I usually add a custom class specific to a container or button to be able to target that specific element.
The Name property of widgets is in my opinion the way to go.
If you have a widget with
it will have the class mx-name-text3
Iterator widgets will create index classes for their entries like mx-name-index-0
Why outsystem can set id for each element, but mendix can not ?