mardi 16 février 2021

WhatsApp Web automation for random messages with Selenium

I'm creating a bot to send random messages from WhatsApp Web.

msg_1 = ["Hey, ", "Hello, "]
print(random.choice(msg_1))

The code above works fine, but when I use It with send_keys In Selenium the result is just the comma and the space.

msg_1 = ["Hey, ", "Hello, "]   

campo_msg = self.driver.find_element_by_xpath('...')
campo_msg.click()      # Tried with a click to see If It solves the problem
campo_msg.send_keys(random.choice(msg_1))

The result Is always ", " in campo_msg... If I send just a string with send_keys It works fine, so what am I doing wrong?




Aucun commentaire:

Enregistrer un commentaire