Error Selenium python, cannot find element

Asked

Viewed 98 times

0

I am trying to use Selenium to make a python script to automate Twitter login. However, I am always getting this error: Unable to locate element. Any page element appears this error, I try to find by xpath.

My code:

from selenium import webdriver

driver = webdriver.Chrome()

driver.get('https://twitter.com')

user = driver.find_element_by_xpath('//*[@id="react-root"]/div/div/div/main/div/div/div/div[1]/div[1]/div/form/div/div[1]/div/label/div/div[2]/div/input')
user.send_keys(afonsobritto)

1 answer

0

Try to use only:

/html/body/div/div/div/div[2]/main/div/div/div[2]/form/div/div[1]/label/div/div[2]/div/input

Remember that the function send_keys() takes parameter of type str (String)

I recommend you see this video

Browser other questions tagged

You are not signed in. Login or sign up in order to post.