java - Selenium WebDriver with Polymer website and Shadow root -
in google chrome console can click on shadow root element this.
document.queryselector('html /deep/ next-tab').queryselector('a').click()
but did same thing web-driver java code did not work .
here web-driver & java code.
webelement result = driver.findelement(by.cssselector("html /deep/ next-tab")).findelement(by.cssselector("html /deep/ a"); result.click();
can me this? simple thing somehow not figure out.
you should use shadowroot
property in javascript rather deep
deprecated:
javascriptexecutor jsexecuter = (javascriptexecutor)driver; webelement result = jsexecuter.executescript('return arguments[0].shadowroot', element) result.click();
where argument[0]
html
in case.
elaboration: webdriver
have option execute javascript after cast driver executor. javascriptexecutor
run javascript code directly page. selenium doesn't support shadowroot
out of box, need casting.
in order want (clicking element inside #shadow-root):
jsexecuter.executescript("return document.queryselector('html').shadowroot.queryselector('next-tab').queryselector('a').click()");
edit: in order click "electronics & applicances" you'll need:
jsexecuter.executescript("document.queryselector('next-app').shadowroot.queryselector('next-app-header').shadowroot.queryselector('app-header').queryselector('next-nav-bar').shadowroot.queryselector('div.bar').queryselector('next-tabs > next-tab').click();");
do see going? every time need element (html tag) under shadow-root
you'll need use .shadowroot
, queryselector('cssselector')
element want.
then can click element, or send keys etc... i've put lot of effort question, it's turn ;)
Comments
Post a Comment