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

Answer

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

Leave a Reply

Your email address will not be published. Required fields are marked *