The situation
I have a simple python script to get the HTML source for a given url:
browser = webdriver.PhantomJS()
PhantomJS has provided resourceTimeout
, which might suit your needs. I quote from documentation here
(in milli-secs) defines the timeout after which any resource requested will stop trying and proceed with other parts of the page. onResourceTimeout callback will be called on timeout.
So in Ruby, you can do something like
require 'selenium-webdriver'
capabilities = Selenium::WebDriver::Remote::Capabilities.phantomjs("phantomjs.page.settings.resourceTimeout" => "5000")
driver = Selenium::WebDriver.for :phantomjs, :desired_capabilities => capabilities
I believe in Python, it's something like (untested, only provides the logic, you are the Python developer, hopefully you will figure out)
driver = webdriver.PhantomJS(desired_capabilities={'phantomjs.page.settings.resourceTimeout': '5000'})