Click a href button with selenium and python?
54,597
Solution 1
Using selenium you could use the following code:
driver.find_element_by_link_text("Send InMail").click()
Solution 2
The above answer driver.findElement(By.linkText("Send InMail")).click();
is in Java. In python, use find_element_by_link_text
:
driver.find_element_by_link_text('Send InMail').click()
or something like this is sometimes helpful
driver.find_element_by_partial_link_text('Send').click()
Related videos on Youtube
Author by
Findios
Updated on July 09, 2022Comments
-
Findios almost 2 years
I have one button from one LinkedIn page with this code:
<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>
Is there any way to click on an element just by its href link? Thanks
-
Findios over 10 yearsI get an error: 'WebDriver' object has no attribute 'findElement'
-
Findios over 10 yearsfix it by using .find_element_by_link_text. Thanks.