javascript - Running multiple instances of selenium webdriver asynchronously (firefox) - Stack Overflow

How can I make my webdriver request multiple pages (or open multiple browsers) at the same time, concur

How can I make my webdriver request multiple pages (or open multiple browsers) at the same time, concurrently?

All solutions I found on the internet waits until the previous session has finished loading and only then open a new instance of the browser.

I have tried selenium-webdriver, webdriverjs and wdjs, and none of them seem to be able to do multiple http requests for different pages asynchronously. Even solutions like this wont work. They all open one at time.

Am I missing something?

PS: I don't want to run multiple browsers concurrently! I want to run multiple instances of the same browser.

How can I make my webdriver request multiple pages (or open multiple browsers) at the same time, concurrently?

All solutions I found on the internet waits until the previous session has finished loading and only then open a new instance of the browser.

I have tried selenium-webdriver, webdriverjs and wdjs, and none of them seem to be able to do multiple http requests for different pages asynchronously. Even solutions like this https://github./OniOni/wd-parallel-async wont work. They all open one at time.

Am I missing something?

PS: I don't want to run multiple browsers concurrently! I want to run multiple instances of the same browser.

Share Improve this question edited Aug 9, 2014 at 9:11 Artjom B. 62k26 gold badges136 silver badges231 bronze badges asked Jun 27, 2014 at 17:07 lucaswxplucaswxp 2,1296 gold badges25 silver badges37 bronze badges 1
  • I think I misunderstood a little the webdrivers. Yes, they all seem to open one at time, but once they are open I can manage them independently. – lucaswxp Commented Jun 27, 2014 at 19:51
Add a ment  | 

2 Answers 2

Reset to default 2

Something like:

WebDriver driver1 = new FirefoxDriver();
WebDriver driver2 = new FirefoxDriver();
WebDriver driver3 = new FirefoxDriver();
driver1.get("page1");
driver2.get("page2");
driver3.get("page3");

If you need it truly asynchronous, then you will need to get into Java threading ... which would make this into a longer discussion and off-topic for SO.

Utilize threading. I see you have node.js tagged...I am not as familiar with that, but below is a c# example that works...similar theory should apply. c#

    Parallel.Invoke(
        ()=> { 1st test execution call },
        ()=> { 2nd test execution call },
        ()=> { 3rd test execution call }
    );

Although be careful as the webdriver can sometimes get confused and overlap windows. I have found that doing more than 5 at a time on a single machine leads to miscellaneous problems. If you use the Parallel.Invoke in c# you can throttle this to only allow a certain number at a time...although Grid is the best way to do that as you setup your limits in configuration and then it load balances for you.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745544073a4632258.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信