码迷,mamicode.com
首页 > Web开发 > 详细

selenium error "WebElement object has no attribute 'sendKeys'

时间:2019-02-20 12:40:44      阅读:933      评论:0      收藏:0      [点我收藏+]

标签:key   alt   browser   action   ima   name   sel   https   break   

selenium 访问一个form的title,总是报错如题:

WebElement object has no attribute ‘sendKeys‘ [duplicate]

@when (‘I enter "(.*)" in the "(.*)" field‘)
def step_impl(context,content,filed_name):
post_page = Post_Page(context.driver)
post_page.form_field(filed_name).send_Keys(content)

找了好几个方法都不管用:

1.   post_page.form_field(filed_name).send_Keys(content) 改成:form_field = post_page.form_field(filed_name) ; form_field.send_Keys(content)

2.  import module :  from selenium.webdriver.common.keys import Keys

 

3. 然后这个方法总算管用,原因未知。

Input1 = browser.find_element_by_xpath(‘//*[@id="login-dialog dialog"]/div[2]/div[2]/div[2]/form/div[1]/input‘)
actions = ActionChains(driver)
actions.move_to_element(input1).send_keys("myusername").perform()

技术图片

 

 

selenium error "WebElement object has no attribute 'sendKeys'

标签:key   alt   browser   action   ima   name   sel   https   break   

原文地址:https://www.cnblogs.com/cometous/p/10344600.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!