'I can't get into Shadow root selenium

enter image description here

I'm developing an automation in selenium python, and not being able to enter iframe due to shadow root

   def expand_shadow_element(element):
    shadow_root = driver.execute_script('return arguments[0].shadowRoot', element)
    return shadow_root

    outer = expand_shadow_element(driver.find_element_by_css_selector("body > macroponent-f51912f4c700201072b211d4d8c26010"))
    inner = outer.find_element_by_css_selector("/html/body/macroponent-f51912f4c700201072b211d4d8c26010//div")

     inner.click()


    
    

    time.sleep(5)
    #driver.switch_to.default_content()
    driver.switch_to.frame(driver.find_element_by_xpath('//*[@id="gsft_main"]'))
  


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source