要使用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