使用Selenium和Testng进行移动并行执行

时间:2017-09-07 12:53:32

标签: selenium testng

我正在尝试使用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();
        }

}

0 个答案:

没有答案