I am trying to log into my Instagram account using Selenium. For that, I need to fill in my username and password into the login form.
The username input bar has the tag input
and the name
equal to username
. Is there a way to retrieve this input bar using only the name
attribute and the tag name? I know I can use the XPath and the class name, but I want to do this using the name
attribute only.
I tried the code below but got an error.
Code:
username = driver.find_element(by = By.CSS_SELECTOR, value = "input[name = 'username']")
print(username.get_attribute("class"))
Output:
File "d:\Personal\CS\Bots\Instabot\msg.py", line 17, in <module>
username = driver.find_element(by = By.CSS_SELECTOR, value = "input[name = 'username']")
Edit:
I tried the class name and the XPath too but they don't work either
XPath:
username = driver.find_element(by = By.XPATH, value = '//*[@id="loginForm"]/div/div[1]/div/label/input')
print(username.get_attribute("class"))
Class:
username = driver.find_element(by = By.CSS_SELECTOR, value = 'input._2hvTZ pexuQ zyHYP')
print(username.get_attribute("class"))
What am I doing wrong here?