我正试图用Python上的WebDriver点击Selenium中Google frontpage上的Gmail链接。我的代码基本上复制了这里的代码:Why Cant I Click an Element in Selenium?
我的代码:
import selenium.webdriver as webdriver
firefox = webdriver.Firefox()
firefox.get("http://www.google.ca")
element = firefox.find_element_by_xpath(".//a[@id='gb_23']")
element.click()
webdriver加载页面,然后什么也没有发生。我试过使用ActionChains并将_移动到_element(element),单击(element),然后执行(),但也没有发生任何事情。
使用
find_element_by_id
方法:或者将xpath更正为:
Here you have nice tutorial.
试试看
您也可以使用
ClickElement
。试试这个,因为我在html中看不到这个id:
相关问题 更多 >
编程相关推荐