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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745544073a4632258.html
评论列表(0条)