Kalebu / alright

Python wrapper for WhatsApp web-based on selenium
https://www.youtube.com/watch?v=yitQTt-NukM
MIT License
368 stars 110 forks source link

send_message1() is not working #75

Closed bekbolsky closed 2 years ago

bekbolsky commented 2 years ago

It looks like one of the xpath are broken. I don't know which one. Throws UnboundLocalVariable error on line 249 of __init.py__ file

euriconicacio commented 2 years ago

Hi, @bekbolsky. I see that we may be facing some backward compatibility on Selenium versions. I've set a quick general fix that may help you with text messages sending: the just_type_and_send_message method. Recommended usage:

            messenger = WhatsApp()
            messenger.find_by_username("John")
            messenger.just_type_and_send_message("Bla\nBla\nBla")
            messenger.browser.quit()

Please, let us know if that works as expected. Thanks a lot for reporting the issue!

bekbolsky commented 2 years ago

It works, but for saved contacts. Anyway send_message1() is more convenient.

euriconicacio commented 2 years ago

@bekbolsky could you please tell more about how it is more convenient?

And about stored contact, find_by_username works for phone numbers that exist on your list of messages on the left menu. Is it enough, or do you need to send a message to a totally new number?

bekbolsky commented 2 years ago

how it is more convenient?

It is convenient because you don't have to store the number in a phone contact.

do you need to send a message to a totally new number?

Yes, it would be better if it is possible to send a message to the new number.

euriconicacio commented 2 years ago

Hi, @bekbolsky.

It is convenient because you don't have to store the number in a phone contact.

If you reach out to our docs, you'll see you don't need to store the number in a phone contact in order to use find_by_username - the method naming is just for easiness of documentation (our README states that it can be used for "saved-name or number or group", check it out). You can perform a call of this method like this: messenger.find_by_username('+1 234 567-8900') - the correct spacing and dashing matters, though.

Little PoC:

image

Lmk if you have doubts on how to reproduce it.

Yes, it would be better if it is possible to send a message to the new number.

Have you already sent a message to that number before, so that it is stored on the left menu? If yes, this approach solves your issue.

Please, let us know if your issue persists even with these recommendations. We are looking forward to hearing from you.

nCKbr.

abdullahalshubaili commented 2 years ago

i was not able to send a message also but i have found a way to send messages.

change the value of inp_xpath line#421 in file __init__.py to '//*[@id="main"]/footer/div[1]/div/span[2]/div/div[2]/div[1]/div/div[1]'

it should work hopefully

bekbolsky commented 2 years ago

it should work hopefully

Yes, I changed the value on that line and now it works. As I said in the comment to the issue,

It looks like one of the xpath are broken.

the problem was in xpath. And you found that broken xpath. Good job @abdullahalshubaili :+1: