selenium - Executing tests Concurrently on different OS and Browsers with WebDriver using Java and TestNG -
i have configured grid in system , written test script. can run test on specified os , browser on 1 os , 1 browser @ 1 time not os , browser simultaneously. here have done. please tell me how can configure can run in configured os in 1 time.
my script using java below:
import java.net.malformedurlexception; import java.net.url; import org.junit.afterclass; import org.openqa.selenium.*; import org.openqa.selenium.remote.desiredcapabilities; import org.openqa.selenium.remote.remotewebdriver; import org.testng.annotations.*; public class gridwithwebdriver { public webdriver driver; @parameters({"browser"}) @beforeclass public void setup(string browser) throws malformedurlexception { desiredcapabilities capability=null; if(browser.equalsignorecase("firefox")){ system.out.println("firefox"); capability= desiredcapabilities.firefox(); capability.setbrowsername("firefox"); capability.setplatform(org.openqa.selenium.platform.any); //capability.setversion(""); } if(browser.equalsignorecase("iexplore")){ system.out.println("iexplore"); capability= desiredcapabilities.internetexplorer(); capability.setbrowsername("iexplore"); capability.setplatform(org.openqa.selenium.platform.windows); //capability.setversion(""); } driver = new remotewebdriver(<span class="il_ad" id="il_ad11">new url</span>("http://localhost:4444/wd/hub"), capability); driver.navigate().to("http://google.com"); } @test public void test_first() throws interruptedexception{ thread.sleep(3000); webelement search_editbox = driver.findelement(by.name("q")); webelement search_button = driver.findelement(by.name("btng")); search_editbox.clear(); search_editbox.sendkeys("first"); search_button.click(); } @test public void test_second(){ webelement search_editbox = driver.findelement(by.name("q")); webelement search_button = driver.findelement(by.name("btng")); search_editbox.clear(); search_editbox.sendkeys("second"); search_button.click(); } @afterclass public void teardown(){ driver.quit(); } }
testng.xml:
<suite name="selenium <span class="il_ad" id="il_ad7">grid with</span> webdriver" verbose="3" parallel="classes" thread-count="2"> <test name="selenium grid demo"> <parameter name="browser" value="iexplore"/> <classes> <class name="tests.gridwithwebdriver"/> <class name="tests.gridwithwebdriver1"/> </classes> </test> </suite>
aditya,
your code(testng.xml) running parallel test on different-different or same system should below:
testng.xml
<!doctype suite system "http://testng.org/testng-1.0.dtd"> <suite name="my sample suite" verbose="3" parallel="tests" thread-count="2"> <test name="run on firefox"> <parameter name="mybrowser" value="firefox"/> <parameter name="myip" value="http://172.16.10.119:5566/wd/hub"/> <classes> <class name="testcases.login"/> </classes> </test> <test name="run on chrome"> <parameter name="mybrowser" value="chrome"/> <parameter name="myip" value="http://172.16.10.106:5567/wd/hub"/> <classes> <class name="testcases.login"/> </classes> </test> </suite> here trying acess 1 linux(ttp://172.16.10.119:5566) , 1 mac(http://172.16.10.106:5567) , sending ip , browser parameter. run parallel have mentioned in <testsuite> tag parallel="tests" thread-count="2"
i hope pretty clear now.
Comments
Post a Comment