In this tutorial, I have used Python3 and Selenium. I am assuming that you know the basics of Python.
If you don't have Python installed, you can download it from https://www.python.org/ and follow the install instruction.
After Python installed, we will need to install Selenium Automation Framework. We will be using pip to install Selenium.
python3 -m pip install Selenium
Next, we will need to install ChromeDriver. You can download it from https://chromedriver.chromium.org/downloads. After downloading, unzip it and move it to some sensible location.
Automate WhatsApp
import os
from typing import KeysView
from selenium import webdriver
from selenium.webdriver.common import keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
os.environ['PATH'] += r"C:\Users\saura\Desktop" #replace it with path that contains chromedriver
driver = webdriver.Chrome()
driver.get("https://web.whatsapp.com/")
driver.implicitly_wait(5)
try:
destination = driver.find_element(By.XPATH, "//span[.='Friend']")#replace Friend with your WhatsApp contact
destination.click()
except:
destination = driver.find_element(By.XPATH, "//span[.='Friend']")#replace Friend with your whatsApp contact.
destination.click()
msg_area = driver.find_element(By.CSS_SELECTOR, "[title*='Type a message']")
for i in range(20): #Number of time message will be sent.
msg_area.send_keys("Hi") #Replace "Hi" with whatever message you want to send.
msg_area.send_keys(Keys.RETURN)
Copy the code and paste it in your Python file with (.py) extension. Replace drivers path and WhatsApp contact in code. And then run it. It will show a WhatsApp web interface. Scan the QR code. And you are done.
Now you can change the code, according to your various requirements.
Top comments (4)
12000+Whatsapp group links 2024 | Join, share, submit
Finding WhatsApp group links are now easy, You can find different group links here like school, travel, job and entertainment group links, etc.
click hera
shorturl.at/gel1L
This is a great tutorial for automating WhatsApp using Python and Selenium! It’s impressive how you can send messages programmatically, and the step-by-step instructions make it easy to follow. Just a reminder to use this responsibly and avoid spamming your contacts on WhatsApp. Automating tasks can save time, but it's essential to respect others' privacy. Thanks for sharing this code; I’m looking forward to customizing it for my needs!
WTPGold improves your messaging fm whatsapp v10.24 experience with a range of tweaks and additions, adding new features that surpass the app's default functionalities.
Great post, learned a lot about FM Whatsapp integration.
Some comments may only be visible to logged-in visitors. Sign in to view all comments.