selenium获取元素后用click()点击没有作用,用键盘输入enter(Keys.ENTER)就可以成功
#coding = utf-8 from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Firefox() driver.get("http://www.baidu.com") driver.find_element_by_xpath("//*[@id='gxszButton']/a[1]").send_keys(Keys.ENTER) #键盘输入enter # driver.find_element_by_xpath("//*[@id='gxszButton']/a[1]").click() #用click()点__击
#提交,点击操作
driver.find_element_by_id("submit").click()
driver.find_element_by_xpath('//*[@id="btn_query"]').submit()
driver.find_element_by_id('btn_query').send_keys(Keys.ENTER)
driver.execute_script("var login=document.getElementById('btn_query');login.click();")