24

I have one button from one LinkedIn page with this code:

<div class="primary-action-button"><a class="primary-action label" href="/requestList?displayProposal=&amp;destID=39959446&amp;creationType=DC&amp;authToken=Yr4_&amp;authType=OUT_OF_NETWORK&amp;trk=vsrp_people_res_pri_act&amp;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

2 Answers 2

22

Using selenium you could use the following code:

driver.find_element_by_link_text("Send InMail").click()
Sign up to request clarification or add additional context in comments.

2 Comments

I get an error: 'WebDriver' object has no attribute 'findElement'
fix it by using .find_element_by_link_text. Thanks.
5

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()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.