将GWT中的ui:字段映射到生成的代码 [英] Mapping ui:field in GWT to generated code

查看:113
本文介绍了将GWT中的ui:字段映射到生成的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在GWT应用程序上进行一些自动化UI测试,并且无法找到跟踪UI元素的方法。

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>

这是一个编译器错误,用于设置ui:field和id(id始终被视为弃用)问题是我没有简单的方法来选择使用像硒这样的提交按钮。

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"

到生成的HTML?

to the generated HTML?

推荐答案

经过进一步的调查后,我发现你可以启用debugIds,这些都是用于测试的目的。如果您添加:

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"/>

添加到您的* .gwt.xml文件中,然后您可以在您的UI元素上设置debugId: / p>

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"/>

以及使用确保调试ID方法的代码隐藏内容

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

submitButton.ensureDebugId("submitButton");

这篇关于将GWT中的ui:字段映射到生成的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆