我的代码中有如下元素:
<input data-v-d6c12922="" type="text" name="account" placeholder="账号" class="username">
<input data-v-d6c12922="" type="password" name="password" placeholder="密码" class="password">
我用过这个,但不起作用
userElem = browser.find_element_by_xpath("//html/body/div[1]/div[1]/div[2]/div/div[2]/input")
错误:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//html/body/div[1]/div[1]/div[2]/div/div[2]/input"}
如何自动填写用户名和密码
多谢各位
问题可能是您试图在元素可见之前找到它
您可以使用下面的代码等待元素可见(我还通过CLASS_NAME而不是XPATH查找ID,并捕获一个屏幕截图以显示字段已填充)
相关问题 更多 >
编程相关推荐