intellij-ui-test-robot icon indicating copy to clipboard operation
intellij-ui-test-robot copied to clipboard

The Remote-Robot framework does not support native parts of the IntelliJ Idea

Open zcervink opened this issue 4 years ago • 21 comments

  • 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: img

zcervink avatar Jan 12 '21 11:01 zcervink

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

nizienko avatar Jan 12 '21 17:01 nizienko

Hello, could you please try JMenuBarFixture which uses osascript to work with native mac menu

nizienko avatar May 13 '21 10:05 nizienko

@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 avatar Aug 31 '21 07:08 zcervink

@zcervink could you try following code, please: remoteRobot.find(JMenuBarFixture.class, JMenuBarFixture.Companion.byType(), Duration.ofSeconds(10));

mkfl3x avatar Aug 31 '21 10:08 mkfl3x

@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);

zcervink avatar Aug 31 '21 16:08 zcervink

@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");

zcervink avatar Aug 31 '21 16:08 zcervink

@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.

Snímek obrazovky 2021-09-01 v 20 12 19

zcervink avatar Sep 01 '21 18:09 zcervink

@zcervink Thanks for the investigation, seems that processName='Main' when we run idea with gradle. We will think how to handle this.

nizienko avatar Sep 02 '21 13:09 nizienko

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 avatar Oct 20 '21 14:10 bric3

@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: image there should be one node found

nizienko avatar Oct 20 '21 16:10 nizienko

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 image.

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")

image image

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 avatar Oct 21 '21 09:10 bric3

@bric3 for File Chooser Dialog you can use ide.mac.file.chooser.native=false

nizienko avatar Oct 21 '21 10:10 nizienko

Ah cool thanks

bric3 avatar Oct 21 '21 11:10 bric3

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 ?

gsaslis avatar Jul 19 '22 14:07 gsaslis

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

nizienko avatar Jul 19 '22 15:07 nizienko

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 avatar Jul 19 '22 15:07 gsaslis

@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 avatar Jul 19 '22 16:07 nizienko

@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 avatar Jul 19 '22 18:07 gsaslis

@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

nizienko avatar Jul 20 '22 09:07 nizienko

thanks @nizienko - setting both (!) to false did the trick... apologies I should have spotted that myself earlier!

gsaslis avatar Jul 20 '22 14:07 gsaslis

Ah thanks for the update, this seem to have changed indeed. This question might surface again with the new UI ?

bric3 avatar Jul 28 '22 16:07 bric3