使用Python Selenium和IE驱动程序我没有成功找到元素
这是HTML代码的一部分:
<div class="loginTextCss">
<label for="j_username">User Name:</label>
<br />
<input id="j_username" name="j_username" type="text" value="" style="font-size:16px; width:170px;" />
<br /><br />
<label for="j_password">Password:</label>
<br />
<input type="password" id="j_password" name="j_password" value="" style="font-size:16px; width:170px;" />
<br />
<div style="font-size:11;">
<input id="rememberMe" type="checkbox" name="_spring_security_remember_me" title="Remember me on this computer" />
<label for="rememberMe" title="Remember me on this computer">Remember me on this computer</label>
</div>
</div>
我的代码是:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
browser = webdriver.Ie()
browser.get('http://192.168.58.32/asset-manager-web/')
browser.maximize_window()
element = browser.find_element_by_id('j_username')
我收到了错误:
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
browser.find_element_by_id("j_username")
File "C:\Python33\lib\site-packages\selenium-2.41.0-py3.3.egg\selenium\webdriver\remote\webdriver.py", line 199, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "C:\Python33\lib\site-packages\selenium-2.41.0-py3.3.egg\selenium\webdriver\remote\webdriver.py", line 655, in find_element
{'using': by, 'value': value})['value']
File "C:\Python33\lib\site-packages\selenium-2.41.0-py3.3.egg\selenium\webdriver\remote\webdriver.py", line 166, in execute
self.error_handler.check_response(response)
File "C:\Python33\lib\site-packages\selenium-2.41.0-py3.3.egg\selenium\webdriver\remote\errorhandler.py", line 164, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: 'Unable to find element with id == j_username'
有人知道这是什么问题吗?
由于