每次在硒中GWT id元素都在变化 [英] GWT id element is changing every time in selenium

查看:162
本文介绍了每次在硒中GWT id元素都在变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

selenium.click("gwt-uid-204"); // this is recorded from Selenium IDE

我点击我的(gwt)java应用程序中的复选框。 gwt-uid正在改变时间,所以如果id改变了,那么我的元素在我的应用程序中找不到。正则表达式不适用于我,我不确定我做错了什么。感谢您的帮助

I am clicking the check box in my (gwt) java application. The gwt-uid is changing ever time, so if the id changed then my element is not found in my apps. The regular expression is not working for me and I am not sure what I am doing wrong. Thanks for your help

selenium.click("gwt-uid-[0-9]);

我使用的是selenium 1.0.3,Java

I am using selenium 1.0.3, Java

推荐答案

许多GWT元素都带有ensureDebugId(UIObject上的方法),允许你显式地将Ids设置为元素进行测试和调试,还需要继承模块

Many GWT elements comes with ensureDebugId (method on UIObject) to allow you to explicitly set Ids to elements for testing and debugging purpose. You also need to inherit the module

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

来使它工作,这样做的好处是,你可以通过在prod模式编译过程中删除继承的模块来从生产部署中删除跟踪,因此不会将代码更改为删除不必要的ID。

to make it work. The advantage of this is, you can remove the trace from the production deployment by removing the inherited module in during prod mode compile. Hence there wont be code changes to remove unnecessary Ids.

这篇关于每次在硒中GWT id元素都在变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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