我试图在一个带有 python 和 Selenium 的网页中找到一个登录表单(带有两个规范的用户和密码字段)(该页面是通用的,所以我不能使用字段的 ID 或特定的 xpath地点)。
一般情况下,我使用
获取网页中的所有表单for form in browser.find_elements_by_xpath('.//form'):
然后我想找到所有的输入字段
for input_field in form.find_elemenents_by_xpath('.//input'):
但是我得到一个错误:
AttributeError: 'WebElement' object has no attribute 'find_elemenent_by_xpath'
在网上我发现我可以在 webElement 上使用“find_element”,但它不起作用。
有人可以帮助我吗?提前谢谢你!
请您参考如下方法:
你的代码有错别字
您输入的是 elements 而不是 elements
