Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get link value inside href

I have a div tag in which a tag is enclosed. How can i get the value href?

For example, "https://www.tweeter.com/rkShukl" from <a> tag:

<a href="https://www.tweeter.com/rkShukl"></a>
like image 358
Little bird Avatar asked Apr 24 '26 23:04

Little bird


1 Answers

It depends on the language bindings. In java it is getAttribute():

WebElement element = driver.findElement(By.id('id_of_the_link'));
element.getAttribute('href');

In Python it is get_attribute():

element = driver.find_element_by_id('id_of_the_link')
element.get_attribute('href')
like image 115
alecxe Avatar answered Apr 26 '26 13:04

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!