Running multiple parallel Selenium WebDriver sessi

2020-07-20 03:41发布

问题:

I am wondering if we are able to run two Selenium WebDriver sessions, or how I can handle two browser windows using the same WebDriver and run them in parallel.

回答1:

Try to define your TestNg suite like the below and then it will start running both at a time.

<suite name="TestSuite" parallel="tests" thread-count="2">
  <test name="Test1" preserve-order="true">
    <parameter name="baseURL" value="http://www.amazon.com" />
    <classes>
      <class name="package.myClass" />
    </classes>
  </test>
  <test name="Test2" preserve-order="true">
    <parameter name="baseURL" value="http://www.google.com" />
    <classes>
      <class name="package.myClass" />
    </classes>
  </test>