Is the parallel execution possible, without selenium grid?or (only testNG is enough?)

半城伤御伤魂 提交于 2019-12-12 01:54:37

问题


I am beginner in selenium webdriver. so for parallel execution normally we do changes in xml file like parallel="methods" thread-count="3" and my doubt is:

Is the parallel execution possible without selenium grid? or only testNG is enough?


回答1:


Yes, you may run UI tests in parallel without grid, or using only selenium grid node directly, without hub. Each thread in TestNG will open additional browser window, but you will get unpredictable issues in case when you application will manage all connections from you host as one user session.




回答2:


Yes, using @Parameters ("browser") of TestNg..sample code as below...

 @Parameters ("browser")
  public void test(String browserName) {
      if(browserName.equalsIgnoreCase("firefox")){
          driver = new FirefoxDriver();

      } else if (browserName.equalsIgnoreCase("chrome")){
          System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir")+"\\chromedriver.exe" );
          driver = new ChromeDriver();
      }
  }

write your test after that in your testng.xml use parallel option also mention the parameter value.. sample code as below..

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite789787" parallel="tests">
  <test name="FFTest98798">
  <parameter name="browser" value="firefox"/>   

  <classes>
    <class name ="crossbrowsertest.VerifyTitle" >
    </class>
  </classes>
  </test> <!-- Test -->

  <test name="ChromeTest8999">
    <parameter name="browser" value="chrome"/>  

  <classes>
    <class name ="crossbrowsertest.VerifyTitle" >
    </class>
  </classes>
  </test>   <!-- Test -->
</suite> <!-- Suite -->

hope this helps



来源:https://stackoverflow.com/questions/36148658/is-the-parallel-execution-possible-without-selenium-gridor-only-testng-is-eno

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!