Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping ui:field in GWT to generated code

Tags:

gwt

uibinder

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?

like image 904
Dimitar Avatar asked Mar 08 '11 03:03

Dimitar


1 Answers

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");
like image 131
Dimitar Avatar answered Sep 29 '22 12:09

Dimitar