If you want to send Whatsapp messages to multiple users at a time, using browser automation with Python Selenium and Web Driver, you are at the right place. This script works after Whatsapp’s most recent updates. So let’s get started with the code.

Open the github repository. Download or clone these three files in the same folder. You can name this folder whatever you want. The rest of the file names should not be changed.
Points to note before you run the script:
1- You must be using python3 to run the code.
2- Your Google Chrome and Chrome Driver versions must be the same. I have Google Chrome of Version 73.0.3683.103 (Official Build) (64-bit) so I downloaded Chrome Driver accordingly.

3- You can download another version of chrome driver from the link – http://chromedriver.chromium.org/downloads please keep reading for more details on this.
4- I built this code to have selenium leverage the Google Chrome driver, specifically.
5- You must have downloaded Selenium as well. You can use the command – pip3 install selenium
to download selenium
6- You must have downloaded the web driver manager. You can use the command – pip3 install webdriver-manager
to download this.
7- As we are using an Excel file here (named tt.xlxs), you must download openpyxl . Use command – pip3 install openpyxl to download this.
8- In the tt.xlsx file, you have to mention the names that are saved in your contact list in the proper format.
And now you are good to go.
How to execute –
The file named tt.xlsx is an excel file where you have to edit the name of your contacts. After saving these contacts, execute whatsapp_sendmessage.py using python3. To execute, run command python3 whatsapp_sendmessage.py and hit enter.

A terminal will open which will ask you to enter the message that you want to send. After that, you will be asked to scan the QR code (to login on Whatsapp Web). Scan the QR code and watch Whatsapp web.

You can see that the message is sent automatically to your contacts with a delay of 5 seconds and after the task is completed, the tab is closed automatically.
I hope this post helped you. If you are still facing any issues you can comment on the post. I will be more than happy to help you. To read more such posts on Automation, here is another post I wrote recently.
Hi Vivek dwivedi I didn;t understand the part where you use find_element_by_classname can you help me with it that how you find the class name
You have to inspect the webpage for that. Sorry for a bit late reply.
Hi sir,
This is Sanjeev Kumar. I have installed properly everything but when i executing my whatsapp_sendmessage.py it shows the error: Bus Error
Thank you.
Hi Sanjeev, Glad you liked it and everything worked for installation properly. Now can you please share me the screen shot so that i can help you further.
Hi,
Installations worked fine but getting this error
File “C:\Users\Aditya Choudhary\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py”, line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {“method”:”css selector”,”selector”:”._13mgZ”}
Would really appreciate help in this regards.
Thanks!
Aditya Choudhary
Hey Thanks!! But keep getting this error, right after log into WPP and entering the message in the terminal:
Traceback (most recent call last):
File “whatsapp_sendmessage.py”, line 46, in
message = driver.find_element_by_class_name(‘_13mgZ’)
File “/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py”, line 564, in find_element_by_class_name
return self.find_element(by=By.CLASS_NAME, value=name)
File “/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py”, line 978, in find_element
‘value’: value})[‘value’]
File “/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py”, line 321, in execute
self.error_handler.check_response(response)
File “/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py”, line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {“method”:”css selector”,”selector”:”._13mgZ”}
(Session info: chrome=81.0.4044.138)
Do you know what it could be? Thanks!
nothing is happening after entering message in Terminal
Hello sir, when I run that code whatsapp_sendmesaage.py it’s shows some error in line 18,73,76,990-os error .
Can u help me to resolve it
Hello i have trying to make whatsapp number filtering system, i have done, but my system filter was check one by one number, it means its filter only one number at a time, but i want to make which filters atleast 100 number at a time please help me.
Each and every time WhatsApp web is closing and again it’s opening . how to make open for all time. to send continues WhatsApp to unknow numbers.
I am getting following Error
Enter the message : [2804:4392:0807/160802.744:ERROR:device_event_log_impl.cc(214)] [16:08:02.744] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[2804:4392:0807/160802.750:ERROR:device_event_log_impl.cc(214)] [16:08:02.749] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[7768:10544:0807/160949.185:ERROR:gpu_init.cc(441)] Passthrough is not supported, GL is disabled
Can you please help me on bellow error
>>> driver = webdriver.Chrome(‘C:\Users\Madhavi\Desktop\whatsapp_py\chromedriver’)
File “”, line 1
driver = webdriver.Chrome(‘C:\Users\Madhavi\Desktop\whatsapp_py\chromedriver’)
^
SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape
Hi there
I recently made a python library that abstracts selenium and provides an easy and intuitive interface plus advanced control over the WhatsApp Web, you really wanna have a look at it, I’m pretty sure you will love it
Here is a link https://github.com/Kalebu/alright
Here how to send a message to the user
“`python
>>> from alright import WhatsApp
>>> messenger = WhatsApp()
>>> messenger.find_user(‘2557xxxxxz’)
>>> messages = [‘Morning my love’, ‘I wish you a good night!’]
>>> for message in messages:
messenger.send_message(message)
“`
Thank you
Kalebu