Python Selenium Select All Links In Spesific Element

Question:

I have the following code which works fine gets and lists all of the links in the given URL however Im struggling to make it work when I want to get links in a specific tag. Im new at python

My code is;

chromedriver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
chromedriver.get("https://www.ebay.co.uk/usr/username")
links = chromedriver.find_elements("xpath", ".//a[@href]")

for link in links:
    print(link.get_attribute("href"))

Tag is;

<ol class="pagination__items">

</ol>
Asked By: Abdullah Ergun

||

Answers:

You can use the following XPath:

links = chromedriver.find_elements('xpath', '//ol[@class="pagination__items"]//a[@href]')
Answered By: Unmitigated