GWT id element is changing every time in selenium GWT id element is changing every time in selenium selenium selenium

GWT id element is changing every time in selenium


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

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.


You can do it in 3/4 ways Can check this link : 3 ways of dealing with GWT dynamic element Idswhich talks about 3 different ways of assigning a static id to your GWT elements.

Also, You can write a custom javascript method which will fetch all the ids dynamically. Then you can process those ids for selenium actions.


There are two possible solutions. The first is to tell Se that you are using a regex by saying regex:gwt-uid-[0-9]. As you have it there it is looking the and element whose name or id is that literal string.

The other solution is to turn on static id's for things which I discuss in http://element34.ca/blog/google-web-toolkit-and-id.

-adam