As far as I can tell, there are two ways to set the IDs for web elements from within GWT. I need to perform Selenium automated testing, and would appreciate insight into the relative advantages of each technique.
Option 1: the generally accepted method
uiObject.ensureDebugId("idForMyElement");
This solution is well documented, and officially supported by google. However it comes with some disadvantages:
My team will have to add lines to every package's gwt.xml file like so:
<inherits name='com.google.gwt.user.Debug' />
Furthermore, the Debug class prepends "gwt-debug" to IDs by default. I realize I can change this behavior, but I don't like adding complexity where I can help it.
Option 2: use a generic setAttribute call
uiObject.getElement().setAttribute("id", "idForMyElement);
This seems cleaner to me- are there any downsides I might be overlooking?
Relevant resources: How can I set id for GWT widgets in UiBinder? https://code.google.com/p/google-web-toolkit/issues/detail?id=4176