Closed Alexvbp closed 9 months ago
Thank you for your first issue to whatsapp-osint! I really appreciate your interest and hope you enjoy the repository.
Having the same issue on Version 114.0.5735.90 (Official Build) (64-bit) I tried it in case the Chrome for testing was causing issues somehow
Hello @Alexvbp , I have just tested with your Chromedriver version:
It seems to be working fine. Please, paste here what you see on the terminal. Do you arrive to my step on the picture?
Hi @jasperan, hereby a screenshot of my output:
I've also tried to use my phone as a hotspot, in case it was my internet, but that didn't seem to resolve the issue either.
Hi @Alexvbp , the script is failing to find the following XPATH: //div[@data-testid="wa-web-loading-screen"]
Can you try to find the location of this HTML div when you create a new incognito session and login to whatsapp? It is present during loading, and for some reason your client is not finding it, so it's stuck on loading as it can't find the login screen.
You can test this with Chrome Developer tools for example, by inspecting the HTML
Hi @jasperan,
Should this XPATH be present at the screen of the QR code, the loading when i login or when i am already logged in? I am unable to find it when i open devtools and ctrl+f for "loading" in elements, at the QR screen and when i am logged in.
when i search for wa-web-loading-screen in all files at sources i don't seem to find it either.
Here:
That's odd, when i first go to web.whatsapp.com (before the QR screen) i get this:
I get the QR screen, scan my code and this is the very first thing i see:
after this my chats appear. my whatsapp isn't set up in any special way, not in any beta, i am using two step verification though but i dont think this should interfere?
When in the QR code screen, you should see a new message in the chat logs that isn't appearing, it looks like the HTML div in your previous screen is different to what the Python script has.
I recommend getting the loading screen HTML tag and updating it in the Python script, that way it will work for your specific case 👍🏻
Hiya, not the most elegant fix, but in case anyone has the same problem.
def whatsapp_load(driver) -> None:
"""
Wait for the WhatsApp Web loading screen to disappear based on the disappearance of the resume-logo element.
Args:
- driver: Selenium WebDriver instance.
Returns:
None
"""
try:
# Wait for the resume-logo to disappear, indicating loading is complete
WebDriverWait(driver, 30).until_not(
EC.presence_of_element_located((By.CSS_SELECTOR, "path.resume-logo"))
)
print("Loading complete.")
except TimeoutException:
print("Loading took too much time!")
I also added a find contact function because whatsapp doesnt always show the username instantly, sometimes it shows the phone numbers at first, causing it to close prematurely. if the user isnt loaded in the gui, you have to scroll down for them to load.
def find_contact(driver, user, timeout=30):
"""
Wait for a specific contact to appear in WhatsApp Web.
...
"""
end_time = time.time() + timeout
while time.time() < end_time:
try:
span = f"span[title='{user}']"
element = driver.find_element(By.CSS_SELECTOR, span)
return element
except NoSuchElementException:
time.sleep(1) # Wait for 1 second before trying again
return None
i've also changed the remove_idle function since it couldnt find @data-testid="smiley"
all in all, not very elegant but it works for me now.
def remove_idle(driver):
while True:
time.sleep(10)
try:
# Updated selector to target the smiley button
smiley_button = driver.find_element(By.CSS_SELECTOR, 'button[aria-label="Open emojis panel"]')
smiley_button.click()
except NoSuchElementException:
print('Smiley button not found.')
Thanks for the contribution @Alexvbp !
Hi,
I've tested this on windows and linux, whenever i launch the script it opens up chrome, i have scanned my QR it is stuck on "loading...". On linux i am using python 3.10 and Chrome for testing v119.0.6045.105 with matching chromedriver.