码迷,mamicode.com
首页 > 移动开发 > 详细

Appium for iOS setup

时间:2015-11-17 00:15:07      阅读:390      评论:0      收藏:0      [点我收藏+]

标签:

                    知乎Android客户端登陆:http://www.cnblogs.com/tobecrazy/p/4579631.html

                                                  appium实现截图和清空EditText:http://www.cnblogs.com/tobecrazy/p/4592405.html

                                                  appium 滑动处理:http://www.cnblogs.com/tobecrazy/p/4612133.html

                   ChromeDriver:http://www.cnblogs.com/tobecrazy/p/4836995.html

                                              appium 九宫格解锁招商银行手机客户端app :http://www.cnblogs.com/tobecrazy/p/4881390.html

                                             Hybrid app webview :http://www.cnblogs.com/tobecrazy/p/4905917.html

 


 

Mac准备环境

1. JDK安装

2. xcode安装

3. NodeJS安装

4. Appium 安装

5. 使用Appium example demo

 

6. 创建测试用例

  

package com.dbyl.core;


import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import io.appium.java_client.ios.IOSDriver;

import java.io.File;

import java.net.URL;

import java.util.concurrent.TimeUnit;

public class iOSTest {
    private IOSDriver driver;
    private boolean isInstall = true;

     
    @BeforeClass(alwaysRun = true)
    public void setUp() throws Exception {
        // set up appium

        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "iOS");
        capabilities.setCapability("platformName", "Mac");
        capabilities.setCapability("deviceName", "iPhone 6");
        capabilities.setCapability("platformVersion", "8.4");
        // if no need install don‘t add this
        if (isInstall) {
            File classpathRoot = new File(System.getProperty("user.dir"));
            File appDir = new File(classpathRoot, "apps");
            File app = new File(appDir, "TestApp.app");
            System.out.println("---->"+app.getAbsolutePath());
            capabilities.setCapability("app", app.getAbsolutePath());
        }

        // support Chinese
        capabilities.setCapability("unicodeKeyboard", "True");
        capabilities.setCapability("resetKeyboard", "True");
    
        driver = new IOSDriver (new URL("http://127.0.0.1:4723/wd/hub"),
                capabilities);
         
    }

    @Test
    public void login() {

     
        // wait for 20s
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

        // find login userName and password editText
        WebElement inputbox1 =driver.findElementByName("TextField1");
        inputbox1.sendKeys("12");
        
        WebElement inputbox2 =driver.findElementByName("TextField2");
        inputbox2.sendKeys("65");
        
        WebElement calcButton=driver.findElementByXPath("//UIAApplication[1]/UIAWindow[2]/UIAButton[1]");
        
        calcButton.click();
        WebElement result=driver.findElementByXPath("//UIAApplication[1]/UIAWindow[2]/UIAStaticText[1]");
        Assert.assertEquals(result.getAttribute("value"), "77");
    }
 

    @AfterClass(alwaysRun = true)
    public void tearDown() throws Exception {
        driver.quit();
    }
 
}

 

7. 相关资料

视频教程:https://www.youtube.com/watch?v=BULjgsTpw2c

代码:https://github.com/tobecrazy/appiumDemo

Appium for iOS setup

标签:

原文地址:http://www.cnblogs.com/tobecrazy/p/4970188.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
分享档案
周排行
mamicode.com排行更多图片
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!