open-wa / wa-automate-python

💬 🤖 The most advanced Python whatsapp library for chatbots with advanced features. Be sure to ⭐ this repository for updates!
Other
349 stars 75 forks source link

Remote Driver in WhatsAPIDriver object #52

Closed GauthamramRavichandran closed 4 years ago

GauthamramRavichandran commented 4 years ago

I'm using a remote driver in the WhatsAPIDriver object.

def connect_to_session(session_id, executor_url):
    # Connect to a remote session where whatsapp web is logged in
   return driver

wt_driver = WhatsAPIDriver(headless = True, autoconnect = False,
                               extra_params = {'log_path': f'./logs/open-wa-session-at-{int(time())}.log'})
wt_driver.driver = connect_to_session(session_id = session_id, executor_url = cmd_url)
    if not wt_driver.is_logged_in():
    raise Exception('Login details expired'')
    for chat in wt_driver.get_all_chats():
        # do something here

The logged in check was success. but get_all_chats() raises TypeError: 'NoneType' object is not iterable. This happens only when I try with remote driver. Is there anyway to connect to this remote driver? I have the session_id and command_executor_url

mrodal commented 4 years ago

I dont get it, in the sample code you are not using a remote driver. Did you take a look at this sample?

GauthamramRavichandran commented 4 years ago

yes, I am using a remote driver at connect_to_session. It accepts session_id and command_executor_url. Returning a new driver which proxies all the requests to that given session_id and cmd_url. (Sorry, if my explanation is vague, I'm still learning selenium)

Basically this method, mimics the creation of new session and use the old one itself. I understand now that I have to integrate this connect_to_session in the constructor of APIDriver. Thank you,