Dec-11-2019, 08:24 PM
(This post was last modified: Dec-11-2019, 08:24 PM by akanowhere.)
Thanks a lot for your help. As you recomend I removed the is_connected() function as bellow and didt´n work in
second phone number in the list again. The same error persists
second phone number in the list again. The same error persists
from time import sleep from selenium.webdriver.common.by import By from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as EC from selenium.common.exceptions import TimeoutException from selenium.webdriver.support.ui import WebDriverWait import socket #import csv message_text='Ola essa é uma mensagem automatizada de Whats App.' # message no_of_message = 1 # no. of time moblie_no_list = [5551981440050, 5551982073305] # list of phone number #moblie_no_list= open('entrada.csv', 'r') def element_presence(by,xpath,time): element_present = EC.presence_of_element_located((By.XPATH, xpath)) WebDriverWait(driver, time).until(element_present) driver = webdriver.Chrome(executable_path="D:\Programas\Aulas\scripts\Projetos\whatsautomatico\chromedriver.exe") driver.get("http://web.whatsapp.com") sleep(10) #wait time to scan the code in second def send_whatsapp_msg(phone_no,text): driver.get("https://web.whatsapp.com/send?phone={}&source=&data=#".format(phone_no)) # try: #driver.switch_to_alert().accept()#alterar a linha ou comenta# driver.switch_to_alert.accept() #driver.switch_to_alert().accept() # except Exception as e: # pass # try: element_presence(By.XPATH,'//*[@id="main"]/footer/div[1]/div[2]/div/div[2]',30) txt_box=driver.find_element(By.XPATH , '//*[@id="main"]/footer/div[1]/div[2]/div/div[2]') global no_of_message for x in range(no_of_message): txt_box.send_keys(text) txt_box.send_keys("\n") # except Exception as e: # print("invailid phone no :"+str(phone_no)) for moblie_no in moblie_no_list: # try: send_whatsapp_msg(moblie_no, message_text) # except Exception as e: # sleep(10)
Output:DevTools listening on ws://127.0.0.1:61710/devtools/browser/85cbcdcd-b841-4966-b32a-e55094b3f384
Error:Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
== RESTART: D:\Programas\Aulas\scripts\Projetos\whatsautomatico\Aut0001.py ==
[error]== RESTART: D:\Programas\Aulas\scripts\Projetos\whatsautomatico\Aut0001.py ==
invailid phone no :5551982073305
>>>