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

The script is loading #34

Open
rfalcon-cnmc opened this issue Apr 2, 2024 · 21 comments
Open

The script is loading #34

rfalcon-cnmc opened this issue Apr 2, 2024 · 21 comments
Assignees
Labels
bug Something isn't working

Comments

@rfalcon-cnmc
Copy link

Hi,

image

My chrome
image

My Chromedriver
image

What could be a problem?

Copy link

github-actions bot commented Apr 2, 2024

Thank you for your first issue to whatsapp-osint! I really appreciate your interest and hope you enjoy the repository.

@jasperan
Copy link
Owner

jasperan commented Apr 2, 2024

Hey @rfalcon-cnmc , could you show me what happens in the graphical interface when you launch the program? Or is it stuck permanently on Loading....?

A visual GUI interface should appear for you and whatsapp-osint should be redirecting you to scan the QR code automatically

@rfalcon-cnmc
Copy link
Author

what-osin.webm
I leave you a complete recording of the execution

@jasperan
Copy link
Owner

jasperan commented Apr 2, 2024

Hey @rfalcon-cnmc , so I have modified the code to add some debug logging when there is the permanently stuck loading error (now you will get a more detailed exception).

I think that the issue is that it's not detecting the following XPATH element in the web app: //div[@data-testid="wa-web-loading-screen"] which is the loading screen for whatsapp. For some reason it's loading extremely fast for you and you don't get a loading screen as usual.

Can you try again with the new version, and print this error here?

If we can't fix it like this, I will add the possibility to skip the loading step by pressing a key like F1.

@jasperan jasperan self-assigned this Apr 2, 2024
@jasperan jasperan added the bug Something isn't working label Apr 2, 2024
@rfalcon-cnmc
Copy link
Author

@jasperan It is throwing me this error:

Loading...: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@data-testid="wa-web-loading-screen"]"}
  (Session info: chrome=123.0.6312.86); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
#0 0x60df8ff5c8a3 <unknown>
#1 0x60df8fc528c6 <unknown>
#2 0x60df8fc9d618 <unknown>
#3 0x60df8fc9d6d1 <unknown>
#4 0x60df8fce0744 <unknown>
#5 0x60df8fcbf5cd <unknown>
#6 0x60df8fcddc19 <unknown>
#7 0x60df8fcbf343 <unknown>
#8 0x60df8fc90593 <unknown>
#9 0x60df8fc90f5e <unknown>
#10 0x60df8ff2088b <unknown>
#11 0x60df8ff247e5 <unknown>
#12 0x60df8ff0e5b1 <unknown>
#13 0x60df8ff25372 <unknown>
#14 0x60df8fef38bf <unknown>
#15 0x60df8ff4b768 <unknown>
#16 0x60df8ff4b93b <unknown>
#17 0x60df8ff5b9f4 <unknown>
#18 0x78072a694ac3 <unknown>
Loading...: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@data-testid="wa-web-loading-screen"]"}

@jasperan
Copy link
Owner

jasperan commented Apr 3, 2024

Hey can you try with the new code? You should skip the loading screen by pressing F1

@rfalcon-cnmc
Copy link
Author

First I added "keyboard" requirements.txt

rfalconadm@CNMC2294U ~/whatsapp-osint (master)$ python3 whatsappbeacon.py --username "Yooooo" --language "es"
In order to make this program to work, you will need to log-in once in WhatsApp. After that, your session will be saved until you revoke it.
Loading. Press F1 if stuck in this step...: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@data-testid="wa-web-loading-screen"]"}
  (Session info: chrome=123.0.6312.105); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
#0 0x5ed3752518a3 <unknown>
#1 0x5ed374f478c6 <unknown>
#2 0x5ed374f92618 <unknown>
#3 0x5ed374f926d1 <unknown>
#4 0x5ed374fd5744 <unknown>
#5 0x5ed374fb45cd <unknown>
#6 0x5ed374fd2c19 <unknown>
#7 0x5ed374fb4343 <unknown>
#8 0x5ed374f85593 <unknown>
#9 0x5ed374f85f5e <unknown>
#10 0x5ed37521588b <unknown>
#11 0x5ed3752197e5 <unknown>
#12 0x5ed3752035b1 <unknown>
#13 0x5ed37521a372 <unknown>
#14 0x5ed3751e88bf <unknown>
#15 0x5ed375240768 <unknown>
#16 0x5ed37524093b <unknown>
#17 0x5ed3752509f4 <unknown>
#18 0x74a34ac94ac3 <unknown>
Traceback (most recent call last):
  File "/home/rfalconadm/whatsapp-osint/whatsappbeacon.py", line 169, in whatsapp_load
    loading = driver.find_element(by=By.XPATH, value='//div[@data-testid="wa-web-loading-screen"]')
  File "/home/rfalconadm/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 741, in find_element
    return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
  File "/home/rfalconadm/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 347, in execute
    self.error_handler.check_response(response)
  File "/home/rfalconadm/.local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@data-testid="wa-web-loading-screen"]"}
  (Session info: chrome=123.0.6312.105); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
#0 0x5ed3752518a3 <unknown>
#1 0x5ed374f478c6 <unknown>
#2 0x5ed374f92618 <unknown>
#3 0x5ed374f926d1 <unknown>
#4 0x5ed374fd5744 <unknown>
#5 0x5ed374fb45cd <unknown>
#6 0x5ed374fd2c19 <unknown>
#7 0x5ed374fb4343 <unknown>
#8 0x5ed374f85593 <unknown>
#9 0x5ed374f85f5e <unknown>
#10 0x5ed37521588b <unknown>
#11 0x5ed3752197e5 <unknown>
#12 0x5ed3752035b1 <unknown>
#13 0x5ed37521a372 <unknown>
#14 0x5ed3751e88bf <unknown>
#15 0x5ed375240768 <unknown>
#16 0x5ed37524093b <unknown>
#17 0x5ed3752509f4 <unknown>
#18 0x74a34ac94ac3 <unknown>


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/rfalconadm/whatsapp-osint/whatsappbeacon.py", line 250, in <module>
    main()
  File "/home/rfalconadm/whatsapp-osint/whatsappbeacon.py", line 243, in main
    driver = whatsapp_login()
  File "/home/rfalconadm/whatsapp-osint/whatsappbeacon.py", line 205, in whatsapp_login
    whatsapp_load(driver=driver)
  File "/home/rfalconadm/whatsapp-osint/whatsappbeacon.py", line 175, in whatsapp_load
    if keyboard.is_pressed('F1'):
  File "/home/rfalconadm/.local/lib/python3.10/site-packages/keyboard/__init__.py", line 410, in is_pressed
    _listener.start_if_necessary()
  File "/home/rfalconadm/.local/lib/python3.10/site-packages/keyboard/_generic.py", line 35, in start_if_necessary
    self.init()
  File "/home/rfalconadm/.local/lib/python3.10/site-packages/keyboard/__init__.py", line 196, in init
    _os_keyboard.init()
  File "/home/rfalconadm/.local/lib/python3.10/site-packages/keyboard/_nixkeyboard.py", line 113, in init
    build_device()
  File "/home/rfalconadm/.local/lib/python3.10/site-packages/keyboard/_nixkeyboard.py", line 109, in build_device
    ensure_root()
  File "/home/rfalconadm/.local/lib/python3.10/site-packages/keyboard/_nixcommon.py", line 174, in ensure_root
    raise ImportError('You must be root to use this library on linux.')
ImportError: You must be root to use this library on linux.

@jasperan
Copy link
Owner

jasperan commented Apr 7, 2024

The keyboard library requires root permissions on the user you're trying to execute, the script is not failing now but getting stuck on the new skip line feature with F1.

Can you try to run the program with administrative privileges?

@zubi33
Copy link

zubi33 commented Jul 17, 2024

First of all, thank you for your work. I'm very interested in this tool. Unfortunately, I'm having trouble using it. I've added the ‘keyboard’ library, which isn't in the requirements.txt. Then I ran the script command with and without privileges.

Here are the results:

Without privileges :

python3 whatsappbeacon.py --username "XXX" --language "fr"
In order to make this program to work, you will need to log-in once in WhatsApp. After that, your session will be saved until you revoke it.
Loading. Press F1 if stuck in this step...: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@data-testid="wa-web-loading-screen"]"}
  (Session info: chrome=126.0.6478.182); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
#0 0x65202bb60c7a <unknown>
#1 0x65202b843e2c <unknown>
#2 0x65202b890661 <unknown>
#3 0x65202b890751 <unknown>
#4 0x65202b8d4f64 <unknown>
#5 0x65202b8b35ed <unknown>
#6 0x65202b8d2303 <unknown>
#7 0x65202b8b3363 <unknown>
#8 0x65202b883247 <unknown>
#9 0x65202b883b9e <unknown>
#10 0x65202bb2724b <unknown>
#11 0x65202bb2b2f1 <unknown>
#12 0x65202bb12afe <unknown>
#13 0x65202bb2be52 <unknown>
#14 0x65202baf779f <unknown>
#15 0x65202bb50638 <unknown>
#16 0x65202bb50810 <unknown>
#17 0x65202bb5fdac <unknown>
#18 0x7c98c70fdded <unknown>
#19 0x7c98c71810dc <unknown>
Traceback (most recent call last):
  File "/home/osint/Documents/whatsapp-osint/whatsappbeacon.py", line 169, in whatsapp_load
    loading = driver.find_element(by=By.XPATH, value='//div[@data-testid="wa-web-loading-screen"]')
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/osint/Documents/whatsapp-osint/env/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 748, in find_element
    return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/osint/Documents/whatsapp-osint/env/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute
    self.error_handler.check_response(response)
  File "/home/osint/Documents/whatsapp-osint/env/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@data-testid="wa-web-loading-screen"]"}
  (Session info: chrome=126.0.6478.182); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
#0 0x65202bb60c7a <unknown>
#1 0x65202b843e2c <unknown>
#2 0x65202b890661 <unknown>
#3 0x65202b890751 <unknown>
#4 0x65202b8d4f64 <unknown>
#5 0x65202b8b35ed <unknown>
#6 0x65202b8d2303 <unknown>
#7 0x65202b8b3363 <unknown>
#8 0x65202b883247 <unknown>
#9 0x65202b883b9e <unknown>
#10 0x65202bb2724b <unknown>
#11 0x65202bb2b2f1 <unknown>
#12 0x65202bb12afe <unknown>
#13 0x65202bb2be52 <unknown>
#14 0x65202baf779f <unknown>
#15 0x65202bb50638 <unknown>
#16 0x65202bb50810 <unknown>
#17 0x65202bb5fdac <unknown>
#18 0x7c98c70fdded <unknown>
#19 0x7c98c71810dc <unknown>


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/osint/Documents/whatsapp-osint/whatsappbeacon.py", line 250, in <module>
    main()
  File "/home/osint/Documents/whatsapp-osint/whatsappbeacon.py", line 243, in main
    driver = whatsapp_login()
             ^^^^^^^^^^^^^^^^
  File "/home/osint/Documents/whatsapp-osint/whatsappbeacon.py", line 205, in whatsapp_login
    whatsapp_load(driver=driver)
  File "/home/osint/Documents/whatsapp-osint/whatsappbeacon.py", line 175, in whatsapp_load
    if keyboard.is_pressed('F1'):
       ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/osint/Documents/whatsapp-osint/env/lib/python3.12/site-packages/keyboard/__init__.py", line 410, in is_pressed
    _listener.start_if_necessary()
  File "/home/osint/Documents/whatsapp-osint/env/lib/python3.12/site-packages/keyboard/_generic.py", line 35, in start_if_necessary
    self.init()
  File "/home/osint/Documents/whatsapp-osint/env/lib/python3.12/site-packages/keyboard/__init__.py", line 196, in init
    _os_keyboard.init()
  File "/home/osint/Documents/whatsapp-osint/env/lib/python3.12/site-packages/keyboard/_nixkeyboard.py", line 113, in init
    build_device()
  File "/home/osint/Documents/whatsapp-osint/env/lib/python3.12/site-packages/keyboard/_nixkeyboard.py", line 109, in build_device
    ensure_root()
  File "/home/osint/Documents/whatsapp-osint/env/lib/python3.12/site-packages/keyboard/_nixcommon.py", line 174, in ensure_root
    raise ImportError('You must be root to use this library on linux.')
ImportError: You must be root to use this library on linux.

With privileges :

sudo python3 whatsappbeacon.py --username "XXX" --language "fr"
In order to make this program to work, you will need to log-in once in WhatsApp. After that, your session will be saved until you revoke it.
Traceback (most recent call last):
  File "/home/osint/Documents/whatsapp-osint/whatsappbeacon.py", line 250, in <module>
    main()
  File "/home/osint/Documents/whatsapp-osint/whatsappbeacon.py", line 243, in main
    driver = whatsapp_login()
             ^^^^^^^^^^^^^^^^
  File "/home/osint/Documents/whatsapp-osint/whatsappbeacon.py", line 200, in whatsapp_login
    driver = webdriver.Chrome(options=options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/osint/Documents/whatsapp-osint/env/lib/python3.12/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/osint/Documents/whatsapp-osint/env/lib/python3.12/site-packages/selenium/webdriver/chromium/webdriver.py", line 66, in __init__
    super().__init__(command_executor=executor, options=options)
  File "/home/osint/Documents/whatsapp-osint/env/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 212, in __init__
    self.start_session(capabilities)
  File "/home/osint/Documents/whatsapp-osint/env/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 299, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/osint/Documents/whatsapp-osint/env/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute
    self.error_handler.check_response(response)
  File "/home/osint/Documents/whatsapp-osint/env/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome failed to start: exited normally.
  (session not created: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /root/.cache/selenium/chrome/linux64/126.0.6478.182/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x6402da3e6c7a <unknown>
#1 0x6402da0c9e2c <unknown>
#2 0x6402da0fed6a <unknown>
#3 0x6402da0fb17b <unknown>
#4 0x6402da145c49 <unknown>
#5 0x6402da139363 <unknown>
#6 0x6402da109247 <unknown>
#7 0x6402da109b9e <unknown>
#8 0x6402da3ad24b <unknown>
#9 0x6402da3b12f1 <unknown>
#10 0x6402da398afe <unknown>
#11 0x6402da3b1e52 <unknown>
#12 0x6402da37d79f <unknown>
#13 0x6402da3d6638 <unknown>
#14 0x6402da3d6810 <unknown>
#15 0x6402da3e5dac <unknown>
#16 0x74f40a011ded <unknown>
#17 0x74f40a0950dc <unknown>

I ran this program on a virtual machine (Archlinux) on Virtualbox. Here are the versions of the programs requested:

Google Chrome 126.0.6478.126
ChromeDriver 126.0.6478.126 (d36ace6122e0a59570e258d82441395206d60e1c-refs/branch-heads/6478@{#1591})
Python 3.12.4

@jasperan
Copy link
Owner

Hey @zubi33 , this is a known issue (the second one) which happens when you run chromedriver as root. The intended use is for you to run without privileges, and trying to fix the first issue.

On line 175, in whatsappbeacon.py, there is a if statement. You can try to delete that statement and the command inside it:

if keyboard.is_pressed('F1'):
.......

Delete these lines, and remove the keyboard import, I think it's the only time it's being used.

On Windows, it would work for you, but Linux and the keyboard module aren't good friends. :)

@zubi33
Copy link

zubi33 commented Jul 18, 2024

@jasperan

On Linux, after removing the block from the if statement and removing keyboard from the import, it seems to run in an infinite loop :

Loading. Press F1 if stuck in this step...: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@data-testid="wa-web-loading-screen"]"}
  (Session info: chrome=126.0.6478.182); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
#0 0x6418fc582c7a <unknown>
#1 0x6418fc265e2c <unknown>
#2 0x6418fc2b2661 <unknown>
#3 0x6418fc2b2751 <unknown>
#4 0x6418fc2f6f64 <unknown>
#5 0x6418fc2d55ed <unknown>
#6 0x6418fc2f4303 <unknown>
#7 0x6418fc2d5363 <unknown>
#8 0x6418fc2a5247 <unknown>
#9 0x6418fc2a5b9e <unknown>
#10 0x6418fc54924b <unknown>
#11 0x6418fc54d2f1 <unknown>
#12 0x6418fc534afe <unknown>
#13 0x6418fc54de52 <unknown>
#14 0x6418fc51979f <unknown>
#15 0x6418fc572638 <unknown>
#16 0x6418fc572810 <unknown>
#17 0x6418fc581dac <unknown>
#18 0x7c62e27bbded <unknown>
#19 0x7c62e283f0dc <unknown>

Under Windows, this also seems to be a loop:

Loading. Press F1 if stuck in this step...: Message: no such window: target window already closed
from unknown error: web view not found
  (Session info: chrome=126.0.6478.182)
Stacktrace:
        GetHandleVerifier [0x00007FF6C35DEEB2+31554]
        (No symbol) [0x00007FF6C3557EE9]
        (No symbol) [0x00007FF6C341872A]
        (No symbol) [0x00007FF6C33ED995]
        (No symbol) [0x00007FF6C34944D7]
        (No symbol) [0x00007FF6C34AC051]
        (No symbol) [0x00007FF6C348CDD3]
        (No symbol) [0x00007FF6C345A33B]
        (No symbol) [0x00007FF6C345AED1]
        GetHandleVerifier [0x00007FF6C38E8B2D+3217341]
        GetHandleVerifier [0x00007FF6C3935AF3+3532675]
        GetHandleVerifier [0x00007FF6C392B0F0+3489152]
        GetHandleVerifier [0x00007FF6C368E786+750614]
        (No symbol) [0x00007FF6C356376F]
        (No symbol) [0x00007FF6C355EB24]
        (No symbol) [0x00007FF6C355ECB2]
        (No symbol) [0x00007FF6C354E17F]
        BaseThreadInitThunk [0x00007FF9B8DB257D+29]
        RtlUserThreadStart [0x00007FF9B980AF28+40]

Did WhatsApp change some of the headings in the code so that the software could no longer find them?

@jasperan
Copy link
Owner

jasperan commented Jul 18, 2024

@zubi33 , keep the "break" statement but remove the if. It should look like:

except Exception as e:
    print("Loading. Press F1 if stuck in this step...: {}".format(e), end=f"\r")
    break

@zubi33
Copy link

zubi33 commented Jul 19, 2024

@jasperan, it would appear that even with the addition of break, the programme will not work. It cannot find the selected contact. Perhaps it's a language problem because i use french ?

XXX is not found. Returning...(Maybe your contact is in the archive. Check it)

@jasperan
Copy link
Owner

Hmmm @zubi33 , French language should be supported. Have you put the name exactly as it is found (byte by byte) as the target? If you think it's a language issue you can also try with English by changing the language of your WhatsApp

@zubi33
Copy link

zubi33 commented Jul 25, 2024

@jasperan Unfortunately, I couldn't get the script to work. I tried with a simple name ‘Florine’. I also tried changing the language to English, but I got the following result:

Florine is not found. Returning...(Maybe your contact is in the archive. Check it)

@jasperan
Copy link
Owner

This is a weird issue, I am quite busy right now with work but I have put this in my watchlist to debug what's happening - I have tested myself and for me it's working - I'll be able to have a look in a couple of weeks

@labeleza
Copy link

labeleza commented Aug 8, 2024

I have the same error, it says it can't find the contact

@BurnsteinKarl
Copy link

BurnsteinKarl commented Sep 23, 2024

@jasperan Why using name instead of using phone numbers to identify targets, I don't get your choice here... Because for example I have some contacts that have 2 or 3 numbers under one name, so how will it manage these cases? will your script bug on those targets?

@jasperan
Copy link
Owner

@BurnsteinKarl because even if the phone number is unique and the name isn't, nobody has duplicate names for contacts in their contacts list (it's confusing)

Also, it's searching for HTML elements in the chat interface, if you have a person added as a contact, it won't display their phone number in their name. But, if you have someone in your recents without a contact saved, you can input the phone number as their "name" and it will still work

@BurnsteinKarl
Copy link

Thank you for your reply and clarification about your choice here, @jasperan . Your explanation about the uniqueness of the phone number and the name in the contacts list makes sense. Also, your point about searching for HTML elements in the chat interface is well taken. I appreciate your insights

@jasperan
Copy link
Owner

No worries @BurnsteinKarl happy to 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants