1

I am using PhantomJS via Python through Selenium+Ghostdriver.

I am looking to load several pages simultaneously and to do so, I am looking for an async method to load pages.

From my research, PhantomJS already lives in a separate thread and supports multiple tabs, so I believe the only missing piece of the puzzle is a method to load pages in a non-blocking way.

Any solution would be welcome, be it a simple Ghostdriver method I overlooked, bypassing Ghostdriver and interfacing directly with PhantomJS or a different headless browser.

Thanks for the help and suggestions.

Yuval

Yuval Cohen
  • 185
  • 1
  • 1
  • 6

2 Answers2

2

If you want to bypass ghostdriver, then you can directly write your PhantomJS scripts in JavaScript or CoffeeScript. As far as I know there is no way of doing this with the selenium webdriver except with different threads in the language of your choice (python).

If you are not happy with it, there is CasperJS which has more freedom in writing scripts than with selenium, but you will only be able to use PhantomJS or SlimerJS.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
  • Thanks for the quick reply. I will look into CasperJS. Another idea I had was to use WebDriver's execute_script_async and just give it a bunch of "window.location" commands. Is that something that would work? – Yuval Cohen Feb 04 '15 at 11:25
  • No, because they are executed on the same page/tab, so they would overwrite each other. – Artjom B. Feb 04 '15 at 11:27
0

I'm not completely sure on how to do this via Selenium/Ghostdriver specifically, but if you (or future readers) are able to touch the phantom scripts directly, then the solution is as simple as:

page.open(newUrl, ...);

The "page.open()" method is async by default, and should serve your needs. - Quite some time has passed since you asked this question so not sure if you need the help anymore. But, again, for those who may read this later I do hope this helps!

sramzan
  • 96
  • 8