How to find certain components in UITests

Hello you all,
I want to find out about how the ionic code is translated into Xcode components.
I try to get insight by using print(XCUIApplication().debugDescription) in swift code.
My problem is, that the code for our buttons in the app are not easy to identify in swift for using inside the UITests.
For example:

<button name="company" class="menuItem bt big" (click)="goToPage('company')" ion-button><span class="bt_content"><i class="fas fa-{{getTypeIcon('Company')}} ico_big"></i><BR/><div class="bt_text">{{getTypeLabel('Company')}}</div></span></button>


Button, 0x60400019efa0, traits: 146029019137, {{24.0, 53.0}, {104.0, 104.0}}, label: 'Company'

I would like to identify the button not using the label, because the text is variable due to Translation / I18N…

I am new to this, so I have no clue where to start…
Thanks for your help, Anne

I also tested

<button id="company" 

but no change…


Thanks for providing the links. A lot to read :slight_smile:
I don’t get the point. Can you please explain?

My problem is, that I am testing in the compiled app via Xcode / fastlane for generating screenshots. I cannot do testing with other tools outside Xcode…

It isn’t.


No progress here, :frowning:
The above link doesn’t help me, sorry. Somehow, XCUIApplication (and linked classes) have to inspect the “DOM” of the ionic app. But how? Apple Source Code, I suppose, so no open source…

I need to know what attributes I have to put in ionic to be able to identify the component in XCUIApplication. Label and index are useless for me, because they can change during runtime :-/

It isn’t.

This cannot be 100% correct. If I make changes to my ionic html files they are not reflected inside the test in Xcode until I ran “ionic cordova build ios”…

I now found out, that I have to set the attribute aria-label to my element, which is translated into “Label” for inside the XCUIApplication. Took so much time to find out about that…