How to locate the username and password field within Instagram login page using Chromedriver and Selenium Python

て烟熏妆下的殇ゞ 提交于 2020-06-23 10:59:28

问题


Here's inspected source code

input aria-label="Phone number, username, or email" aria-required="true" autocapitalize="off" autocorrect="off" maxlength="75" name="username" type="text" class="_2hvTZ pexuQ zyHYP" value=""

I have tried this code run

driver = webdriver.Chrome()
driver.get('https://www.instagram.com/')
driver.find_element_by_xpath("//input[@name=\"username\"]").send_keys(username)
driver.find_element_by_xpath("//input[@name=\"password\"]").send_keys(pw)
driver.find_element_by_xpath('//button[@type="submit"]').click()

But having error like this

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@name="username"]"}
  (Session info: chrome=83.0.4103.61)

My chromedriver and chrome version are match, and finding elements by following instruction. Why am I getting this error?

来源:https://stackoverflow.com/questions/62018006/how-to-locate-the-username-and-password-field-within-instagram-login-page-using

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!