[Python] read messages with driver.find_element(By.XPATH

Discussão em 'Python' iniciado por Stack, Janeiro 31, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to read messages from a WhatsApp community and according to the content of that message it is resent to another number, I'm trying to get the content of the messages with xpath but it doesn't seem to find anything.

    mensagens = driver.find_elements(By.XPATH, "//div[contains(@class, 'message-in')]//span[@class='selectable-text']")

    for msg in mensagens:
    texto = msg.text
    print(f"Mensagem recebida: {texto}")
    registrar_log(f"Mensagem recebida: {texto}")


    I created a log to show the messages that are received but nothing appears. Why is that and how can I fix it?

    Continue reading...

Compartilhe esta Página