For most testing frameworks you can add a property (either in UiBinder or using element.setAttribute('debugId','myId')), and then your testing framework looks for that element. Since HTML spec says unknown attributes are silently ignored, you can just add "debugId='myId'" and then the browser ignores it, but the DOM will still allow you to select elements using it.
Hope that helps,
Sincerely,
Joseph