我想在 Python 中使用 Splinter 直接输入电子邮件和密码。问题是它出现了这条消息:
AttributeError: 'ElementList' object has no attribute 'fill'
我做的代码如下:
browser.find_by_id('email').first.find_by_tag('input').fill('test@gmail.com')
browser.find_by_id('password').first.find_by_tag('input').fill('mypassword')
'login_email' 是文本框的名称,它是电子邮件类型。与密码相同。 ¿为什么这不起作用的任何帮助?
更新:我尝试了 narzero 的代码,但现在它说它没有找到元素:splinter.exceptions.ElementDoesNotExist:找不到 ID 为“email”的元素。
最佳答案
经过一些研究,似乎有人遇到了与您相同的问题。 find_by_name 返回一个 ElementList,因此您必须选择这些 Element 之一。为此,您可以使用 ElementList 的第一种方法。
这是从 this post 中提取的一些工作代码
# Find the username form and fill it with the defined username
browser2.find_by_id('gebruikersnaam').first.find_by_tag('input').fill(username2)
# Find the password form and fill it with the defined password
browser2.find_by_id('wachtwoord').first.find_by_tag('input').fill(password2)
# Find the submit button and click
browser2.find_by_css('.submit').first.click()
感谢 narzero 提供此代码。
找到适合您需求的方式
关于python - Splinter 在 PayPal 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33870214/