如何用Python解决自动化WhatsApp中的一个问题

如何用Python解决自动化WhatsApp中的一个问题,python,list,authentication,Python,List,Authentication,当我尝试搜索联系人时,我的代码在列表中出现错误 from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager driver = webdriver.Chrome(ChromeDriverManager().install()) import time class WhatsappBot: def __init__(self): # Parte 1 - A

当我尝试搜索联系人时,我的代码在列表中出现错误

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())
import time

class WhatsappBot:
    def __init__(self):
        # Parte 1 - A mensagem que você quer enviar
        self.mensagem = "Testando"
        # Parte 2 - Nome dos grupos ou pessoas a quem você deseja enviar a mensagem
        self.grupos_ou_pessoas = ["Mae","Matheus", ]
        self.filepath = input("Enter your filepath (images/video): ")
        self.teste = "Mae"
       
                        
        options = webdriver.ChromeOptions()
        options.add_argument('lang=pt-br')
        self.driver = webdriver.Chrome(
            executable_path=r'./chromedriver.exe', chrome_options=options)
             

    def EnviarMensagens(self):
        self.driver.get("https://web.whatsapp.com")
        time.sleep(60)
        
        for grupo_ou_pessoa in self.grupos_ou_pessoas:
            procurar = self.driver.find_element_by_class_name("_3xpD_")
            procurar.click()
            procurar.send_keys(self.grupos_ou_pessoas)
            time.sleep(3)
            campo_grupo = self.driver.find_element_by_xpath(
                f"//span[@title='{grupo_ou_pessoa}']")
            time.sleep(2)
            campo_grupo.click()
            attachment_box = self.driver.find_element_by_xpath("//span[@data-icon = 'clip']")
            attachment_box.click()
            image_box = self.driver.find_element_by_xpath("//input[@accept='image/*,video/mp4,video/3gpp,video/quicktime']")
            image_box.send_keys(self.filepath)
            time.sleep(2)
            chat_box = self.driver.find_element_by_class_name("_3FRCZ")
            time.sleep(3)
            chat_box.click()
            chat_box.send_keys(self.mensagem)
            botao_enviar = self.driver.find_element_by_xpath(
                "//span[@data-icon='send']")
            time.sleep(3)
            botao_enviar.click()
            time.sleep(3)


bot = WhatsappBot()
bot.EnviarMensagens()


如何解决?

您遇到的错误是什么?请添加错误。引发异常\u类(消息、屏幕、堆栈跟踪)selenium.common.exceptions.ElementNotInteractiableException:message:element不可交互(会话信息:chrome=83.0.4103.116)您遇到的错误是什么?请添加错误。引发异常\u类(消息、屏幕、堆栈跟踪)selenium.common.exceptions.elementnotinteractitableexception:message:element不可交互(会话信息:chrome=83.0.4103.116)