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.04k stars 795 forks source link

window.WAPI doesn't exist #1183

Open andlb opened 1 year ago

andlb commented 1 year ago

Does anybody is having problem with new whatsapp version?

I got this error:

 42         :rtype: JsFunction
 43         """

---> 44 wapi_functions = dir(self) 45 46 if item not in wapi_functions:

TypeError: 'NoneType' object is not iterable

There isn't window.WAPI anymore.

iaron commented 1 year ago

In my case I just changed the querySelector, I did this in wapi_js_wrapper.py so the script can be injected:

From: result = self.driver.execute_script("if (document.querySelector('*[data-icon=chat]') !== null) { return true } else { return false }")

To: result = self.driver.execute_script("if (document.querySelector('*[data-icon=default-user]') !== null || document.querySelector('*[data-icon=chat]') !== null ) { return true } else { return false }")

andlb commented 1 year ago

Thanks very much. I helped me a lot. I didn't know where to look. The final solution for me was that one:

result = self.driver.execute_script("if (document.querySelector('[data-icon=default-user]') !== null || document.querySelector('[data-icon=new-chat]') !== null || document.querySelector('*[data-icon=chat]') !== null ) { return true } else { return false }")

I added a new clause to data-icon=new-chat.

You may have to do that in the future too.