I’m running test automation software that will rely on “id” tags to recognize controls.
I’m developing in java on eclipse using the GWT plugin and have tried using both of the below methods to set the id tag for a button “add”.
add.setId(“addId”);
DOM.setElementAttribute(add.getElement(), “id”, “addId”);
neither of these are modifying the id property correctly. Have you had this problem before or do you know a workaround?
Thank you for any help!
Jerry
If I remember correctly, several browsers (or probably just Internet Explorer) won’t let you set a DOM element’s ID after it has been appended to the DOM. This limitation would be there even if you are directly doing this hand coded javascript. The browser won’t show any error on setting id attribute but won’t update the attribute either.
So you need to set the ID before appending the element to the DOM.
EDIT
From discussion below it appears that you were assuming that setting ID on Button widget’s DOM element will set the ID on a
<input type="button">DOM element. But this assumptions is not proving to be correct because Button widget wraps the<input type="button">DOM element in other DOM elements (like table or div).EDIT
You may want to try
Button.wrap(element)method if you want to customize theinput type="button">element. First create (DOM.createButton()) or locate a DOM element, set it’s id, and wrap it usingButton.wrap(element)