from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.keys import Keys
from time import
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
with open('msg2.
msg = file.
msg=quote(msg)
msg = quote(msg)
number = []
with open('numbers.
for num in file.readlines():
number.append(num.rstrip())
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
link = 'https://web.whatsapp.com/'
driver.get(link)
WebDriverWait(driver, 40).until(EC.presence_of_element_located((By.XPATH, '//*[@id="app"]/div/div[2]/div[3]/header')))
for num in number:
link2 = f'https://web.whatsapp.com/send/?phone=91{num}&text;={msg}'
driver.
time.sleep(15)
action
Pathurl =
action.send_keys(Keys.ENTER)
action.perform()
time.sleep(10)
time.sleep(2000)
if Pathurl=='//*[@id="app"]/div/span[2]/div/span/div/div/div/div/div/div[1]':
driver.find_element(By.XPATH,'//*[@id="app"]/div/span[2]/div/span/div/div/div/div/div/div[2]/div/button/div/div').click()
continue
#Message #/html/body/div[1]/div/span[2]/div/span/div/div/div/div/div/div[1]
#Ok #/html/body/div[1]/div/span[2]/div/span/div/div/div/div/div/div[2]/div/button/div/div
# driver.find_element(By.XPATH,'//*[@id="app"]/div/span[2]/div/span/div/div/div/div/div/div[2]/div/button/div/div').click()
#//*[@id="app"]/div/span[2]/div/span/div/div/div/div/div/div[1]
#//*[@id="app"]/div/span[2]/div/span/div/div/div/div/div/div[2]/div/button/div/div
WebDriverWait(driver, 150).until(EC.presence_of_element_located((By.XPATH, '//div[@title="Attach"]')))
sleep(2)
driver.find_element(By.XPATH,'//div[@title="Attach"]').click()
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, '//span[contains(text(),"Photos & Videos")]/../input')))
image_btn = driver.find_element(By.XPATH,'//span[contains(text(),"Photos & Videos")]/../input')
image_btn.send_keys('E:FITECHContactsWhatsapp send automationJava banner.png')
WebDriverWait(driver, 2).until(EC.presence_of_element_located((By.XPATH, '//span[@data-icon="send"]')))
sleep(2)
driver.find_element(By.XPATH,'//span[@data-icon="send"]/..').click()
sleep(5)
print("Done")