Tithibots / tithiwa

Automate Web WhatsApp with selenium in python.
MIT License
24 stars 22 forks source link

Fix sometimes our script throws error while scrolling down while clearing all chats #89

Open NavpreetDevpuri opened 2 years ago

NavpreetDevpuri commented 2 years ago

It is happing most probably due to our script getting the options button from the previous chat and then the next chat loaded but we are trying to click on an element from the previous chat's button

So, to fix it we need to use the _wait_for_an_element_to_deattached for the options button from the previous chat or maybe in some other way

Following error

Traceback (most recent call last):
  File "E:\ee\tithiwa\tithiwa\temp\test.py", line 41, in <module>
    tithiwabot.clear_all_chats()
  File "E:\ee\tithiwa\tithiwa\chatroom.py", line 71, in clear_all_chats
    self._wait_for_presence_of_an_element(SELECTORS.CHATROOM__OPTIONS).click()
 ..etc
  File "C:\Users\ee\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 243, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
  (Session info: chrome=95.0.4638.69)