admin管理员组文章数量:1429078
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
2 Answers
Reset to default 2Something 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.
本文标签: javascriptRunning multiple instances of selenium webdriver asynchronously (firefox)Stack Overflow
版权声明:本文标题:javascript - Running multiple instances of selenium webdriver asynchronously (firefox) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745544072a2662624.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论