TestProject Forum
Powered by leading experts in the test automation community

Element missing in tree - iOS native app build with Xamarin Forms

Hi,

We have an application that’s build with Xamarin Forms as a native iOS app. It seems that not all elements are found as we search in the tree of the element explorer. We expect to see an element for the + icon button; in Xamarin Forms this is defined as a label element with FontAweson unicode character to show the + icon. It is defined as clickable.

While we can click the element with the action tap on a coordinate this is not the desired way for testing since the coordinates are different for device screen sizes/orientation.

Is there another way to get to this element? Is there a reason why this element is not visible in the tree?

Thanks in advance.

Regards,
Peter

Hi @p.blommendaal,

Can you please send me the attributes of this missing element as they were defined in XCode?

Also, while the recorder is open on that page, please open this URL from another tab and send me the output:
http://localhost:8100/source

Hi @amit.yahav,

Attached the page source.

We build the app with Xamarin Form, so there’s no XCode attributes. In Xamarin Forms the attribute of the label is:

Text = f067

Where f067 is the unicode for the + icon in FontAwesome:

https://fontawesome.com/icons/plus?style=regular

Where iv:FontAwesome is an extension of Label

{

“value” : “<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<XCUIElementTypeApplication type=“XCUIElementTypeApplication” name=“K2 Apps” label=“K2 Apps” enabled=“true” visible=“true” x=“0” y=“0” width=“414” height=“736”>\n <XCUIElementTypeWindow type=“XCUIElementTypeWindow” enabled=“true” visible=“true” x=“0” y=“0” width=“414” height=“736”>\n <XCUIElementTypeOther type=“XCUIElementTypeOther” enabled=“true” visible=“true” x=“0” y=“0” width=“414” height=“736”>\n <XCUIElementTypeOther type=“XCUIElementTypeOther” enabled=“true” visible=“true” x=“0” y=“0” width=“414” height=“736”>\n <XCUIElementTypeOther type=“XCUIElementTypeOther” enabled=“true” visible=“true” x=“0” y=“0” width=“414” height=“736”>\n <XCUIElementTypeOther type=“XCUIElementTypeOther” enabled=“true” visible=“true” x=“0” y=“0” width=“414” height=“736”>\n <XCUIElementTypeOther type=“XCUIElementTypeOther” enabled=“true” visible=“false” x=“0” y=“0” width=“331” height=“736”>\n <XCUIElementTypeOther type=“XCUIElementTypeOther” enabled=“true” visible=“false” x=“0” y=“0” width=“331” height=“736”>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“” name=“” label=“” enabled=“true” visible=“false” x=“21” y=“45” width=“20” height=“20”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“Peter Blommendaal” name=“Peter Blommendaal” label=“Peter Blommendaal” enabled=“true” visible=“false” x=“62” y=“36” width=“253” height=“20”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“Demo” name=“Demo” label=“Demo” enabled=“true” visible=“false” x=“62” y=“55” width=“253” height=“20”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“” name=“” label=“” enabled=“true” visible=“false” x=“23” y=“110” width=“15” height=“21”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“Apps” name=“Apps” label=“Apps” enabled=“true” visible=“false” x=“62” y=“110” width=“40” height=“20”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“” name=“” label=“” enabled=“true” visible=“false” x=“23” y=“158” width=“15” height=“21”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“Drafts” name=“Drafts” label=“Drafts” enabled=“true” visible=“false” x=“62” y=“158” width=“48” height=“20”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“” name=“” label=“” enabled=“true” visible=“false” x=“21” y=“206” width=“20” height=“21”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“Tasks” name=“Tasks” label=“Tasks” enabled=“true” visible=“false” x=“62” y=“206” width=“44” height=“20”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“” name=“” label=“” enabled=“true” visible=“false” x=“21” y=“254” width=“20” height=“21”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“Notifications” name=“Notifications” label=“Notifications” enabled=“true” visible=“false” x=“62” y=“254” width=“97” height=“20”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“” name=“” label=“” enabled=“true” visible=“false” x=“18” y=“327” width=“25” height=“21”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“Switch Project” name=“Switch Project” label=“Switch Project” enabled=“true” visible=“false” x=“62” y=“327” width=“110” height=“20”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“” name=“” label=“” enabled=“true” visible=“false” x=“21” y=“375” width=“20” height=“21”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“Sync” name=“Sync” label=“Sync” enabled=“true” visible=“false” x=“62” y=“375” width=“38” height=“20”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“” name=“” label=“” enabled=“true” visible=“false” x=“21” y=“423” width=“20” height=“21”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“Settings” name=“Settings” label=“Settings” enabled=“true” visible=“false” x=“62” y=“423” width=“64” height=“20”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“” name=“” label=“” enabled=“true” visible=“false” x=“26” y=“471” width=“10” height=“21”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“About” name=“About” label=“About” enabled=“true” visible=“false” x=“62” y=“471” width=“46” height=“20”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“” name=“” label=“” enabled=“true” visible=“false” x=“21” y=“519” width=“20” height=“21”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“Logout” name=“Logout” label=“Logout” enabled=“true” visible=“false” x=“62” y=“519” width=“53” height=“20”/>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n <XCUIElementTypeOther type=“XCUIElementTypeOther” enabled=“true” visible=“true” x=“0” y=“0” width=“414” height=“736”>\n <XCUIElementTypeOther type=“XCUIElementTypeOther” enabled=“true” visible=“true” x=“0” y=“0” width=“414” height=“736”>\n <XCUIElementTypeNavigationBar type=“XCUIElementTypeNavigationBar” name=“Drafts” enabled=“true” visible=“true” x=“0” y=“20” width=“414” height=“44”>\n <XCUIElementTypeButton type=“XCUIElementTypeButton” name=“menu” label=“menu” enabled=“true” visible=“true” x=“12” y=“20” width=“43” height=“44”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“Drafts” name=“Drafts” label=“Drafts” enabled=“true” visible=“true” x=“61” y=“20” width=“341” height=“44”/>\n </XCUIElementTypeNavigationBar>\n <XCUIElementTypeOther type=“XCUIElementTypeOther” enabled=“true” visible=“true” x=“0” y=“0” width=“414” height=“736”>\n <XCUIElementTypeOther type=“XCUIElementTypeOther” enabled=“true” visible=“true” x=“0” y=“0” width=“414” height=“736”>\n <XCUIElementTypeOther type=“XCUIElementTypeOther” enabled=“true” visible=“true” x=“0” y=“64” width=“414” height=“672”>\n <XCUIElementTypeOther type=“XCUIElementTypeOther” enabled=“true” visible=“true” x=“0” y=“64” width=“414” height=“672”>\n <XCUIElementTypeImage type=“XCUIElementTypeImage” name=“businessman.png” enabled=“true” visible=“true” x=“67” y=“289” width=“280” height=“162”/>\n <XCUIElementTypeStaticText type=“XCUIElementTypeStaticText” value=“Nothing to find here” name=“Nothing to find here” label=“Nothing to find here” enabled=“true” visible=“true” x=“131” y=“490” width=“151” height=“20”/>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n </XCUIElementTypeWindow>\n <XCUIElementTypeWindow type=“XCUIElementTypeWindow” enabled=“true” visible=“false” x=“0” y=“0” width=“414” height=“736”>\n <XCUIElementTypeOther type=“XCUIElementTypeOther” enabled=“true” visible=“false” x=“0” y=“0” width=“414” height=“736”>\n <XCUIElementTypeOther type=“XCUIElementTypeOther” enabled=“true” visible=“false” x=“0” y=“0” width=“414” height=“736”/>\n </XCUIElementTypeOther>\n </XCUIElementTypeWindow>\n</XCUIElementTypeApplication>\n”,
“sessionId” : “34FC348E-50E0-4383-BB70-1633D21567F5”
}

Could not attach the json file, so posted as code now.

Hi @p.blommendaal,

Thank you for providing me all this information.
The XML output that I asked you to send me, is the parsed DOM of this application that we are getting from Appium. I can see that your element is not there as well.
Besides that, I can also see that some values are not displayed correctly (I think it’s related to the fact that it’s Font Awesome).

I will investigate it a bit more and get back to you with an answer.

Kind regards,
Amit

Hi @amit.yahav,

I’ve tested it with regular text instead (Add) of a unicode character to rule out a unicode issue but that doesn’t change the result, the label is still not visible as an element in the Navigationbar element:

@amit.yahav the same Xamarin Forms code generated for Android native is of course different, and there we have no problems finding the element.

Hi @p.blommendaal,

One of our mobile developers spent some time on it trying to figure out what is going on with your application.

He tried to build a label using the font awesome icon, and even this doesn’t work well with Swift. According to him, Using Xamarin and FontAwsome is not a native way to develop normal iOS apps. If are doing it, you should know that XCUITest don’t see the element.

Hope it make sense :slight_smile:

Have a great weeked!
Amit

Hi @amit.yahav,

Thanks for the input. We’ve researched a bit and our developer found for Xamarin you can set the AutomationId and AutomationProperties.Name and some more: Xamarin Form Automation Properties

Now the label elements in the navigationbar can be found easily via the device viewer and element explorer.

Regards,
Peter

1 Like