intellij-ui-test-robot
intellij-ui-test-robot copied to clipboard
The Remote-Robot framework does not support native parts of the IntelliJ Idea
- some part of the IntelliJ Idea are on some platforms native and not accessible using the RR framework
- see the top menu on OX X:
Hello, thanks for the issue. We are working on separate library with basic fixtures and I believe we going to publish it soon. We expecting it will contains methods to work with native menu via osascript
which we use in our internal test project
Hello,
could you please try JMenuBarFixture which uses osascript
to work with native mac menu
@nizienko I tried to use that fixture, but I am not able to create instance on OS X (probably I need to use another approach because of the native parts on OS X). When I use:
JMenuBarFixture jMenuBarFixture = remoteRobot.find(JMenuBarFixture.class, Duration.ofSeconds(10));
I get an error:
default locator is not defined for class com.intellij.remoterobot.fixtures.JMenuBarFixture
@zcervink could you try following code, please:
remoteRobot.find(JMenuBarFixture.class, JMenuBarFixture.Companion.byType(), Duration.ofSeconds(10));
@mkfl3x I have tried it several times on OS X 11.5.2. When I run it from IntelliJ, it always uses the menu of IntelliJ I use to develop my tests, not the menu of IntelliJ that starts and is used to run the UI tests (I have focus on the IntelliJ that is used to run the UI tests, that does not help). When I run it from terminal, it fails (WaitForConditionTimeoutException), probably it is looking for the menu of IntelliJ, that is now closed.
After several unsuccessful attempts I have also tried the following code, it gave me the same results:
Locator locator = Locators.INSTANCE.byType(JMenuBar.class);
JMenuBarFixture menu = remoteRobot.find(JMenuBarFixture.class, locator);
@mkfl3x I have an important update. I have tried the JPopupMenuFixture (not native parts of IntelliJ on OS X) and it works without any issue. I have open context menu and after that the following code navigates and clicks as expected. Well, the JMenuBarFixture does not address the right process/IntelliJ instance.
JPopupMenuFixture menu = remoteRobot.find(JPopupMenuFixture.class, JPopupMenuFixture.Companion.byType(), Duration.ofSeconds(10));
menu.select("New", "File");
@mkfl3x @nizienko I have discussed this issue with my team - this issue is caused probably by wrong name of the IntelliJ used to run the UI tests (the name is generated in the JMenuBarFixture class). In my case (and I think it will be in all cases), the IntelliJ is name 'Main'. I think it will be really easy to fix.

@zcervink Thanks for the investigation, seems that processName='Main' when we run idea with gradle. We will think how to handle this.
I am not sure if this exactly related. But when I try to simply get access to the menu bar (even if the right instance) the call gets timed out.
val barFixture = remoteRobot.find<JMenuBarFixture>(JMenuBarFixture.byType(), Duration.ofSeconds(10))
Exceeded timeout (PT10S) for condition function (Failed to find 'JMenuBarFixture' by 'by type javax.swing.JMenuBar' in 10s)
com.intellij.remoterobot.utils.WaitForConditionTimeoutException: Exceeded timeout (PT10S) for condition function (Failed to find 'JMenuBarFixture' by 'by type javax.swing.JMenuBar' in 10s)
Even if I enter an actual xpath.
Exceeded timeout (PT10S) for condition function (Failed to find 'JMenuBarFixture' by '//div[@javaclass="javax.swing.JMenuBar" or contains(@classhierarchy, "javax.swing.JMenuBar ") or contains(@classhierarchy, " javax.swing.JMenuBar ")]' in 10s)
com.intellij.remoterobot.utils.WaitForConditionTimeoutException: Exceeded timeout (PT10S) for condition function (Failed to find 'JMenuBarFixture' by '//div[@javaclass="javax.swing.JMenuBar" or contains(@classhierarchy, "javax.swing.JMenuBar ") or contains(@classhierarchy, " javax.swing.JMenuBar ")]' in 10s)
@bric3 Could you please check the xpath in the browser? You can stop at the breakpoint on remoteRobot.find()
line, open in browser http://127.0.0.1:8580 and check xpath in the developer's console:
there should be one node found
Sorry I forgot versions in my earlier comment 🤦
Targeted IntelliJ :
IntelliJ IDEA 2021.1.3 (Ultimate Edition) Build #IU-211.7628.21, built on June 30, 2021 Licensed to <edited> You have a perpetual fallback license for this version. Subscription is active until September 7, 2022. Runtime version: 11.0.11+9-b1341.60 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 11.5 GC: G1 Young Generation, G1 Old Generation Memory: 512M Cores: 8 Registry: ide.mac.message.dialogs.as.sheets=false Non-Bundled Plugins: com.jetbrains.test.robot-server-plugin (0.11.7), com.datadog.intellij (0.2) Kotlin: 211-1.4.32-release-IJ7628.19
Robot : 0.11.7
So, actually I don't even have the WelcomeFrameMenuBar
as it's a native component
.
The trick to make the menu appear in the frame is to disable native UI in the Look-and-Feel.
systemProperty("apple.laf.useScreenMenuBar", "false")
Although I don't know how to do the same trick with native File Chooser Dialog window, eg when opening a project it opens a native window, and the robot does not show it.
@bric3 for File Chooser Dialog you can use ide.mac.file.chooser.native=false
Ah cool thanks
Hello @bric3,
I am facing the same issue as I also can't make the native menu bar and sheets show up, despite having set:
systemProperty("ide.mac.message.dialogs.as.sheets", "false")
systemProperty("apple.laf.useScreenMenuBar", "false")
Would you happen to know if this is still the recommended way to go about this ?
Do you mean you want to disable the Mac native menu and file chooser? Then these properties are correct. Check how we defined it in our test project
Thank you @nizienko !
Yes, that is exactly how they have been defined in Our project as well, but the native menu still shows up
@gsaslis Indeed, just checked that apple.laf.useScreenMenuBar
flag doesn't work.
I've found another one jbScreenMenuBar.enabled=false
, seems it is more reliable.
I'm going to fix this info in the docs, thanks for pointing at this.
@nizienko I'm trying with both but neither seems to be having any effect...
could I please ask you to send me a screenshot of how it looks like on your machine when it is enabled?
@gsaslis That's really strange. It seems we have to set both properties to false. I'm not sure that this is ok and asked about this in the corresponding issue
thanks @nizienko - setting both (!) to false did the trick... apologies I should have spotted that myself earlier!
Ah thanks for the update, this seem to have changed indeed. This question might surface again with the new UI ?