I'm trying to write a function, which returns a list of elements from any level of nesting from the html, containing the word 'products' in its text, case insensitive.
here is my function:
def __find_elements(driver):
return driver.find_elements(By.XPATH,
"//*[contains(translate(descendant::text(), "
"'ABCDEFGHIJKLMNOPQRSTUVWXYZ', "
"'abcdefghijklmnopqrstuvwxyz'), "
"'products')]")
; for some reason, processing this part of HTML
<a class="nav-link main-navigation-link" href="https://www.leuze.com/en-int/products" itemprop="url" data-flyout-menu-trigger="e3e2319128d6464d8a025ac00823ce4e" title="Products">
<div class="main-navigation-link-text"\>
<span itemprop="name"\>Products\</span\>
</div\>
</a\>
, the function returns [] instead of the list, containing the following span element:
<span itemprop="name">Products</span>
QUESTION:
Could you please clarify, how to modify the function to return a list with the mentioned above span element, while processing the part of HTML?
Expected: list with the element
<span itemprop="name">Products</span>
Actually happened: empty list