使用selenium和python单击href按钮?
我有一个LinkedIn页面上的一个按钮,代码如下:使用selenium和python单击href按钮?,python,selenium,button,click,href,Python,Selenium,Button,Click,Href,我有一个LinkedIn页面上的一个按钮,代码如下: <div class="primary-action-button"><a class="primary-action label" href="/requestList?displayProposal=&destID=39959446&creationType=DC&authToken=Yr4_&authType=OUT_OF_NETWORK&
<div class="primary-action-button"><a class="primary-action label" href="/requestList?displayProposal=&destID=39959446&creationType=DC&authToken=Yr4_&authType=OUT_OF_NETWORK&trk=vsrp_people_res_pri_act&trkInfo=VSRPsearchId%3A2998448551382744275729%2CVSRPtargetId%3A39959446%2CVSRPcmpt%3Aprimary">Send InMail</a></div>
有没有办法只通过href链接点击一个元素?感谢使用selenium,您可以使用以下代码:
driver.find_element_by_link_text("Send InMail").click()
上面的答案
driver.findElement(By.linkText(“Send InMail”))。单击()代码>是用Java编写的。在python中,使用find\u element\u by\u link\u text
:
driver.find_element_by_link_text('Send InMail').click()
或者像这样的东西有时是有用的
driver.find_element_by_partial_link_text('Send').click()
我收到一个错误:“WebDriver”对象没有属性“findElement”,请使用.find\u element\u by\u link\u text修复它。谢谢