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.
Asked
Active
Viewed 2,983 times
3
-
To handle two browser, you don't have to run 2 webdriver session. You can do it from single webdriver session. Check the screenshot in reply I shared here- https://stackoverflow.com/questions/46698136/how-to-run-my-selenium-test-methods-in-parallel-using-testng/46702419#46702419 – Shoaib Akhtar Oct 12 '17 at 09:12
-
Thanks for your reply but I think this is not what I intended to ask. I am not running tests in parallel using grid. My question is to run the webdriver from eclipse and to be able to handle 2 different browser windows. Actually I need to perform few actions e.g. running jobs on another screen or app using different logins and do not want to quit my currently running test so looks like I should wait in my current test and then open another webdriver session with new window and complete the job there, and then continue my current test.... – Hemant Verma - Selenium Oct 12 '17 at 09:23
-
Yes soon after completing your first task with some specific user, you start new webdriver session for another task with different credential if this is the requirement and the required action. I hope this can be done. In case doing this you are facing any issue then you can share that. – Shoaib Akhtar Oct 12 '17 at 09:30
-
1You can just instatiate two webdriver objects. They will manage different browsers. – Alexey R. Oct 12 '17 at 09:50
-
1As Alexey said, you need two instances of web driver for each browser. means, one webdriver can drive/control only one browser. if you need to driver two browsers at a time then, you need to instantiate two drivers in a test. we had same scenario in our project and we had options to launch secondary browser in our framework itself. say driver1 for browser 1 and driver 2 for browser2. – Murthi Oct 12 '17 at 12:06
1 Answers
0
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>

Brandon Stillitano
- 1,304
- 8
- 27

Mounika
- 38
- 7