0 votes
1 view
in DevOps and Agile by (20k points)

Using Selenium and the Chrome Driver I do:

links = browser.find_elements_by_partial_link_text('##') matches about 160 links.

If I try,

for link in links:

    print link.text

with it I get the text of all the links:

##1

##2

...

##160

The links are like this:

<a href="1.html">##1</a>

<a href="2.html">##2</a>

...

<a href="160.html">##160</a>

How can I get the href attribute of all the links found?

1 Answer

0 votes
by (28.4k points)

Call get_attribute on each of the links you have found as shown below:

links = browser.find_elements_by_partial_link_text('##')

for link in links:

    print link.get_attribute("href")

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...