2626
2727import java .time .Duration ;
2828import java .util .List ;
29+ import java .util .Optional ;
2930
3031import static com .intellij .remoterobot .search .locators .Locators .byXpath ;
3132import static com .intellij .remoterobot .utils .RepeatUtilsKt .waitFor ;
@@ -66,7 +67,7 @@ public void navigateTo(String... path) {
6667
6768 // Wait for the JPopupMenuFixture to appear
6869 waitFor (Duration .ofSeconds (5 ), Duration .ofSeconds (1 ), "JPopupMenu to appear" , () ->
69- !remoteRobot .findAll (JPopupMenuFixture .class , JPopupMenuFixture .Companion .byType ()).isEmpty ()
70+ !remoteRobot .findAll (JPopupMenuFixture .class , JPopupMenuFixture .Companion .byType ()).isEmpty ()
7071 );
7172 }
7273
@@ -109,18 +110,22 @@ public CommonContainerFixture getMainMenu() {
109110 return cf ;
110111 }
111112
112- public void setVisible (){
113+ public void setVisible () {
113114 // check menu already visible
114115 try {
115116 getMainMenu ();
116117 } catch (WaitForConditionTimeoutException e ) {
117118 // not visible
118119 MainIdeWindow mainIdeWindow = remoteRobot .find (MainIdeWindow .class , Duration .ofSeconds (5 ));
119120 mainIdeWindow .searchEverywhere ("Appearance" );
120- ScreenshotUtils .takeScreenshot (remoteRobot );
121- ComponentFixture appearanceDialog = remoteRobot .find (ComponentFixture .class , byXpath ("//div[@class='JBViewport'][.//div[@class='MyList']]" ));
121+ ComponentFixture appearanceDialog = remoteRobot .find (ComponentFixture .class , byXpath ("//div[@class='SearchEverywhereUI']" ));
122122 List <RemoteText > items = appearanceDialog .findAllText ();
123- items .stream ().filter (remoteText -> remoteText .getText ().equals ("View | Appearance: Main Menu" )).findFirst ().ifPresent (RemoteText ::click );
123+ Optional <RemoteText > item = items .stream ().filter (remoteText -> remoteText .getText ().equals ("View | Appearance: Main Menu" )).findFirst ();
124+ if (item .isPresent ()) {
125+ item .get ().click ();
126+ } else {
127+ ScreenshotUtils .takeScreenshot (remoteRobot , "Can't find 'Appearance' Main menu item" );
128+ }
124129 }
125130 }
126131}
0 commit comments