Tuesday, February 6, 2024

Re: Autogenerate IDs for eatch widget

Nothing that I am aware of. Also I think you need some naming conventions for your debug ids anyways which makes automatic generation difficult. Otherwise it will be difficult to write and later understand the UI test if debug ids are generic like input-0, input-1, input-2. You also need to verify if any of your widgets might already use an ID because of CSS styling or element selection using document.querySelector(). This would break if you override the ID.

Every widget has onAttach/onDetach/onLoad/onUnload methods you can override. You could copy GWT's Widget class into your own source code (keep the original package) or give all your widgets a common super class and adjust the code to set a debug id. But I think you will quickly realize that generating stable but unique debug IDs on that abstract level will be difficult. Also widgets usually want debug ids on some internal meaningful elements as well, which you do not know at that abstract level.

-- J.


Sebastian Bota schrieb am Dienstag, 6. Februar 2024 um 09:15:33 UTC+1:
Hello everyone.
I have a GWT application and for testing purposes ( using external UI testing tools ) i need that each widget to have an ID set. i know it is possible by using ensureDebugID(), but this approach will take forever to change in my project and is very error prone.

So my question, is there any way i can set an ID to each widget automaticly ?
Perhaps some kind of hook, so when a widget is added to DOM i can set the ID.
This id will be only used in test, not in production.

Thank you very much for any suggestions.
BR,
Sebastian

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/c468fa99-0732-47b6-8f90-e57367b2a678n%40googlegroups.com.

No comments:

Post a Comment