0

I am creating a virtual assistant, which I want to be able to use by sending a message to a WhatsApp chat, in which the assistant can read the message, perform its functions and send the response, for this I wanted to use the selenium library. My problem comes from the fact that I don't understand how I can select the appropriate chat to send. Reviewing the WhatsApp web code, I saw that the chats are divided into span tags which have the text that identifies each of the chats. How could I select the chat I want and send the message itself? `

from selenium import webdriver
import time
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By




driver_path = '/home/santiago/asistente/chromedriver/'
service = Service(executable_path=driver_path)
driver = webdriver.Chrome(service=service)

def chose_chat() :
    elements = driver.find_element(By.TAG_NAME, 'span')
  ?????
    elements.click()
    print ("Im here")
    
    return False


def botwhatsapp():
    driver.get('https://web.whatsapp.com/')`
    input('Press enter when you are ready: ')
    chose_chat()

botwhatsapp()`

I have tried to use other libraries or previous versions but I can't find anything current and whatsapp web changes its structure or label

0 Answers0