python: Selenium webdriver and hanging proxy issue -
i trying understand how handle cases when calls perfomed through proxies hanging. example have code:
def call_with_proxy(ip, port): profile = firefoxprofile() profile.set_preference('network.proxy.type', 1) profile.set_preference('network.proxy.socks', ip) profile.set_preference('network.proxy.socks_port', port) profile.update_preferences() driver= webdriver.firefox(profile) driver.get("http://somewebsite.com")
the proxy taken free proxies list here https://hidemyass.com/proxy-list/
some times everythig works , getting page requesting. getting blank firefox page (where can see elements of website being loaded, e.g. css), , process lasts long time. e.g. session not being closed after 10 minutes of such waiting time. want ask if there way, automatically close browser if example page not loading time, or example test performing stopped execution (due reason related proxies)
in java have:
webdriver.manage().timeouts().pageloadtimeout(30, timeunit.seconds);
from doc:
pageloadtimeout
webdriver.timeouts pageloadtimeout(long time, java.util.concurrent.timeunit unit)
sets amount of time wait page load complete before throwing error. if timeout negative, page loads can indefinite.
parameters: time - timeout value. unit - unit of time. returns: timeouts interface.
quick googling shows:
webdriver.set_page_load_timeout(30)
for python. try in try-catch
(or try-except
in case)
Comments
Post a Comment