Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我想用python中的selenium登录晨星_Python_Selenium_Authentication_Selenium Webdriver - Fatal编程技术网

我想用python中的selenium登录晨星

我想用python中的selenium登录晨星,python,selenium,authentication,selenium-webdriver,Python,Selenium,Authentication,Selenium Webdriver,当我尝试登录晨星时,会发生这种情况->AttributeError:“list”对象没有属性“send\u keys” 这是我的代码: 随机导入 从时间上导入睡眠 从selenium导入webdriver 从selenium.webdriver.common.keys导入密钥 作为pd进口熊猫 driver=webdriver.Chrome('./chromedriver.exe') 司机,上车https://www.morningstar.es/es/funds/snapshot/snapsh

当我尝试登录晨星时,会发生这种情况->AttributeError:“list”对象没有属性“send\u keys”

这是我的代码:

随机导入
从时间上导入睡眠
从selenium导入webdriver
从selenium.webdriver.common.keys导入密钥
作为pd进口熊猫
driver=webdriver.Chrome('./chromedriver.exe')
司机,上车https://www.morningstar.es/es/funds/snapshot/snapshot.aspx?id=F00000XDCO')
boton_1=驱动程序。通过xpath('/*[@id=“individualinvestor”]/span[1]”查找_元素
boton_1.单击()
睡眠(随机、均匀(1.0、3.0))
boton_2=驱动程序。通过xpath('/*[@id=“\u evidon-accept-button”]”查找元素
boton_2.单击()
睡眠(随机、均匀(4.0、8.0))
entrar=driver。通过xpath('/*[@id=“signInLabel”]')查找元素。单击()
睡眠(随机、均匀(1.0、3.0))
电子邮件=驱动程序。通过id(“txtUsername”)查找元素。发送密钥(“电子邮件”)

驱动程序。按id(“txtUsername”)查找元素。返回web元素列表。
您不能向web元素列表发送文本。
您只能将文本发送到特定的web元素。
因此,您必须使用
驱动程序。通过id(“txtUsername”)查找元素。发送密钥(“电子邮件”)

或者
list=driver。通过id('txtUsername')
查找元素,然后
list[0]。发送密钥(“电子邮件”)


在这种情况下,看起来您刚刚犯了一个错误,您应该使用
email=driver.find_element_by_id('txtUsername')。在此处发送密钥(“email”)
,您正在使用
find_element_by
这是错误的,您应该使用
find_element_by

find_element_by
返回一个列表,您无法向列表发送电子邮件,因此您应该使用
find_element_by


因此,只需删除
find_elements\u by

中的s即可。我在3分钟前写过:)我在发布时没有看到你的,页面上没有:)当然,我只是觉得这像个笑话。非常简单的Socrame错误