Is there a way to automatically generate IDs on SWT-Widgets so UI-Tests can reference them? I know i can manually set an id using seData but I want to implement this feature for an existing application in a somewhat generic fashion.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- SWT table: how to set/get “focused” row
You can recursively assign IDs for all your shells in your application using
Display.getCurrent().getShells();
andWidget.setData();
.Setting the IDs
You have access to all the active (not disposed) Shells in your application with the method
Display.getCurrent().getShells();
. You can loop through all children of eachShell
and assign an ID to eachControl
with the methodWidget.setData();
.If the
Control
is aComposite
it may have controls inside the composite, that's the reason I have used a recursive solution in my example.Finding Controls by ID
Now, if you like to find a Control in one of your shells I would suggest a similar, recursive, approach:
With the method
findControlById()
you can easily find aControl
by it's ID.Links