Sarfraz
Sarfraz

Reputation: 108

How to Find Element by Link Text using Selenium Python

I've few web links please let me know how I can visit their contact pages i've tried using but not working

contact_link = driver.find_element_by_partial_link_text('Contact')

and

driver.find_element_by_xpath('//a[contains(text(),"contact")]')

Every web page have different classes and different attributes so it is possible to do..

thanks

Upvotes: 0

Views: 5940

Answers (2)

Asif Alam
Asif Alam

Reputation: 69

you can use:

driver.find_element_by_link_text("Contact").click()

Upvotes: 0

Andersson
Andersson

Reputation: 52665

Try this one on each page (each site homepage) driver.find_element_by_xpath('//a[contains(@href,"contact")]').click()

Upvotes: 1

Related Questions