How can I get the href of elements found by partial link text? How can I get the href of elements found by partial link text? python python

How can I get the href of elements found by partial link text?


Call get_attribute on each of the links you have found:

links = browser.find_elements_by_partial_link_text('##')for link in links:    print(link.get_attribute("href"))


An existing answer to a similar question seems like it might apply:

Assume

your HTML consists solely of that one tag, then this should do it:

String href = selenium.getAttribute("css=a@href");

You use the DefaultSelenium#getAttribute() method and pass in a CSS locator, an @ symbol, and the name of the attribute you want to fetch. In this case, you select the a and get its @href.

So if the link contains "..blablabla..." text then you can find it in that way:

selenium.getAttribute("css=a:contains('..blablabla...')@href");