7

I'm trying to get some automated UI testing going on a GWT application and I'm having trouble finding a way to track UI elements.

For example, I have the following:

<g:Button text="Submit" ui:field="submitButton" enabled="true" />

which generates:

<button class="gwt-Button" type="button">Submit</button>

Its a compiler error to set both ui:field and id (id is considered deprecated anyway) so the problem is that I have no easy way to select my submit button using something like selenium.

Is anyone aware of a way I can map the

ui:field="sumbitButton"

to the generated HTML?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Dimitar
  • 2,392
  • 2
  • 19
  • 28

1 Answers1

8

After further investigation I've discovered that you can enable debugIds which are ment for testing purposes. If you add:

<inherits name="com.google.gwt.user.Debug"/>

to your *.gwt.xml file you can then set debugId on your ui elements as such:

<g:Button text="Submit" ui:field="submitButton" enabled="true" debugId="submitButton"/>

and also in the codebehind by using the ensure debug id method

submitButton.ensureDebugId("submitButton");
Dimitar
  • 2,392
  • 2
  • 19
  • 28