Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script breaks while indexing contacts (and why this project is discontinued) #3

Open
AnirudhJohn opened this issue Apr 20, 2021 · 2 comments
Labels
bug Something isn't working critical wontfix This will not be worked on

Comments

@AnirudhJohn
Copy link

Ran it many times, every time it stops after the 7th contact and this is the log:

Most likely this is because you closed the browser window.
If that's not the case please create an issue at https://github.com/ErikTschierschke/WhatsappMonitor/issues including the following message:
Traceback (most recent call last):
File "/root/WhatsappMonitor/whatsappmonitor.py", line 46, in
monitor.start(contacts.select_contacts(browser), browser)
File "/root/WhatsappMonitor/contacts.py", line 19, in select_contacts
contact.click()
File "/usr/local/lib/python3.9/dist-packages/selenium/webdriver/remote/webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "/usr/local/lib/python3.9/dist-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "/usr/local/lib/python3.9/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.9/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: The element reference of

is stale; either the element is no longer attached to the DOM, it is not in the current frame context, or the document has been refreshed

@ErikTschierschke
Copy link
Owner

Yep, the new Whatsapp Web update broke the script again.
It seems like the divs in the contact list are unloaded at random when scrolling up or down.

I'm trying to find a solution but it could take some time.

@ErikTschierschke ErikTschierschke added bug Something isn't working critical labels Apr 21, 2021
@ErikTschierschke
Copy link
Owner

Update:

After a detailed look into the issue I have decided to not fix this issue and thereby discontinue the project.

I wasn't able to figure out to which rules the website unloads the contacts nor how to stop it. I found multiple workarounds but all of them break the script at a later point. A working fix would require rewriting large parts of the script and I am currently lacking spare time to do so.




Below there are some technical details of the issue in case anyone reading this intends to fix the problem:

With the new Whatsapp Web update the site layout has been changed again. Most of the scripts XPath selectors do not work anymore. Fixing them wouldn't be that hard.

Instead, the main issue is that scrolling the contact selection list on the left site sometimes unloads contact divs from the DOM, seemingly at random. The script then throws the error above since it can't find the elements anymore.

I was able to prevent this by setting the contact selector list to a height of 300% so that scrolling becomes unnecessary. But then the header bar on which the script also relies doesn't load properly.


In general the script may break with any upcoming update because of it's architecture. A much more robust approach would be to directly hook into Whatsapp Webs websocket like discribed here.

@ErikTschierschke ErikTschierschke pinned this issue Apr 24, 2021
@ErikTschierschke ErikTschierschke added the wontfix This will not be worked on label Apr 24, 2021
@ErikTschierschke ErikTschierschke changed the title Doesn't map correctly, stops while mapping the whatsapp Script breaks while indexing contacts (and why this project is discontinued) Apr 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working critical wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants