iOS - Click on Share Facebook

Hi,

I a testing an hybrid iOS application. From webview i can share to Facebook.
When i click it, the iOS modal for share will open. How can i interact with ?

I tried clicking on it, using Xpath and on both context and it fails.

Any ideas ?
Thanks

Print page sources forall context to try to understand what is really happening.

Here is the source of NATIVE_APP context:

<?xml version="1.0" encoding="UTF-8" ?>\n
<AppiumAUT>\n
	<UIAApplication name="SDKTester" label="SDKTester" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0" x="64" y="72" width="640" height="920">\n
		<UIAWindow name="" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0" x="0" y="0" width="768" height="1024">\n</UIAWindow>\n
		<UIAWindow name="" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1" x="64" y="32" width="640" height="960">\n
			<UIATextField name="" label="" value="enter proj URL here" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/1/0" x="84" y="52" width="400" height="60">\n</UIATextField>\n
			<UIAButton name="Load Project" label="Load Project" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/1/1" x="504" y="52" width="300" height="60">\n</UIAButton>\n
			<UIAScrollView name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/1/2" x="84" y="152" width="600" height="820">\n
				<UIAWebView name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/1/2/0" x="84" y="152" width="640" height="874">\n
					<UIAStaticText name="AJR" label="AJR" value="" dom="[object Object]" enabled="true" valid="true" visible="true" hint="" path="/0/1/2/0/0" x="180" y="108" width="54" height="26">\n</UIAStaticText>\n
					<UIAStaticText name="SUBSCRIBE" label="SUBSCRIBE" value="" dom="[object Object]" enabled="true" valid="true" visible="false" hint="" path="/0/1/2/0/1" x="410" y="1118" width="108" height="20">\n</UIAStaticText>\n
					<UIAStaticText name="4" label="4" value="" dom="[object Object]" enabled="true" valid="true" visible="false" hint="" path="/0/1/2/0/2" x="78" y="394" width="14" height="28">\n</UIAStaticText>\n</UIAWebView>\n
				<UIAImage name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/1/2/1" x="679" y="638" width="5" height="14">\n</UIAImage>\n
				<UIAImage name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/1/2/2" x="990" y="967" width="14" height="5">\n</UIAImage>\n</UIAScrollView>\n
			<UIAActivityView name="ActivityListView" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1/3" x="80" y="122" width="608" height="854">\n
				<UIAActionSheet name="" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1/3/0" x="80" y="122" width="608" height="854">\n
					<UIAScrollView name="" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1/3/0/0" x="80" y="122" width="608" height="750">\n
						<UIAStaticText name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/1/3/0/0/0" x="112" y="32" width="544" height="0">\n</UIAStaticText>\n
						<UIAStaticText name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/1/3/0/0/1" x="112" y="32" width="544" height="0">\n</UIAStaticText>\n
						<UIACollectionView name="" label="" value="page 1 of 1" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1/3/0/0/2" x="80" y="122" width="608" height="750">\n
							<UIACollectionCell name="AirDrop. Tap to turn on Wi-Fi and Bluetooth to share with AirDrop." label="" value="0" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1/3/0/0/2/0" x="80" y="122" width="608" height="234">\n
								<UIAButton name="Enable AirDrop sharing" label="Enable AirDrop sharing" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1/3/0/0/2/0/0" x="95" y="163" width="124" height="124">\n</UIAButton>\n
								<UIAStaticText name="AirDrop. Tap to turn on Wi-Fi and Bluetooth to share with AirDrop." label="AirDrop. Tap to turn on Wi-Fi and Bluetooth to share with AirDrop." value="AirDrop. Tap to turn on Wi-Fi and Bluetooth to share with AirDrop." dom=""
								enabled="true" valid="true" visible="true" hint="" path="/0/1/3/0/0/2/0/1" x="249" y="199" width="398" height="53">\n</UIAStaticText>\n</UIACollectionCell>\n
							<UIACollectionCell name="" label="" value="0" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1/3/0/0/2/1" x="80" y="358" width="608" height="256">\n
								<UIACollectionView name="" label="" value="page 1 of 1" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1/3/0/0/2/1/0" x="80" y="358" width="608" height="256">\n
									<UIACollectionCell name="Message" label="Message" value="0" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1/3/0/0/2/1/0/0" x="85" y="396" width="144" height="192">\n</UIACollectionCell>\n
									<UIACollectionCell name="Mail" label="Mail" value="0" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1/3/0/0/2/1/0/1" x="229" y="396" width="144" height="192">\n</UIACollectionCell>\n
									<UIACollectionCell name="Facebook" label="Facebook" value="0" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1/3/0/0/2/1/0/2" x="373" y="396" width="144" height="192">\n</UIACollectionCell>\n
									<UIACollectionCell name="More" label="More" value="0" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1/3/0/0/2/1/0/3" x="517" y="396" width="144" height="192">\n</UIACollectionCell>\n</UIACollectionView>\n</UIACollectionCell>\n
							<UIACollectionCell name="" label="" value="0" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1/3/0/0/2/2" x="80" y="616" width="608" height="256">\n
								<UIACollectionView name="" label="" value="page 1 of 1" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1/3/0/0/2/2/0" x="80" y="616" width="608" height="256">\n
									<UIACollectionCell name="Copy" label="Copy" value="0" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1/3/0/0/2/2/0/0" x="85" y="654" width="144" height="192">\n</UIACollectionCell>\n</UIACollectionView>\n</UIACollectionCell>\n</UIACollectionView>\n
						<UIAImage name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/1/3/0/0/3" x="683" y="122" width="5" height="750">\n</UIAImage>\n
						<UIAImage name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/1/3/0/0/4" x="80" y="867" width="608" height="5">\n</UIAImage>\n</UIAScrollView>\n
					<UIACollectionView name="" label="" value="page 1 of 1" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/1/3/0/1" x="80" y="872" width="608" height="0">\n</UIACollectionView>\n
					<UIAButton name="Cancel" label="Cancel" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1/3/0/2" x="80" y="888" width="608" height="88">\n</UIAButton>\n</UIAActionSheet>\n</UIAActivityView>\n</UIAWindow>\n
		<UIAWindow name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/2" x="0" y="0" width="48" height="48">\n
			<UIAButton name="1X" label="1X" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/2/0" x="715" y="971" width="48" height="48">\n</UIAButton>\n</UIAWindow>\n
		<UIAWindow name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/3" x="64" y="32" width="640" height="960">\n</UIAWindow>\n
		<UIAWindow name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/4" x="0" y="0" width="320" height="20">\n</UIAWindow>\n
		<UIAWindow name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/5" x="-384" y="-512" width="1536" height="2048">\n
			<UIAStatusBar name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/5/0" x="-384" y="-512" width="1536" height="40">\n
				<UIAElement name="iPad" label="iPad" value="" dom="" enabled="true" valid="true" visible="false" hint="Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top"
				path="/0/5/0/0" x="-372" y="-512" width="50" height="40">\n</UIAElement>\n
				<UIAElement name="3 of 3 Wi-Fi bars" label="3 of 3 Wi-Fi bars" value="Interluders" dom="" enabled="true" valid="true" visible="false" hint="Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top"
				path="/0/5/0/1" x="-312" y="-512" width="26" height="40">\n</UIAElement>\n
				<UIAElement name="Network connection in progress" label="Network connection in progress" value="" dom="" enabled="true" valid="true" visible="false" hint="Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top"
				path="/0/5/0/2" x="-274" y="-512" width="20" height="40">\n</UIAElement>\n
				<UIAElement name="11:35" label="11:35" value="" dom="" enabled="true" valid="true" visible="false" hint="Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top"
				path="/0/5/0/3" x="356" y="-512" width="58" height="40">\n</UIAElement>\n
				<UIAElement name="Network connection in progress" label="Network connection in progress" value="" dom="" enabled="true" valid="true" visible="false" hint="Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top"
				path="/0/5/0/4" x="976" y="-512" width="20" height="40">\n</UIAElement>\n
				<UIAElement name="100% battery power, On AC Power" label="100% battery power, On AC Power" value="" dom="" enabled="true" valid="true" visible="false" hint="Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top"
				path="/0/5/0/5" x="1008" y="-512" width="134" height="40">\n</UIAElement>\n</UIAStatusBar>\n</UIAWindow>\n</UIAApplication>\n</AppiumAUT>

I see the button in the XML, i can tap it using Appium inspector with this Xpath:
//UIAApplication[1]/UIAWindow[2]/UIAActivityView[1]/UIAActionSheet[1]/UIAScrollView[1]/UIACollectionView[1]/UIACollectionCell[2]/UIACollectionView[1]/UIACollectionCell[3]

But not able to click it from the test.

Thanks

You should try to use a better selector, xpath with index are unreliable.

If you can tap it in the inspector, you can tap it in the test, it is the same.

It’s right there in your XML, so it should be accessible in Native context. What might not work is if the Facebook app is invoked as iOS testing has some limitations interacting with apps other than your UAT.

I have found XPATH to be plenty reliable, though I don’t use massively long chains like that (a single index anywhere in the chain will break it), nor do I typically use indexes in general (only when no other unique identifier is available).

Try something like this in Python:

self.driver.find_element_by_xpath("//UIACollectionCell[@name='Facebook']").click()