Friday, 15 March 2013

testng - Multiple instances of chrome are not opening up in grid using webdriver -



testng - Multiple instances of chrome are not opening up in grid using webdriver -

to run parallel test using testng , selenium grid did followed steps.

1)registered hub , grid :-

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 code provide capability , instantiate 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>

run maven test

mvn test -ptestapp

calling hub configuration

http://localhost:4444/grid/console?config=true&configdebug=true

tells 15 instances of chrome available running mvn command 1 instance of chrome opened.tell me if doing wrong.

in suite.xml configured attribute parallel = tests. have 1 test tag in xml file. so, there no chance launch 2 chrome instance.

see testng documentation here more parallelism.

edit:

<suite name="testapp" parallel="classes" > <test verbose="2" name="testapp" annotations="jdk"> <classes> <class name="com.testapp"/> <class name="com.testapp"/> </classes> </test> </suite>

by above xml file @test methods nowadays in class com.testapp run in 2 different threads (i.e. parallel mode).

if want run individual@test method in parallel mode configure xml file parallel attribute methods.

webdriver testng selenium-grid

No comments:

Post a Comment