[英]Selenium, Trying to Find an Element [Python]
I am trying type the username and password into my University mail using Selenium
module. 我正在尝试使用
Selenium
模块在我的大学邮件中输入用户名和密码。 This is the id's attribute value that I'm trying to locate: 这是我要查找的id的属性值:
<input id="ContentPlaceHolder1_UsernameTextBox" name="username" tabindex="1" placeholder="FAU Net ID" value="" autocomplete="false" type="text">
Here's how I'm trying to find it in my program: 这是我试图在程序中找到它的方法:
userElem = browser.find_element_by_id('ContentPlaceHolder1_UsernameTextBox')
But this is the error that I'm running into: 但这是我遇到的错误:
Exception -: 例外-:
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
emailElem = browser.find_element_by_id('ContentPlaceHolder1_UsernameTextBox')
File "C:\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 269, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "C:\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 752, in find_element
'value': value})['value']
File "C:\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "C:\Python\Python35\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [id="ContentPlaceHolder1_UsernameTextBox"]
Thanks and any help would be greatly appreciated. 谢谢,任何帮助将不胜感激。
EDIT: 编辑:
for reference this is the page 供参考,这是页面
If Selenium is telling you it couldn't find the element, then it isn't there. 如果Selenium告诉您找不到元素,则该元素不存在。 There are typically a few possible reasons for this:
通常有以下几种可能的原因:
browser.page_source
to double-check? browser.page_source
进行了仔细检查?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.