mukulhase / WebWhatsapp-Wrapper

An API for sending and receiving messages over web.whatsapp [Working as of 18th May 2018]
https://webwhatsapi.readthedocs.io/en/latest/
MIT License
2.02k stars 797 forks source link

Cant Login Using Headless for selenium #912

Closed IlhamriSKY closed 3 years ago

IlhamriSKY commented 4 years ago

I try login using headless, and scan image qr from driver.get_qrcode(), but bot immediately close.

this is my code

import time
from webwhatsapi import WhatsAPIDriver
from webwhatsapi.objects.message import Message

driver = WhatsAPIDriver(username="test1",  headless=True)
print("Waiting for QR")
driver.get_qr(filename="ilham1.png")

driver.wait_for_login()
print("Bot started")

while True:
    time.sleep(3)
    print("Checking for more messages")
    for contact in driver.get_unread():
        for message in contact.messages:
            if isinstance(message, Message):  # Currently works for text messages only.
                contact.chat.send_message(message.content)

i am already using lates version, try both version using pip and setup.py

marcelocecin commented 4 years ago

please share the error

IlhamriSKY commented 4 years ago

please share the error

Traceback (most recent call last):
  File "E:\Project WaBot\Test\testilham\test1.py", line 9, in <module>
    driver.wait_for_login()
  File "C:\Python38\lib\site-packages\webwhatsapi-2.0.3-py3.8.egg\webwhatsapi\__init__.py", line 317, in wait_for_login
    WebDriverWait(self.driver, timeout).until(
  File "C:\Python38\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 
marcelocecin commented 4 years ago

which versions of selenium and browser?

treborxrs commented 4 years ago

I have the same problem, I was wondering if the version of selenium, firefox, six and python-dateutil interfere in the execution of the api ??

marcelocecin commented 4 years ago

yes, it influences, and there are already several closed issues that explain about it

treborxrs commented 4 years ago

could you let me know these issues? my application:

six: 1.12.0 selenium: 3.141.0 python-dateutil: 2.8.1 firefox: 3.14.0 webwhatsapi: 2.0.5

marcelocecin commented 4 years ago

which operating system and version? which version of python?

treborxrs commented 4 years ago

and linux(debian) python 3.7.3

treborxrs commented 4 years ago

I made the necessary corrections in the selector, but still does not get the qrcode!!

IlhamriSKY commented 4 years ago

which operating system and version? which version of python?

windows 10 x64 i am using python 3.8.3 lates version selenium ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103@{#416}) geckodriver 0.26.0 (e9783a644016 2019-10-10 13:38 +0000)

marcelocecin commented 4 years ago

did you install this repository From Source ?

IlhamriSKY commented 4 years ago

did you install this repository From Source ?

yap i try both version using pip and setup.py

treborxrs commented 4 years ago

can someone tell me what's wrong with the selector ??

_SELECTORS = { "firstrun": "#wrapper", "qrCode": "canvas[aria-label='Scan me!']", "qrCodePlain": "div[data-ref]", "mainPage": ".two", "chatList": ".infinite-list-viewport", "messageList": "#main > div > div:nth-child(1) > div > div.message-list", "unreadMessageBar": "#main > div > div:nth-child(1) > div > div.message-list > div.msg-unread", "searchBar": ".input", "searchCancel": ".icon-search-morph", "chats": ".infinite-list-item", "chatBar": "div.input", "sendButton": "button.icon:nth-child(3)", "LoadHistory": ".btn-more", "UnreadBadge": ".icon-meta", "UnreadChatBanner": ".message-list", "ReconnectLink": ".action", "WhatsappQrIcon": "span.icon:nth-child(2)", "QRReloader": "div[data-ref] > span > div", "OpenHereButton": "div[data-animate-modal-body=true] div[role=button]:nth-child(2)", }

marcelocecin commented 4 years ago

the ideal is to install from source and then manually apply all changes from pull request #888

treborxrs commented 4 years ago

I installed it directly from the source, and made the necessary corrections that I was asking to change, but the error persists !!

marcelocecin commented 4 years ago

may be something related to the operating system, I suggest trying on linux

treborxrs commented 4 years ago

the API is installed on linux !!

treborxrs commented 4 years ago

the API was working all right, but after whatsappWeb updated, until then the versions that were in the source are not working right, I had to install lower versions to work, now I redid everything straight from the source, and still have the same problem!

marcelocecin commented 4 years ago

I'm using firefox 61.0 geckodriver 0.26.0 CentOS Linux release 7.8.2003 Python 3.4.3

IlhamriSKY commented 4 years ago

can someone tell me what's wrong with the selector ??

_SELECTORS = { "firstrun": "#wrapper", "qrCode": "canvas[aria-label='Scan me!']", "qrCodePlain": "div[data-ref]", "mainPage": ".two", "chatList": ".infinite-list-viewport", "messageList": "#main > div > div:nth-child(1) > div > div.message-list", "unreadMessageBar": "#main > div > div:nth-child(1) > div > div.message-list > div.msg-unread", "searchBar": ".input", "searchCancel": ".icon-search-morph", "chats": ".infinite-list-item", "chatBar": "div.input", "sendButton": "button.icon:nth-child(3)", "LoadHistory": ".btn-more", "UnreadBadge": ".icon-meta", "UnreadChatBanner": ".message-list", "ReconnectLink": ".action", "WhatsappQrIcon": "span.icon:nth-child(2)", "QRReloader": "div[data-ref] > span > div", "OpenHereButton": "div[data-animate-modal-body=true] div[role=button]:nth-child(2)", }

try this

    _SELECTORS = {
        'qrCode': "canvas[aria-label=\"Scan me!\"]",
        'qrCodePlain': "div[data-ref]",
        'QRReloader': 'div[data-ref] > span > div',
        'mainPage': ".two",
    }
IlhamriSKY commented 4 years ago

I'm using firefox 61.0 geckodriver 0.26.0 CentOS Linux release 7.8.2003 Python 3.4.3

i cant run at centos7 are you use docker for that? because they told have some issue at centos

lucianomarav commented 4 years ago

I tried in many ways with debian with ubuntu with docker without docker in Winodws on linux, with several different commits and nothing to work. Who has the section saved and can test, disconnect and connect again please to do the test Thank you

marcelocecin commented 4 years ago

try to use https://www.oracle.com/virtualization/virtualbox/ for testing

lucianomarav commented 4 years ago

I use VMware here. I'm thinking that the problem may really be with SELECTORS, because I can't find the "mainPage: in html and I can't scan the QRcode, the time ends even if I start the web session

IlhamriSKY commented 4 years ago

I use VMware here. I'm thinking that the problem may really be with SELECTORS, because I can't find the "mainPage: in html and I can't scan the QRcode, the time ends even if I start the web session

try with this selector

    _SELECTORS = {
        'qrCode': "canvas[aria-label=\"Scan me!\"]",
        'qrCodePlain': "div[data-ref]",
        'QRReloader': 'div[data-ref] > span > div',
        'mainPage': ".two",
    }
IlhamriSKY commented 4 years ago

try to use https://www.oracle.com/virtualization/virtualbox/ for testing

i try running on my own server with centos 7

treborxrs commented 4 years ago

Eu uso o VMware aqui. Estou pensando que o problema pode estar realmente com os SELECTORS, porque não consigo encontrar a "mainPage: em html e não consigo escanear o QRcode, o tempo termina mesmo se eu iniciar a sessão da web

tente com esse seletor

    _SELECTORS = {
        'qrCode': "canvas[aria-label=\"Scan me!\"]",
        'qrCodePlain': "div[data-ref]",
        'QRReloader': 'div[data-ref] > span > div',
        'mainPage': ".two",
    }

does not work, still not getting the qr code!!

lucianomarav commented 4 years ago

@treborxrs vi q vc fala portugues entra la no discord da api pra trocarmos umas ideias se possivel !

discord(,)gg/n4nW8dZ qual quer coisa chama no zap tb 5537991210022

lucianomarav commented 4 years ago

solution to the problem is here with commit master it worked. the test with the remote.py example on ubuntu 20.4

https://github.com/Seezapp/WebWhatsAPI/commit/87980cd03c134b23d216abeab98d127317783fc3