0

Using Selenium/Java/JMeter/chromedriver - Am trying to access elements in a shadowDOM page with roots nested on several levels using return arguments[0].shadowRoot. However am getting the error below:

Error in method invocation: Method executeScript( java.lang.String, org.openqa.selenium.remote.RemoteWebElement ) not found in class'org.openqa.selenium.chrome.ChromeDriver

What am I missing? Thank you!

import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.*;
import org.openqa.selenium.remote.RemoteWebElement;
WebDriverWait wait = new WebDriverWait(WDS.browser, 10);

WDS.browser.get("contentPage");
//checks/waits, switchtoFrame
WebElement root1 = WDS.browser.findElement(By.cssSelector("launcher"));
//confirming find successful
WDS.log.info("Found: " + root1.getAttribute("href"));
JavascriptExecutor jse = (JavascriptExecutor) WDS.browser;  
jse.executeScript("return arguments[0].shadowRoot", root1);
dr00x
  • 1
  • Check [this](https://stackoverflow.com/questions/56380091/how-to-interact-with-the-elements-within-shadow-root-open-while-clearing-brow/56381495#56381495) answer which have detailed explanation how to work with shadow elements. – supputuri Mar 20 '20 at 19:18

1 Answers1

0

Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting

It looks like you're using Beanshell which isn't really java, so make sure to choose groovy as the scripting language for the WebDriver Sampler

enter image description here

and once done you should be able to normally use your existing code.

More information: Apache Groovy - Why and How You Should Use It

Dmitri T
  • 159,985
  • 5
  • 83
  • 133