selenium error "WebElement object has no attribute 'sendKeys'


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()

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM