我想登录到已上载.net在python中使用selenium。这是我的代码:
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://www.uploaded.net/#login')
user = browser.find_element_by_xpath("//input[@type='text'][@name='id'][@value='Account-ID']")
user.clear()
user.send_keys("mypass")
password = browser.find_element_by_xpath("//input[@type='text'][@name='pw'][@value='Password']").click()
password.send_keys('mypass')
问题是,selenium成功地填充了用户名字段,但无法填充密码字段。我确信selenium正确地找到了密码字段,但是send_key函数无法填充密码字段。在
有人知道怎么解决这个问题吗?在
是的。我查过了上传.net看起来输入类型是password(显然),而不是您提供的text。在
问题出在这条线上:
单击元素后,类型将更改为“password”,因此selenium无法向保存在password中的元素发送命令。这有时被称为“stale”元素,因为它不再存在于页面上。在
您可以通过将代码更改为:
^{pr2}$相关问题 更多 >
编程相关推荐