要使用testng和selenium网格运行并行测试,我的确按照步骤操作。使用webdriver在网格中打开多个chrome实例
1)注册毂和网格: -
java -jar selenium-server-standalone-2.26.0.jar -role hub
java -jar selenium-server-standalone-2.26.0.jar -role node -
Dwebdriver.chrome.driver="C:\D\chromedriver.exe" -hub
http://localhost:4444/grid/register -browser browserName=chrome,version=24,maxInstances=15,platform=WINDOWS
2)的Java代码,以提供能力和实例RemoteWebDriver。
DesiredCapabilities capability=null;
capability= DesiredCapabilities.chrome();
capability.setBrowserName("chrome");
capability.setVersion("24");
capability.setPlatform(org.openqa.selenium.Platform.WINDOWS);
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
driver.get(browsingUrl);
3)Suite.xml
<suite name="testapp" parallel="tests" >
<test verbose="2" name="testapp" annotations="JDK">
<classes>
<class name="com.testapp" />
</classes>
</test>
<profile>
<id>testapp</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<parallel>tests</parallel>
<threadCount>10</threadCount>
<suiteXmlFiles>
<suiteXmlFile>target/test-classes/Suite.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
运行行家测试
mvn test -Ptestapp
调用枢纽配置
http://localhost:4444/grid/console?config=true&configDebug=true
告诉铬的15个实例也有,但运行MVN命令只镀铬的一个实例是opened.Tell我,如果我做错什么。
在浏览器的多个实例中是否无法运行相同的测试? – sandy 2013-02-21 12:25:05
是的,可以在浏览器的多个实例中运行相同的'@ test'方法。要做到这一点,你必须修改你的testng.xml文件。查看编辑过的帖子。 – Manigandan 2013-02-22 04:26:18