I am trying to access the table elements under Shadow root but I am unable to access it.
The structure is as shown below Structure of the shadow DOM
I have tried below code but still having failure
${title}= Get Row Count Under Shadow Root Element
log ${title}
Close Browser
import selenium
from selenium import webdriver
from robot.libraries.BuiltIn import BuiltIn
def expand_shadow_element(driver, element):
shadow_root = driver.execute_script('return arguments[0].shadowRoot', element)
return shadow_root
def get_row_count_under_shadow_root_element():
seleniumlib = BuiltIn().get_library_instance('Selenium2Library')
driver = seleniumlib.driver
root1 = driver.find_element_by_tag_name('vaadin-grid')
shadow_root1 = expand_shadow_element(driver, root1)
row_count = shadow_root1.find_element_by_xpath("//div[@id='scroller']//table[@id='table']").get_attribute("aria-rowcount")
# row_count = driver.find_element_by_xpath("//div[@id='scroller']").click()
return row_count
Can someone guide me what is wrong in this.
Also a working code would be really appreciated.