要使用 testng 和 selenium 网格运行并行测试,我确实遵循了步骤。
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>
运行maven测试
mvn test -Ptestapp
呼叫中心配置
http://localhost:4444/grid/console?config=true&configDebug=true
告诉我有 15 个 chrome 实例可用,但运行 mvn 命令只打开了一个 chrome 实例。如果我做错了什么,请告诉我。