skip to main |
skip to sidebarSolution 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.
&;
&;