Convert WebElement without Xpath to TestObject


Currently we are using JavaScript to get WebElements:

WebDriver driver = DriverFactory.getWebDriver()
WebElement ele = (WebElement) ((JavascriptExecutor)driver).executeScript("return document.querySelector("body......"))

Some of the elements are under ShadowRoots so a Xpath is not a option to convert the objects correctly.

Is there a way to convert the WebElements into Katalon TestObjects?

Unfortunately no, there’s no way to directly convert a WebElement object to a TestObject object. You can create TestObjects programmatically in your script though:

def testObject = new TestObject(“object_name”)

See the documentation for more details on this.

1 Like

Katalon does support working with sShadow DOM, see here:

although not sure if it’s working with the latest chrome driver, but worth to try out.

1 Like

Thank you, did not stumbled over that documentation. a bit more work then i was hoping for but sure a way to get it working.