[英]Clicking special button with selenium and python
我试图在linkedin上单击“您可能认识的人”页面上的连接按钮( http://www.linkedin.com/people/pymk?trk=nmp-pymk-new_pymk_title )
此按钮的html代码为:
<a class="vcard-button bt-connect bt-primary" href="#"><span> </span>Connect</a>
我尝试这样做:
buttons=driver.find_elements_by_css_selector("a[class='vcard-button bt-connect bt-primary']")
然后为列表中的每个元素调用函数click()。 但是我一直得到同样的错误:
selenium.common.exceptions.WebDriverException: Message: u'unknown error: Element is not clickable at point (473, 14). Other element would receive the click: <input name="keywords" id="main-search-box" class="search-term" type="text" value="" autocomplete="off" placeholder="Search for people, jobs, companies, and more...">
(Session info: chrome=30.0.1599.101)
(Driver info: chromedriver=2.2,platform=Windows NT 6.1 SP1 x86_64)'
有人知道我在做什么错吗?
from selenium.webdriver.common.action_chains import ActionChains
self.driver = webdriver.Firefox()
# You need a mouse to hover the span elements here
self.mouse = webdriver.ActionChains(self.driver)
# You need get the element from its xpath:
buttons=driver.find_elements_by_css_selector("a[class='vcard-button bt-connect bt-primary']")
# Then you hover on span element by mouse and click on it:
self.mouse.move_to_element(buttons).click().perform()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.