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(
    '#test_button'))
inner = outer.find_element_by_id('inner_button')
inner.click()
Accessing elements in the shadow DOM