DevInprogress
DevInprogress

Reputation: 1

Refresh webpage if got connection time out selenium python

I am using proxies rotating and sometimes it could happen one of these randomly doesn't work and I get "ERR_TIMED_OUT" enable to reach server and script just crashed without continuing, is it possible to refresh the webpage automatically in silenium when this happens (so the proxy will rotate). I thought about catch exception putting then driver.refresh() but how can I catch into the entire code without try- except for every instruction? is there another solution? thanks!

Upvotes: 0

Views: 392

Answers (1)

Piotr M.
Piotr M.

Reputation: 395

You can use event_firing_webdriver: https://www.selenium.dev/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.event_firing_webdriver.html

you can decorate method get() and execute try except there (with refresh on timeout exception).

Upvotes: 1

Related Questions