Python Automation | Part 8 : WhatsApp Automation |Sending Attachments|Python Selenium Web Automation


    In this video, we are gonna be automating WhatsApp such that we can send bulk messages to groups along with attachments such as images/videos or in other words, a Python script that can send messages to bulk groups along with attachments such as images/videos. The input to the Python script is the group names, the message and the absolute path of the image/video we want to send as an attachment. In short, we will write a cool Python script to send bulk group messages with attachments. This is the second video of the whole 3 video WhatsApp Automation. In the next and last video, we will fix the QR Code issue, that is, we only need to scan the QR Code at the first time we run the Python script. We will leverage Python Selenium for this WhatsApp Bulk Group Message Sending with attachments Automation.

    First Part of WhatsApp Automation :

    Full Playlist : Python Web Automation | Python Selenium Tutorial | Python Automation Tutorial :

    Project Files – Github Repository :
    Don’t forget to give a ⭐️ to the repo.

    References :
    Selenium Docs :
    Selenium Waits Docs :
    List Comprehension in Python :

    Subscribe | Code Band

    Other videos in Code Band:
    Python Automation | Part 5 :Instagram Profile Fetch Automation|Python Web Automation|Python Selenium :
    Python Automation|Part 6 : Gmail Bulk Email Sending Automation|Python Web Automation|Python Selenium :
    Build a Weather App in Django | Scrape Weather Data from Google | Beautiful Soup | Python Requests :
    Python Interview Questions | Python Tricks | Python Tricky Programs | Python Tricks and Hacks :
    Python .env File | Django .env File Example | Python Decouple Django | Django Environment Variables :
    Django Autocomplete with jQuery UI | AJAX | Search | Filter from Database | Tutorial | Code Band :
    Django Dependent Drop Down List Example | Integration with Django Forms and Django Form Validations :
    Django Select2 Tutorial | Django Dropdown | Django ajax Dropdown | Django Search and Filter :
    Django Shell Plus | Advanced Django Shell | Django Shell Commands | Django Shell Tutorial :
    Django Seed Data into Database Models | Django Faker | Django loaddata | Django Dummy Data :
    3 Cool Django Features that Django Developers are Not Aware of :
    Django Custom User Model | Email as Username | Phone as Username | Authentication Example |Code Band :
    Playlist | Django Authentication | The easiest and actual way of doing it :
    Playlist | Django Relationships | Explained with Example by Code Band :
    Custom Model Manager & Model QuerySet in Django :
    Render Django Form Manually : Make Custom Form with Form Validations –
    Generic Class Based Views in Django | Introduction & Create View in Django | Learn by Example | CRUD :
    How to Deploy Django Project on Heroku for Free :
    Connect Django with MySQL :
    Instagram Automation using Python :
    Top 5 Programming Languages to Learn in 2020 :

    🙂 You Can Find Me On:
    My Website –
    Linkedin –
    Github –
    Facebook –
    Twitter –
    Instagram –


    Previous articleComo criar AMI de ec2 instânce na AWS ? BOTO3 + Python + Lambda
    Next articleПоднимаем Hadoop кластер локально | Скринкасты | Ok #1


    1. Subscribed!! This worked for me off the bat for sending image. I was confused about how you got the Xpath values because I tried to get the absolute and full xpaths with Inspect, but that did not work. This is important to know because whatsapp dev team will keep changing the UI all the time.

    2. Kaustubh Shah

      1 second ago

      Hello I am getting an error for send button x_path , program runs well till selecting image but it can send :

      NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//span[@data-icon="send"]"}

      (Session info: chrome=87.0.4280.141)

      When I tried with div roll = "button" it shows error not operable element

    3. Hey bro, my bot is stoping after sending the message this is my script:

      from selenium import webdriver

      from import By

      from import WebDriverWait

      from import expected_conditions as EC

      from selenium.webdriver.common.keys import Keys

      import pyperclip

      import time

      import sys



      if sys.argv[1]:

      with open('groups.txt', 'r', encoding='utf8') as f:

      groups = [group.strip() for group in f.readlines()]

      except IndexError:

      print('Please provide the group name as the first argument.')

      with open('msg.txt', 'r', encoding='utf8') as f:

      msg =

      browser = webdriver.Chrome('C:/Users/guipo/Desktop/chromedriver_win32/chromedriver.exe')




      for group in groups:

      search_xpath = '//div[@contenteditable="true"][@data-tab="3"]'

      search_box = WebDriverWait(browser, 500).until(

      EC.presence_of_element_located((By.XPATH, search_xpath))





      search_box.send_keys(Keys.CONTROL + "v")


      group_xpath = f'//span[@title="{group}"]'

      group_title = browser.find_element_by_xpath(group_xpath)


      input_xpath = '//div[@contenteditable="true"][@data-tab="6"]'

      input_box = browser.find_element_by_xpath(input_xpath)


      input_box.send_keys(Keys.CONTROL + "v")




      if sys.argv[2]:

      attachment_box = browser.find_element_by_xpath('//div[@title="Anexar"]')


      image_box = browser.find_element_by_xpath('//input[@accept="image/*,video/mp4,video/3gpp,video/quicktime"]')



      except IndexError: