Open Mascherino opened 3 months ago
I was getting this same error (though only on mobile searches), and this fix worked for me in searches.py (lines 171-173):
try:
searchbar = self.browser.utils.waitUntilClickable(
By.ID, "sb_form_q", timeToWait=40
)
except TimeoutException:
logging.debug("TimeoutException")
self.browser.utils.goToSearch()
return
The idea is to just gracefully fail when this happens - the self.browser.utils.goToSearch()
was necessary to somehow reset the webpage so the next waitUntilClickable
won't just timeout again.
I did something similar to try and fix it. Unfortunately I was getting http2 errors after a few errors got caught. Disabling http2 with the --disable-http2
flag in chrome options fixed that and everything works smoothly now.
Me too. I first tried increasing timetoWait, but did not help. I will try both of these solutions. Suggest doing a PR if they work.
Edit, tried both of your suggestions and still got errors. I caught timeout error, but it just looping until it crashed. For me, the timeouts are intermittent in each run, so these fixes appear to work but then don't.
I was getting this same error (though only on mobile searches), and this fix worked for me in searches.py (lines 171-173):
try: searchbar = self.browser.utils.waitUntilClickable( By.ID, "sb_form_q", timeToWait=40 ) except TimeoutException: logging.debug("TimeoutException") self.browser.utils.goToSearch() return
The idea is to just gracefully fail when this happens - the
self.browser.utils.goToSearch()
was necessary to somehow reset the webpage so the nextwaitUntilClickable
won't just timeout again.
This works, the script is not crashing with the mentioned error(s). However, as @jdeath said, it just creates a loop of a search attempt at some point, trying the same search term over and over again while failing it every single time.
edit: Didn't work today. Got into endless TimeoutException loop...
I finally had it complete all searches on first try and successfully continued through a timeout exception. It is based on @mshancock code. Making a new window is what allowed it to not get stuck in an endless timeout loop. Could close the old tab, but I did not bother. I did not need to add --disable-http2
but did add --headless=new
, not sure if necessary
Only worked once, but I will keep testing, I'll do a PR if keeps working
searches.py:
try:
searchbar = self.browser.utils.waitUntilClickable(
By.ID, "sb_form_q", timeToWait=40
)
except TimeoutException:
logging.debug("TimeoutException - Making New Tab")
self.browser.utils.createAndVisitNewTab()
self.browser.utils.goToSearch()
return
utils.py, add a function:
def createAndVisitNewTab(self, timeToWait: float = 0) -> None:
self.webdriver.switch_to.new_window('window')
I also added to browser.py browserSetup, but I am not sure if it was necessary.
options.add_argument("--headless=new")
Function names should probably be changed. I first tried to make a new tab using the existing functions in utils.py, but did not work. I then found the line of code I needed in the selenium documentation. Could change 'window' to 'tab' to see if still works.
Before submitting a bug report...
[X] This bug wasn't already reported. (I have checked every bug report on GitHub)
[X] I've cleared the sessions folder.
Title
Branch
develop
Commit
750fa7a
Describe the bug
The first searches work as expected, but after a few searches, I get the error below. The browser is on the rewards dashboard, loading forever, resulting in a TimeoutException after about 5 minutes of waiting. It seems like it tries to go to the page of the last search term ("hertha bsc") to start the next search but fails to do so for some reason. Manually refreshing the page returns it to the rewards dashboard, crashing the program.
Copy and paste your error
Screenshots
Value of dashboard variable
N/A