Enviado em 26/03/2020 - 21:57h
Boa noite coelgas,selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[contains(@class, '2S1VP')]"}
self.caixa_de_pesquisa = self.driver.find_element_by_xpath("//div[contains(@class, '2S1VP')]")
import os
import time
import re
import requests
import json
from chatterbot.trainers import ListTrainer
from chatterbot import ChatBot
from selenium import webdriver
class wppbot:
dir_path = os.getcwd()
def __init__(self, nome_bot):
print(self.dir_path)
self.bot = ChatBot(nome_bot)
#self.bot.set_trainer(ListTrainer)
self.trainer = ListTrainer(self.bot)
#self.trainer.train(self.conversas)
self.chrome = self.dir_path+'/chromedriver'
self.options = webdriver.ChromeOptions()
self.options.add_argument(r"user-data-dir="+self.dir_path+"/profile/wpp")
self.options.add_argument('--headless')
self.options.add_argument('--no-sandbox')
self.options.add_argument('--disable-dev-shm-usage')
self.driver = webdriver.Chrome(self.chrome, chrome_options=self.options)
def inicia(self,nome_contato):
self.driver.get('https://web.whatsapp.com/')
self.driver.implicitly_wait(20)
self.caixa_de_pesquisa = self.driver.find_element_by_xpath("//div[contains(@class, '2S1VP')]")
self.caixa_de_pesquisa.send_keys(nome_contato)
time.sleep(2)
print(nome_contato)
self.contato = self.driver.find_element_by_xpath('//span[@title = "{}"]'.format(nome_contato))
self.contato.click()
time.sleep(2)
Atualizando o Passado: Linux no Lenovo G460 em 2025
aaPanel - Um Painel de Hospedagem Gratuito e Poderoso
O macete do Warsaw no Linux Mint e cia
Visualizar arquivos em formato markdown (ex.: README.md) pelo terminal
Dando - teoricamente - um gás no Gnome-Shell do Arch Linux
Como instalar o Google Cloud CLI no Ubuntu/Debian
Mantenha seu Sistema Leve e Rápido com a Limpeza do APT!
Procurando vídeos de YouTube pelo terminal e assistindo via mpv (2025)
Instalação de Ubuntu em SSD (interno) como se fosse um dispositivo ext... (1)
Mikrotik não abre o webmail-segur... da Locaweb (10)