简体   繁体   English

“错误:selenium.common.exceptions.NoSuchElementException:消息

[英]"Error: selenium.common.exceptions.NoSuchElementException: Message

I'm encountering an error NoSuchElementException .我遇到错误NoSuchElementException

Here is my code:这是我的代码:

from time import sleep
from selenium import webdriver


browser = webdriver.Firefox()
browser.implicitly_wait(5)

browser.get('https://www.instagram.com/')

login_link = browser.find_element_by_xpath("//a[text()='log In']")
login_link.click()

sleep(2)

username_input = browser.find_element_by_css_selector("input[name='username']")
password_input = browser.find_element_by_css_selector("input[name='password']")

username_input.send_keys("<your username>")
password_input.send_keys("<your password>")

login_button = browser.find_element_by_xpath("//button[@type='submit']")
login_button.click()

sleep(5)

browser.close()

Just tested this and it seems that this step刚刚测试了这个,似乎这一步

login_link = browser.find_element_by_xpath("//a[text()='log In']")
login_link.click()

sleep(2)

is unnecessary.是不必要的。 Going to https://www.instagram.com/ sends you straight to the login page on a fresh browser instance.转到https://www.instagram.com/会将您直接带到新浏览器实例上的登录页面。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 selenium.common.exceptions.NoSuchElementException:消息: - selenium.common.exceptions.NoSuchElementException: Message: selenium.common.exceptions.NoSuchElementException - selenium.common.exceptions.NoSuchElementException selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:无法定位元素 - selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:无法定位元素: - selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: selenium.common.exceptions.NoSuchElementException:消息:在使用 Selenium 调用 Instagram 中的关注者链接时,没有此类元素错误 - selenium.common.exceptions.NoSuchElementException: Message: no such element error invoking click on followers link within Instagram with Selenium selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:无法找到元素: - selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:无法通过 Python 使用 Selenium 定位元素错误 - selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element error using Selenium through Python Selenium.common.exceptions.NoSuchElementException 错误,即使显式等待 - Selenium.common.exceptions.NoSuchElementException error even with explicit waiting Selenium 中的 selenium.common.exceptions.NoSuchElementException - selenium.common.exceptions.NoSuchElementException in Selenium 为什么我收到此错误? selenium.common.exceptions.NoSuchElementException - Why i am getting this error ? selenium.common.exceptions.NoSuchElementException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM