I am attempting to get the title attribute for every listing on a market.
Element:
<a href="/goods/857529?from=market#tab=selling" title="MP9 | Food Chain (Minimal Wear)" xpath="1">
My code:
xpath = "//body/div[@class='marketlist']/div[@class='l_Layout']/div[@id='j_market_card']/div[@id='j_list_card']/ul[@class='card_csgo']/li[1]/a[1]"
for itemName in driver.find_elements("xpath", xpath):
itemName = itemName.get_attribute("title")
print(itemName)
Right now only the first element is being located on the page, although all of the other listings share the exact same xpath. Is there any reason the other listings aren't being located?
Also, is there a better way to locate all of the elements than by xpath? I know link text can be used but each title is different, so I wouldn't be able to search by link text.