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()点__击
-