@@ -183,15 +183,15 @@ public void clickButton(String buttonText)
183183 btn .click (); // awaits being enabled, for example by selecting grid items
184184 }
185185
186- public void doMenuAction (String buttonText , List < String > menuActions )
186+ private MultiMenu getMultiMenu (String buttonText )
187187 {
188188 MultiMenu multiMenu = null ;
189189 boolean found = false ;
190190 int tries = 1 ;
191191
192192 // Sometimes the grid and query bar will load, and even the menu button will render but the text will
193193 // take just a few ms to render, so if at first you don't succeed try again.
194- while (!found && tries <= 3 )
194+ while (!found && tries <= 3 )
195195 {
196196 try
197197 {
@@ -205,15 +205,22 @@ public void doMenuAction(String buttonText, List<String> menuActions)
205205 }
206206 }
207207
208- // If the button still wasn't found try the 'More' button.
209- if (!found )
208+ // If the button still wasn't found, try the 'More' button.
209+ if (!found )
210210 {
211211 multiMenu = elementCache ().findMenu ("More" );
212212 Assert .assertTrue (String .format ("Could not find a menu button '%s' or 'More', don't know what to click." , buttonText ),
213213 multiMenu .getComponentElement ().isDisplayed ());
214214 getWrapper ().log (String .format ("Couldn't find menu button '%s', clicking the 'More' menu button." , buttonText ));
215215 }
216216
217+ return multiMenu ;
218+ }
219+
220+ public void doMenuAction (String buttonText , List <String > menuActions )
221+ {
222+ MultiMenu multiMenu = getMultiMenu (buttonText );
223+
217224 if (menuActions .size () == 1 )
218225 multiMenu .doMenuAction (menuActions .get (0 ));
219226 else if (menuActions .size () == 2 )
@@ -222,6 +229,12 @@ else if (menuActions.size() == 2)
222229 throw new IllegalArgumentException ("There should be either 1 or 2 menu actions, but was:" + menuActions );
223230 }
224231
232+ public boolean isMenuItemDisabled (String buttonText , String menuItem )
233+ {
234+ MultiMenu multiMenu = getMultiMenu (buttonText );
235+ return multiMenu .isMenuItemDisabled (menuItem );
236+ }
237+
225238 public List <String > getMenuButtonsText ()
226239 {
227240 // Because this is not a search for a specific menu button let's pause for a moment to give the buttons a
@@ -268,42 +281,6 @@ public List<String> getMenuText(String buttonText)
268281 throw new NoSuchElementException ("Couldn't find menu button with text '" + buttonText + "'." );
269282 }
270283
271- /**
272- * Private helper function that will get the text of the aliquot view button. This can be used to determine the
273- * current view. Asserts that the button is present.
274- *
275- * @return Text of the aliquot view button.
276- */
277- private String currentAliquotViewText ()
278- {
279- Assert .assertTrue ("There is no 'Aliquot View' button on this grid." ,
280- elementCache ().aliquotView .getComponentElement ().isDisplayed ());
281-
282- return elementCache ().aliquotView .getComponentElement ().getText ();
283- }
284-
285- /**
286- * Get the current view selected in the aliquot view button. This asserts that the button is present.
287- *
288- * @return A {@link AliquotViewOptions} item.
289- */
290- public AliquotViewOptions getCurrentAliquotView ()
291- {
292- String text = currentAliquotViewText ().toLowerCase ();
293-
294- if (text .contains ("all samples" ))
295- return AliquotViewOptions .ALL ;
296-
297- // If the current page is the sources page the text would be 'Derived Samples Only', so this should still work.
298- if (text .contains ("samples only" ))
299- return AliquotViewOptions .SAMPLES ;
300-
301- if (text .contains ("aliquots only" ))
302- return AliquotViewOptions .ALIQUOTS ;
303-
304- return null ;
305- }
306-
307284 public GridBar searchFor (String searchStr )
308285 {
309286
@@ -365,8 +342,6 @@ protected MultiMenu findMenu(String buttonText)
365342 return menus .get (buttonText );
366343 }
367344
368- protected final MultiMenu aliquotView = new MultiMenu .MultiMenuFinder (getDriver ()).withButtonClass ("aliquot-view-selector" ).findWhenNeeded (this );
369-
370345 protected final Input searchBox = Input .Input (Locator .tagWithClass ("input" , "grid-panel__search-input" ), getDriver ()).findWhenNeeded (this );
371346 protected final WebElement clearSearchButton = Locator .byClass ("fa-remove" ).findWhenNeeded (this );
372347 }
@@ -418,11 +393,4 @@ public Character getSeparator()
418393 return _separator ;
419394 }
420395 }
421-
422- public enum AliquotViewOptions
423- {
424- ALL ,
425- SAMPLES ,
426- ALIQUOTS
427- }
428396}
0 commit comments