appium第一个脚本

package test_ios;

import org.testng.annotations.Test;

import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
import java.io.File;
import java.net.URL;
import java.util.List;

import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.MobileBy;
import io.appium.java_client.ios.IOSDriver;

public class iOSTest {

    static IOSDriver<WebElement> driver= null;

    @BeforeMethod
    public void setUp() throws Exception {
        // set up appium
        File classpathRoot = new File(System.getProperty("user.dir"));//返回当前用户工作目录
        File appDir = new File(classpathRoot, "apps");
        File app = new File(appDir, "XX.app");
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("platformName", "iOS");// 设备平台
        capabilities.setCapability("deviceName", "iPhone 4s");// 设备名称
        capabilities.setCapability("platformVersion", "8.4");// 版本
        capabilities.setCapability("app", app.getAbsolutePath());// apk路径
        capabilities.setCapability("noSign", true);// 禁止重签名
        capabilities.setCapability("autoAcceptAlerts", true);// 自动接受提示信息
        driver = new IOSDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    }

    @Test
    public void testCaseKartor() throws Exception {

        //我的账户login
        driver.findElementByXPath("//UIAApplication[1]/UIAWindow[1]/UIAButton[1]").click();
        Thread.sleep(2000);

        //输入账户
        driver.findElementByClassName("UIATextField").click();
        driver.findElementByClassName("UIATextField").clear();
        driver.findElementByXPath("/UIAApplication[1]/UIAWindow[2]/UIAImage[1]/UIATextField[1]").sendKeys("123");

        //输入密码
        driver.findElementByName("UIASecureTextField").click();
        driver.findElementByName("UIASecureTextField").clear();
        driver.findElementByXPath("/UIAApplication[1]/UIAWindow[2]/UIAImage[1]/UIASecureTextField[1]").sendKeys("123");

        //登录
        driver.findElementByName("登录").click();
        Thread.sleep(2000);
    }

    @AfterMethod
    public void done()
    {
        driver.quit();
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值