@@ -61,38 +61,41 @@ public boolean isSelected()
6161 public SuperPackageRow select () // note: this 'selection' behavior is expressed among assigned packages, not among available packages
6262 {
6363 if (!isSelected ())
64- newElementCache ().desc .click ();
65- getWrapper () .waitFor (()-> isSelected () ,
64+ elementCache ().desc .click ();
65+ WebDriverWrapper .waitFor (this :: isSelected ,
6666 "row item never became selected" ,2000 );
6767 return this ;
6868 }
6969
7070 public String getLabel ()
7171 {
72- return newElementCache ().desc .getText ();
72+ return elementCache ().desc .getText ();
7373 }
7474
7575 public SuperPackageRow clickMenuItem (String menuText )
7676 {
77- getWrapper ().fireEvent (newElementCache ().menuToggle , WebDriverWrapper .SeleniumEvent .mouseover );
78- newElementCache ().menuToggle .click ();
79- // wait for the menu to expand
80- getWrapper ().waitFor (()-> newElementCache ().menuToggle .getAttribute ("class" ).contains ("open" ), 1000 );
81- Locator menuItem = Locator .tagWithAttribute ("li" , "role" , "presentation" )
82- .child (Locator .tagWithAttribute ("a" , "role" , "menuitem" )
83- .containing (menuText ));
84- WebElement itemToClick = menuItem .waitForElement (getComponentElement (), 2000 );
85- getWrapper ().fireEvent (newElementCache ().menuToggle , WebDriverWrapper .SeleniumEvent .mouseover );
86- getWrapper ().waitFor (()-> itemToClick .isEnabled (), 2000 );
87- itemToClick .click ();
88- // wait for the menu to collapse (or disappear, if 'remove' was the action')
89- getWrapper ().waitFor (()-> {
90- try
91- {
92- return newElementCache ().menuToggle .getAttribute ("aria-expanded" ).equals ("false" );
93- }catch (StaleElementReferenceException sere ){return true ;}
94- }, 1000 );
95- return this ;
77+ getWrapper ().mouseOver (this .getComponentElement ());
78+ elementCache ().menuToggle .click ();
79+ // wait for the menu to expand
80+ WebDriverWrapper .waitFor (() -> elementCache ().menuToggle .getAttribute ("aria-expanded" ).equals ("true" ), () -> "Menu didn't open: " + getLabel (), 1000 );
81+ Locator menuItem = Locator .tagWithAttribute ("li" , "role" , "presentation" )
82+ .child (Locator .tagWithAttribute ("a" , "role" , "menuitem" )
83+ .containing (menuText ));
84+ WebElement itemToClick = menuItem .waitForElement (getComponentElement (), 2000 );
85+ WebDriverWrapper .waitFor (itemToClick ::isEnabled , () -> "Menu item not enabled: " + menuText , 2000 );
86+ itemToClick .click ();
87+ // wait for the menu to collapse (or disappear, if 'remove' was the action')
88+ WebDriverWrapper .waitFor (() -> {
89+ try
90+ {
91+ return elementCache ().menuToggle .getAttribute ("aria-expanded" ).equals ("false" );
92+ }
93+ catch (StaleElementReferenceException sere )
94+ {
95+ return true ;
96+ }
97+ }, "Menu didn't close" , 1000 );
98+ return this ;
9699 }
97100
98101 @ Override
@@ -101,7 +104,7 @@ protected ElementCache newElementCache()
101104 return new ElementCache ();
102105 }
103106
104- protected class ElementCache extends Component .ElementCache
107+ protected class ElementCache extends Component <?> .ElementCache
105108 {
106109 public WebElement menuToggle = Locator .tagWithClassContaining ("div" , "btn-group" ) // sometimes dropdown, dropup
107110 .child (Locator .id ("superpackage-actions" ))
0 commit comments