Selenium - WebElement 对象没有属性“sendKeys”

Joe*_*Sgg 1 python selenium

我正在尝试使用 selenium 在输入字段中输入文本,但出现错误。代码是:

input1 = browser.find_element_by_xpath('//*[@id="login-dialog dialog"]/div[2]/div[2]/div[2]/form/div[1]/input')
input1.sendKeys("myusername")
Run Code Online (Sandbox Code Playgroud)

但是它给出了这个错误

Traceback (most recent call last):
File "C:\Users\Bradley Jo\Desktop\Project\app.py", line 14, in 
<module>
input1.sendKeys("hello")
AttributeError: 'WebElement' object has no attribute 'sendKeys'
Run Code Online (Sandbox Code Playgroud)

Mur*_*thi 6

该方法不是 sendKeys。它是send_keys。

input1 = browser.find_element_by_xpath('//*[@id="login-dialog dialog"]/div[2]/div[2]/div[2]/form/div[1]/input')
input1.send_keys("myusername")
Run Code Online (Sandbox Code Playgroud)