I was trying the following code for an automated status update on Facebook with selenium.
I copied it from some website to learn about selenium. Here the web driver could not find the class or the id of the box in which we write status.
I even searched for it with the inspect panel, but I didn't get any proper id or class and the above error prompted. Please help me!
How can I find the XPath or id the status update box?
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
import time
### login details ########################
username = "xxxxxxx@xxxxx.xxx"
pwd = "xxxxxxxxx"
##########################################
### what is on my mind ###################
msg = "hey there!"
##########################################
# initializing driver and loading web
chrome_path = r"chromedriver.exe"
options = Options()
options.add_argument("--disable-notifications")
driver = webdriver.Chrome(chrome_path, chrome_options=options)
driver.get("http://www.facebook.com/")
# end initializing
# start login
user_input = driver.find_element_by_xpath("""//*[@id="email"]""")
pwd_input = driver.find_element_by_xpath("""//*[@id="pass"]""")
user_input.send_keys(username)
pwd_input.send_keys(pwd)
pwd_input.send_keys(Keys.ENTER)
# end login
# writing msg
time.sleep(3)
first_what_is_on_my_mind_element = driver.find_element_by_class_name("_5qtp")
first_what_is_on_my_mind_element.click()
time.sleep(3)
second_what_is_on_my_mind_element = driver.switch_to.active_element
second_what_is_on_my_mind_element.send_keys(msg)
# end writing
# posting
buttons = driver.find_elements_by_tag_name('button')
for button in buttons:
if 'Post' in button.text:
button.click()
# end posting

