Mapping ui:field in GWT to generated code

爷,独闯天下 提交于 2019-12-21 04:27:13

问题


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?


回答1:


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");


来源:https://stackoverflow.com/questions/5228153/mapping-uifield-in-gwt-to-generated-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!