Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to locate an href that contains text

I am very new to coding - We are using Selenium with python scripting.

Please find the attached screen shot for the HMTL of my page.

The actual web page is a table that has "x" for all the user accounts.

I am trying to locate the href attribute that contains a user account that I pass as variable.(In the below example I am trying to click on the link that has "[email protected]" )

Can someone please help me locating the element.

Thanks!

like image 836
user3570279 Avatar asked Oct 17 '25 17:10

user3570279


1 Answers

You can find the element by xpath:

text = "[email protected]"  
element = driver.find_element_by_xpath('//a[contains(@href, "%s")]' % text)
like image 129
alecxe Avatar answered Oct 19 '25 06:10

alecxe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!