Using the Firefox webdriver, I want to extract all URLs from a href that contain a word.
I'm using the latest selenium binary.
Tried this:
driver = webdriver.Firefox()
driver.get(url)
nodes = driver.find_elements(By.XPATH, "//a[contains(@href,'products')]/@href")
print("nodes: ", nodes)
links = []
for elem in nodes:
    links.append(elem)
but get an type error:
selenium.common.exceptions.WebDriverException: Message: TypeError: Expected an element or WindowProxy, got: [object Attr href="https://www.example.com/catalogue/products/a.html"]
Also tried driver.find_elements(By.XPATH, "//a[contains(@href,'products')]")
and then using getAttribute("href") for each one, but couldn't as well.
Don't understand where's the error and how to solve this.
Extract of the html:
<html>
  <body>
    <ul class="level2-megamenu">
      <li>
        <div class="level1-title">
          <a href="https://www.example.com/catalogue/products/a.html">
          <strong style="color:#828282;font-size:>Text</strong>                 
          </a>
        </div>
      </li>
    </ul>
  </body>
</html>
 
    