我正在尝试使用我编写的selenium脚本登录一个网站。im的问题是,当它登录时,它无法找到输入的密码。
search = driver.find_element_by_id("clareity")
search.send_keys("user")
search.find_element_by_xpath('//div[@class="form-control lock"]')
search.send_keys("pass")在查找xpath时,它会将密钥发送到用户名输入中,因此当发送两个密钥时,在站点上的用户输入中,它会显示"userPass“,而不是将pass放在密码输入中。
用户名输入表单:
<div class="form-control person" data-ph="LOGIN ID" id="clareity" contenteditable="true" required="" spellcheck="false" autocomplete="off" autocorrect="off" autocapitalize="off"></div>密码输入表单:
<div class="form-control lock" data-ph="PASSWORD" id="security" contenteditable="true" required="" spellcheck="false" autocomplete="off" autocorrect="off" autocapitalize="off"></div>发布于 2021-05-05 07:47:58
您为user创建了一个变量,因此需要对password执行相同的操作
search = driver.find_element_by_id("clareity")
search.send_keys("user")
password = driver.find_element_by_id("security")
password.send_keys("pass")或者根本不使用变量
driver.find_element_by_id("clareity").send_keys("user")
driver.find_element_by_id("security").send_keys("pass")https://stackoverflow.com/questions/67393477
复制相似问题