我正在尝试使用 Selenium 和 TestNG 同时在两个 android 设备上执行一个测试脚本。但我无法实现它。测试脚本首先在一个设备上执行,然后开始在其他 android 设备上执行。TestNg.xml
这是我使用过的:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Parallel test suite" parallel="methods" thread-count="2">
<test name="Regression 1">
<parameter name="devname" value="adb:SM-G900H" />
<classes>
<class name="Parallel.EribankTetsng"/>
</classes>
</test>
<test name="Regression 2">
<parameter name="devname" value="adb:GT-I9300" />
<classes>
<class name="Parallel.EribankTetsng"/>
</classes>
</test>
</suite>
EribankTestng.java:下面是从seetest自动化导出到selenium的测试脚本。我们将两个 android 设备连接到同一台机器并尝试使用 Testng 并行执行。只有在一台设备执行完成后,才会在第二台设备上开始执行。
public class EribankTetsng
{
private String host = "localhost";
private int port = 8889;
private String projectBaseDirectory = "D:\\Vijaya Seetest";
protected Client client = null;
@BeforeTest
public void setUp(){
client = new Client(host, port, true);
client.setProjectBaseDirectory(projectBaseDirectory);
client.setReporter("xml", "reports", "LoginEribank");
}
@Test(groups = {"seetest"})
@Parameters("devname")
public void testLoginEribank(String devname){
client.setDevice(devname);
client.launch("com.experitest.ExperiBank/.LoginActivity", true, false);
client.elementSendText("Eribank", "Username", 0, "company");
client.elementSendText("Eribank", "passwordTextField", 0, "company");
client.click("Eribank", "Login", 0, 1);
client.click("Eribank", "Logout", 0, 1);
}
@AfterTest
public void tearDown(){
client.generateReport(false);
client.releaseClient();
}
}