I got a little problem here with a program I built a few days ago, so I'm going to explain it very straightforward:
I'm scraping data from a page with my program, and for doing so, I set this Explicit Wait:
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH,'/this_is_the_XPATH')))
For most of times, it works pretty well, however, there are sometimes in which the Explicit Wait above causes this error:
TimeoutException
Which makes my program stop and have to repeat a long process again.
I realized that the wait parameter set as 10
seconds is not always a good one, so I wanted to know from you guys if there's a way to set this parameter as a variable that always gets the exact load time (in seconds) for a page that is loaded completely.
Other more simple idea could be to repeat the process forcibly until the visibility of element is finally loaded, like by using try and exception blocks, but I don't know what should I type in the exception block to repeat the try one over and over until it's done.
As always, feedback is appreciated, thanks for reading in advance.