jasperan / whatsapp-osint

WhatsApp spy - logs online/offline events from ANYONE in the world
MIT License
863 stars 111 forks source link

script is stuck on loading... #32

Closed Alexvbp closed 9 months ago

Alexvbp commented 9 months ago

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.

github-actions[bot] commented 9 months ago

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

Alexvbp commented 9 months ago

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

jasperan commented 9 months ago

Hello @Alexvbp , I have just tested with your Chromedriver version: image

It seems to be working fine. Please, paste here what you see on the terminal. Do you arrive to my step on the picture?

Alexvbp commented 9 months ago

Hi @jasperan, hereby a screenshot of my output: Unsaved Image 1

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.

jasperan commented 9 months ago

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

Alexvbp commented 9 months ago

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.

Alexvbp commented 9 months ago

when i search for wa-web-loading-screen in all files at sources i don't seem to find it either.

jasperan commented 9 months ago

Here: NVJWMIp

Alexvbp commented 9 months ago

That's odd, when i first go to web.whatsapp.com (before the QR screen) i get this: chrome_E4oKgcUKNe

I get the QR screen, scan my code and this is the very first thing i see: chrome_gtvPaR3EUo

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?

jasperan commented 9 months ago

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 👍🏻

Alexvbp commented 9 months ago

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.')
jasperan commented 9 months ago

Thanks for the contribution @Alexvbp !