[intellij-ui-test-robot] Error when attempting to .click() on DomElement #491

Hi all,

Reposting an issue I've created on the repo for `intellij-ui-test-robot` to try and raise visibility as it's blocking myself and at least 2 other folks from using the tool for e2e testing of the browser components in our plugins.

https://github.com/JetBrains/intellij-ui-test-robot/issues/491#issuecomment-2881071079

 

----

 

## Overview
When attempting to click on a DomElement found using the `JCefBrowserFixture`, I get the error logs below.

## Relevant logs

```
Dec 19, 2024 3:00:34 PM com.intellij.remoterobot.stepsProcessing.StepLogger doBeforeStep
INFO:         find DOM elements by '//*[contains(text(), 'Get started')]'
Dec 19, 2024 3:00:34 PM com.intellij.remoterobot.stepsProcessing.StepLogger doBeforeStep
INFO:     click at BUTTON
Dec 19, 2024 3:00:34 PM com.intellij.remoterobot.stepsProcessing.StepLogger doBeforeStep
INFO:         scroll to BUTTON
Dec 19, 2024 3:00:34 PM com.intellij.remoterobot.stepsProcessing.StepLogger doOnFail
WARNING:             Failed on step: scroll to BUTTON (StepWorker.kt_step)
...
com.intellij.remoterobot.fixtures.JCefBrowserFixture$JCEFScriptExecutionError: Failed to execute script:

           const cefBrowser = local.get("__cefBrowser");
           if (!cefBrowser) {
               throw new Error("__cefBrowser was not initialized");
           }
           const query = local.get("__Query");
           if (!query) {
               throw new Error("__Query was not initialized");
           }
           const inProgress = "IN PROGRESS"
           local.put("__Result", inProgress);
           const getResult = () => local.get("__Result")

           const initScript = `  window.elementFinder = {};  function Elm(element) { this.tag = element.tagName; this.html = element.outerHTML; this.location = element.getBoundingClientRect(); this.xpath = '/' + window.elementFinder.getPathTo(element).toLowerCase(); }  window.elementFinder.findElement = (xpath) => { console.log("findElement: by '" + xpath + "'"); return document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; };  window.elementFinder.scrollByXpath = (xpath) => { console.log("scrollByXpath: to '" + xpath + "'"); const element = window.elementFinder.findElement(xpath); console.log("found: " + element); element.scrollIntoView(); return "success"; };  window.elementFinder.findElements = (xpath) => { console.log("findElements: by '" + xpath + "'"); const foundElements = []; const nodesSnapshot = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null ); for (let i = 0; i < nodesSnapshot.snapshotLength; i++ ) { foundElements.push( nodesSnapshot.snapshotItem(i) ); } console.log("found " + foundElements.length); const result = foundElements.map((it) => new Elm(it)); return JSON.stringify(result); };  window.elementFinder.getPathTo = (element) => { if (element.tagName.toLowerCase() === 'html') { return element.tagName; } let ix = 0; const siblings = element.parentNode.childNodes; for (let i = 0; i < siblings.length; i++) { const sibling = siblings[i]; if (sibling === element) { return window.elementFinder.getPathTo(element.parentNode) + '/' + element.tagName + '[' + (ix + 1) + ']'; } if (sibling.nodeType === 1 && sibling.tagName === element.tagName) { ix++; } } };  `
           cefBrowser.executeJavaScript(initScript, cefBrowser.getURL(), 0);
           
           cefBrowser.executeJavaScript(query.inject('window.elementFinder.scrollByXpath("/html/body[1]/div[1]/div[1]/div[1]/div[2]/div[1]/main[1]/div[3]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/pre[1]/code[1]")'), cefBrowser.getURL(), 0);
           let x = 0;
           // noinspection EqualityComparisonWithCoercionJS
           while(getResult() == inProgress) {
               Thread.sleep(50);
               x++;
               if (x * 50 > 3000) {
                   throw "No result from script 'window.elementFinder.scrollByXpath("/html/body[1]/div[1]/div[1]/div[1]/div[2]/div[1]/main[1]/div[3]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/pre[1]/code[1]")' in embedded browser. Check logs in browsers DevTools(right click at the browser)" 
               }
           }
           getResult();
       
    at com.intellij.remoterobot.fixtures.JCefBrowserFixture.executeJsInBrowser(JCefBrowserFixture.kt:213)
    at com.intellij.remoterobot.fixtures.JCefBrowserFixture.scrollTo(JCefBrowserFixture.kt:170)
    at com.intellij.remoterobot.fixtures.DomElement$scroll$1.invoke(JCefBrowserFixture.kt:292)
    at com.intellij.remoterobot.fixtures.DomElement$scroll$1.invoke(JCefBrowserFixture.kt:291)
    at com.intellij.remoterobot.stepsProcessing.StepWorkerKt.step(StepWorker.kt:23)
    at com.intellij.remoterobot.fixtures.DomElement.scroll(JCefBrowserFixture.kt:291)
    at com.intellij.remoterobot.fixtures.DomElement$click$1.invoke(JCefBrowserFixture.kt:283)
    at com.intellij.remoterobot.fixtures.DomElement$click$1.invoke(JCefBrowserFixture.kt:282)
    at com.intellij.remoterobot.stepsProcessing.StepWorkerKt.step(StepWorker.kt:23)
    at com.intellij.remoterobot.fixtures.DomElement.click(JCefBrowserFixture.kt:282)
    at com.github.continuedev.continueintellijextension.e2e.GUITests$completeTutorial$1$4.invoke(GUITests.kt:91)
    at com.github.continuedev.continueintellijextension.e2e.GUITests$completeTutorial$1$4.invoke(GUITests.kt:86)
    at com.intellij.remoterobot.stepsProcessing.StepWorkerKt.step(StepWorker.kt:23)
    at com.github.continuedev.continueintellijextension.e2e.GUITests.completeTutorial(GUITests.kt:86)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:728)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:86)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:218)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:214)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:139)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:118)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:93)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:88)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:62)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
    at jdk.proxy1/jdk.proxy1.$Proxy2.stop(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
    at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
    at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
    at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Caused by: com.intellij.remoterobot.client.IdeaSideException: missing ; before statement
    at com.intellij.remoterobot.client.IdeRobotClient.throwIdeaSideError(IdeRobotClient.kt:141)
    at com.intellij.remoterobot.client.IdeRobotClient.processRetrieveResponse(IdeRobotClient.kt:117)
    at com.intellij.remoterobot.client.IdeRobotClient.retrieve(IdeRobotClient.kt:79)
    at com.intellij.remoterobot.JavaScriptApi$DefaultImpls.callJs(JavaScriptApi.kt:101)
    at com.intellij.remoterobot.RemoteRobot.callJs(RemoteRobot.kt:32)
    at com.intellij.remoterobot.fixtures.Fixture.callJs(Fixture.kt:104)
    at com.intellij.remoterobot.fixtures.Fixture.callJs$default(Fixture.kt:97)
    at com.intellij.remoterobot.fixtures.JCefBrowserFixture.executeJsInBrowser(JCefBrowserFixture.kt:211)
    ... 97 more
```

## Code to reproduce

```kotlin
val jcefBrowser =
               find<JCefBrowserFixture>(if (isMac()) JCefBrowserFixture.macLocator else JCefBrowserFixture.canvasLocator)

val testElem = jcefBrowser.findElementByContainsText("Sample string in browser")
testElem.click() // This line fails with the above errors
```

## Relevant information
- Library version: 0.11.23
- OffScreenRendering is enabled (note that when this was disabled, I couldn't target the browser at all)
- Build config:
```kotlin
runIdeForUiTests {
       systemProperty("robot-server.port", "8082")
       systemProperty("ide.mac.message.dialogs.as.sheets", "false")
       systemProperty("jb.privacy.policy.text", "<!--999.999-->")
       systemProperty("jb.consents.confirmation.enabled", "false")
       systemProperty("ide.mac.file.chooser.native", "false")
       systemProperty("jbScreenMenuBar.enabled", "false")
       systemProperty("apple.laf.useScreenMenuBar", "false")
       systemProperty("idea.trust.all.projects", "true")
       systemProperty("ide.show.tips.on.startup.default.value", "false")
       systemProperty("ide.browser.jcef.jsQueryPoolSize", "10000")
       systemProperty("ide.browser.jcef.contextMenu.devTools.enabled", "true")

       intellij {
           version.set("2024.1")
       }
   }
```

## Troubleshooting steps taken
I copied the JCefBrowserFixture class into my project and tried to comment out the `scroll()` line [here](https://github.com/JetBrains/intellij-ui-test-robot/blob/master/remote-fixtures/src/main/kotlin/com/intellij/remoterobot/fixtures/JCefBrowserFixture.kt#L283), got the same "missing ; before statement" error 

1

Please sign in to leave a comment.