selenium 访问一个form的title,老是报错如题:web
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)
找了好几个方法都无论用:post
1. post_page.form_field(filed_name).send_Keys(content) 改为:form_field = post_page.form_field(filed_name) ; form_field.send_Keys(content)spa
2. import module : from selenium.webdriver.common.keys import Keyscode
3. 而后这个方法总算管用,缘由未知。orm
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()
