Skip to content Skip to sidebar Skip to footer

How To Extract Info Within A #shadow-root (open) Using Selenium Python?

I got the next url related to an online store https://www.tiendasjumbo.co/buscar?q=mani and I can't extract the product label an another fields: from selenium import webdriver impo

Solution 1:

The products within the website https://www.tiendasjumbo.co/buscar?q=mani are located within a #shadow-root (open).

impulse-search


Solution

To extract the product label you have to use shadowRoot.querySelector() and you can use the following Locator Strategy:

  • Code Block:

    driver.get('https://www.tiendasjumbo.co/buscar?q=mani')
    item = driver.execute_script("return document.querySelector('impulse-search').shadowRoot.querySelector('div.group-name-brand h1.impulse-title span.formatted-text')")
    print(item.text)
    
  • Console Output:

    La especial mezcla de nueces, maní, almendras y marañones x 450 g
    

References

You can find a couple of relevant discussions in:

Post a Comment for "How To Extract Info Within A #shadow-root (open) Using Selenium Python?"