[英]Run selenium grid test in 2 browser in one machine(Chrome and Firefox)
I have few tests, i want to run the tests on both Chrome and firefox. 我的测试很少,我想同时在Chrome和firefox上运行测试。
How can i do that? 我怎样才能做到这一点?
My code is: 我的代码是:
@Test //Test1
public void logInFaildTest() {
GridTest gridTest = new GridTest();
WebDriver webDriver = gridTest.getWebDriver();//get driver
LoginPage logIn = new LoginPage(webDriver, url);
String userName = "user";
String pass="pass";
......................................
webDriver.close();
}
}
Create an xml file, testing.xml with the desired parameters and add a Parameters annotation (@Parameters) over your loginfailed method. 创建一个具有所需参数的xml文件testing.xml,并在您的loginfailed方法上方添加一个Parameters批注(@Parameters)。 That would pass all the desired parameters required for your tests
这将通过测试所需的所有所需参数
Your testing.xml might look like : 您的testing.xml可能看起来像:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="TestSuite" thread-count="2" parallel="tests" >
<test name="ChromeTest">
<parameter name="browser" value="Chrome" />
<classes>
<class name="<your class name here>">
</class>
</classes>
</test>
<test name="FirefoxTest">
<parameter name="browser" value="Firefox" />
<classes>
<class name="<Your class name here>">
</class>
</classes>
</test>
<test name="IETest">
<parameter name="browser" value="IE" />
<classes>
<class name="<Your class name here>">
</class>
</classes>
</test>
</suite>
The above xml runs tests in parallel threads across all the three given browsers. 上面的xml在所有三个给定的浏览器中以并行线程运行测试。 In your java code, you should pass the parameters from testing.xml like
在您的Java代码中,您应该像这样传递来自testing.xml的参数
@Parameters("browser")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.