Test GWT SimplePager ImageButton enabled state in Selenium Test GWT SimplePager ImageButton enabled state in Selenium selenium selenium

Test GWT SimplePager ImageButton enabled state in Selenium


In standard practice you should create custom component, let say Image button. I would suggest you to use ISFW which provides feature of creating custom component that can be used with annotation. In component you can specify behavior in as per AUT.


Re-writing the code sample to have better formatting.

public class ImageButton extends Component{   public ImageButtom (String loc){    super(locator);   }    @Override   public boolean isEnabled() {    //custom representation!...    return this.getAttribute("class").contains("imgdisabled");    //return this.getCssValue("background").contains("imgdisabled");    //return this.getAttribute("src").contains("imgdisabled");   }}

You can use this component like Webelement in your test page

@FindBy(locator="locator")ImageButton prevButton;@FindBy(locator="locator")ImageButton nextButton;

In your test code

page.prevButton.verifyEnabled();page.prevButton.assertEnabled();


Looking at the source code of SimplePager, it looks like they use a generator to create the css styles, where the disabled state (and the enabled state) has a css class applied to it (i m going off this https://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/user/cellview/client/SimplePager.java?r=9614).

So if you can somehow get access to the actual Resources client bundle, then you can call resources.simplePagerStyle().disabledButton() to get a string that is the css class for the disabled button, and you can then use that as a locator in selenium. That might be really tricky tho, because the jvm running your selenium test may not be able to reference the compiled GWT code (i.e., the code that runs when you debug a GWT app).

Alternatively, you can subclass SimplePager, instead of using the DEFAULT_RESOURCES client bundle, pass in your own, and then you get to control the classname used for the disabled button (by making your own Style class, which just wraps the existing one you get from the original client bundle, but add a prefix or something to the return value).

It's a bit messy, because the component is quite encapsulated, and you are trying to get at its innards.