skip to main |
skip to sidebar
Solution for Dynamic Id Generation in GWT Applicationsat
5:30 PM
I have been using
Selenium to create automated regression testing and compatibility testing on multiple browsers for a
GWT application. In GWT, the object id in the page (the DOM) is dynamically generated each time the page renders. Although Selenium provides a powerful mechanism for testing GWT applications, the painful part is locating the objects in the page.At first, the workaround for this was to use a locater other than the object id. Other locators include dom, xpath, link, and css.Although this workaround made testing possible, recording and tweaking the recorded commands in the script became a lengthy process. After recording the script with the dynamic objects , you have to get the name xpath and css and define the object using a different combination of these three locators.Fortunately , life was made easier when I discovered the following approach that allows you to set a static id for UI elements in the DOM:DOM.setElementProperty(uiObject.getElement(),"id", "desiredId")Using this, you do not have to rewrite the recorded code to include the locators. In addition to saving time, this method makes the recorded script both readable and maintainable.
&;
3 Comments:
Richard Rowellsaid...
3/19/2009 9:19 PM
&;
UIWidget has a getElement() method... So:foo.getElement().setId() works too and may be a touch clearer...
Anilsaid...
10/06/2009 5:06 PM
&;
Hi ,Can you post a working example here.That would be very helpfull.Thanks,Anil
pritesh
said...
4/22/2010 8:23 AM
&;
Hi ,Can you post a working example here.That would be very helpfull.Actually i am using Selenium to record the changes i have made on browser or server and to replay it on another to get the all changes i have made. But in GWT all the ids are dynamic so i am not able to replay it. So please can you give me idea to solve this issue.Thank you in Advance....Thanks,Pritesh
&;