Irritate your friends using WhatsApp automation using python selenium for free

WhatsApp is one of those apps which is a part of our lifestyle. Just imagine you are sending 100’s of messages continuously to your friend in a matter of seconds and he is forced to mute your chat. And if he has a low-end mobile then he is doomed. So let’s find out how to achieve this.


  • This article is just for education’s purpose.
  • WhatsApp may temporarily block your account if you keep repeating this.
  • This is not completely automated since you need to scan the QR code from your mobile to access from WhatsApp web.

With that said, let’s see what the requirements are.

  • Python
  • Selenium package
  • google chrome driver

Other requirements

  • WhatsApp account (obviously)
  • A scapegoat (your friend in whatsapp)

Install python

If you have not installed python on your machine download it from the official website here.

Once you have installed python, open your command prompt (click windows button => search cmd => enter). Type “python –version”. If you receive the python version then it’s installed successfully.

Selenium package

Now you have installed python. The next step is to install the selenium package. In the command prompt type, “pip install selenium”. Selenium package will be installed successfully.

google chrome driver

Google chrome driver is the main step in this process as our automation happens on google chrome. Download the google chrome driver zip file by clicking here. Unzip the file and copy the chromedriver.exe file.


from selenium import webdriver
from selenium.webdriver.common.keys import Keys

path = 'C:\chromedriver.exe' # whichever directory your chromedriver.exe is saved

driver = webdriver.Chrome(path)
driver.get('') # whatsapp web url

name = input('Enter the exact name of user or group: ') 
msg = input('Enter your message : ')
count = int(input("Enter the count: "))

input("Enter anything after scanning QR code")

user = driver.find_element_by_css_selector('span[title = "{}"]'.format(name))

msg_box = driver.find_element_by_xpath("/html/body/div/div[1]/div[1]/div[4]/div[1]/footer/div[1]/div[2]/div/div[2]") #to get element path in developer tools, select element=> right click => copy with path.

for i in range(count):

Create a python file, in my case I named it as “whatsapp”. Paste the following code.

In the above code in order to get the path to the message box do the following.

Open the developer tools by clicking the three dots, more tools and the Developer tools.

Click on the select button that is highlighted on the below diagram and click the text box where you will type the message. The appropriate HTML tag will be highlighted. Right-click, select Copy and then Copy full XPath.

Paste that path in the code

msg_box = driver.find_element_by_xpath(“paste it here”)

Get the GitHub link of above code by clicking here.


  • Open the command prompt on the directory where you have saved the python file. Type “python whatsapp” (enter your
  • Google Chrome will open the WhatsApp web page. Scan the QR code using your WhatsApp app.
  • Then enter the exact name of the person or group you would like to message.
  • Enter your message.
  • Enter how many times that message must be repeated.
  • Finally, click enter confirming that you have scanned the QR code.


Irritating our friends is fun every time. Isn’t it? Make use of the above code and try to improve the fun by adding any if-else condition to send different messages depending on time. But don’t forget continuous use of this trick would result in your account block. Keep that in mind and play responsibly. Happy Coding!!

Leave a Comment