Skip to content
Advertisement

Selenium retry URL when ValueError

How can I retry url from list if ValueError?

Error:

JavaScript

Or other exceptions.

Can use if ValueError then driver.refresh(2wice)

but I dont know location in the code:

JavaScript

Maximum retry 2

Advertisement

Answer

You can put the entire thing in a try/except block and if it encounters a ValueError at some point, you can put the same code under except and it will retry it.

JavaScript

Throw in a finally: after the except block with the same spacing if you want it to do something after it’s tried twice.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement