How I texted whole movie script word by word using Selenium in Python

๐๐๐๐๐๐ ๐ก๐๐๐๐
Search for a command to run...

๐๐๐๐๐๐ ๐ก๐๐๐๐
Haha that looks fun!!!! On my way to irritate my friends with this. Bye๐๐
lol
I'm a Graduate student at UT Arlington. I always feel that taking care of both physically and mentally are essential to our success. So, I start my daily routine at Fitness Recreation Center (gym) and registering slots daily is a hassle and due to co...

You might have seen some people using completely different source labels. Well, today we will see how to change the Twitter source label First, we need to have a Twitter developer account, if you don't have. 1) Just navigate to Twitter Developer web...

We all know, Artificial Intelligence (AI) is one of the most transformative tech evolutions of our times. Well, if you still not aware of what AI is? It is the simulation of human intelligence in machines that are programmed to think like humans and ...

I'm a Indian and I recently moved to the USA to pursue my Master's degree at UT Arlington. So I need to carry some essential documents digitally like passport, health reports and other Government id's to be on the safer side and I don't want others t...

In Machine Learning classification problems, there are often too many factors on the basis of which the final classification is done. These factors are basically variables called features. The higher the number of features, the harder it gets to visu...

In this post, I will share how I texted a whole movie script word by word in Python.
Let's start by watching small demo, how its going to look at end ๐
Now lets talk, Prerequisites:
Step 1 : need to import webdriver, keys and sleep
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
Step 2 : Enter the location of Chrome Webdriver and assign it to driver variable
driver=webdriver.Chrome("") # Enter Location of Chrome driver
Step 3 : I used whatsapp to send messages and I pinned the person to whom we need to send messages, so that there will not be any hustles.
driver.get("https://web.whatsapp.com/")
sleep(15)
driver.find_element_by_xpath("/html/body/div/div/div/div/div/div/div[1]/div/div/div[1]/div/div/div").click()
sleep(5)
There should be some time where we can scan the QRcode to login, so I gave sleep(15) and that XPath is to open the chat window of that respective person
Step 4 : Now locate the movie script file, assign it to fileLocation variable and open it in reading mode
fileLocation= "" # Enter location of movie script file
Step 5 : Now use "for loop" to send msg word by word
Xpath for entering a message
driver.find_element_by_xpath("//*/footer/div[1]/div[2]/div/div[2]").send_keys(word)
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
driver=webdriver.Chrome("") # Enter Location of Chrome driver
driver.maximize_window()
driver.get("https://web.whatsapp.com/")
sleep(15)
driver.find_element_by_xpath("/html/body/div/div/div/div/div/div/div[1]/div/div/div[1]/div/div/div").click()
sleep(5)
fileLocation= "" # Enter location of movie script file
with open(fileLocation,"r") as file:
for line in file:
for word in line.split(" "):
driver.find_element_by_xpath("//*/footer/div[1]/div[2]/div/div[2]").send_keys(word)
driver.find_element_by_xpath("//*/footer/div[1]/div[2]/div/div[2]").send_keys(Keys.ENTER)
Hope it's useful
If you like my content, please consider supporting me