from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from urllib.parse import quote
import time
with open('msg2.txt','r') as file:
msg = file.read()
msg=quote(msg)
number = []
with open('numbers.txt','r') as file:
for num in file.readlines():
number.append(num.rstrip())
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
link = 'https://web.whatsapp.com/'
driver.get(link)
time.
for num in number:
link2 = f'https://web.whatsapp.com/send/?phone=91{num}&text;={msg}'
driver.get(link2)
print("link"+link2)
time.sleep(15)
action =
time.sleep(100)
attachment_btn = driver.find_element(By.XPATH,'//*[@id="main"]/footer/div[1]/div/span[2]/div/div[1]/div[2]/div/div')
attachment_btn.click()
time.sleep(20)
image_btn = driver.find_element(By.XPATH,'//*[@id="main"]/footer/div[1]/div/span[2]/div/div[1]/div[2]/div/span/div/ul/div/div[2]/li/div')
#image_btn = driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div[5]/div/footer/div[1]/div/span[2]/div/div[1]/div[2]/div/span/div/ul/div/div[2]/li/div/span")
time.sleep(20)
image_btn.send_keys('E:\FITECH\Contacts\Whatsapp send automation\spring-boot-microservices-online-training.jpeg') # Replace with your image file path
action.send_keys(Keys.ENTER)
action.perform()
time.sleep(10)
time.sleep(2000)