Appium Android—利用TestNG并行执行用例

发表于:2014-12-05 12:53  作者:sanlengjingvv   来源:51Testing软件测试网采编

字体: | 上一篇 | 下一篇 |我要投稿 | 推荐标签: Appium 移动自动化工具 TestNG 白盒测试工具 自动化测试框架

  一、测试类*注1
package com.testerhome;
import io.appium.java_client.android.AndroidDriver;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
public class Suite1 {
public String port;
public String udid;
private AndroidDriver driver;
@Test
public void switches() throws InterruptedException {
WebElement sound = driver.findElementByAndroidUIAutomator("new UiSelector().text(\"Sound\")");
sound.click();
System.out.println("checked");
Thread.sleep(2000);
System.out.println(Thread.currentThread());
}
@BeforeSuite
@Parameters({ "port", "udid" })
public void beforeSuite(String port, String udid) {
this.port = port;
this.udid = udid;
}
@BeforeClass
public void beforeClass() throws MalformedURLException{
System.out.println(port + udid);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName","device1");
capabilities.setCapability("automationName","Appium");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("udid", udid);
capabilities.setCapability("appPackage", "com.android.settings");
capabilities.setCapability("appActivity", ".Settings");
driver = new AndroidDriver(new URL("http://127.0.0.1:" + port + "/wd/hub"), capabilities);
}
@AfterClass
public void afterClass() {
driver.quit();
}
}

21/212>

评 论

论坛新帖



建议使用IE 6.0以上浏览器,800×600以上分辨率,法律顾问:上海信义律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2022, 沪ICP备05003035号
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪公网安备 31010102002173号

51Testing官方微信

51Testing官方微博

扫一扫 测试知识全知道