I'm having some issues to reach elements in a dropdown list with selenium.
I have a list with values that have to be insert in "Business Group" dropdown list, but the elements are in shadow-root, so I can't reach any of then.
The values that I have to select are in the tags kat-option
I tried almost all elements in the shadow-root , used find_elements and find_element, but I always get the same error: InvalidArgumentException: Message: invalid argument: invalid locator (Session info: chrome=105.0.5195.127)
type(shadow_root1) -- output: selenium.webdriver.remote.shadowroot.ShadowRoot
My code:
def expand_shadow_element(element):
shadow_root = driver.execute_script('return arguments[0].shadowRoot', element)
return shadow_root
root1 = driver.find_element(By.CSS_SELECTOR, '#businessGroupKat')
shadow_root1 = expand_shadow_element(root1)
#type(shadow_root1)
shadow_root1.find_elements(By.TAG_NAME, 'input')