0

Ex:- This is my original String “I agree to the Terms and Conditions and Privacy Policy”.

The “Terms and Conditions” string in the above line is not a link, it exists as part of whole ‘Label’ and I want to tap on specific “Terms and Conditions”.

I applied tap gesture event to "Terms and Conditions" String in label. When the User clicks on the "Terms and Conditions" string it navigates to another screen.

--> I'm unable to tap on "Terms and Conditions" in my Test cases(not working).

Suneel IOS
  • 71
  • 6

2 Answers2

1

Without a screenshot of your view hierarchy this is hard to solve. A very unstable way to solve this is to use coordinates: How to tap on a specific point using Xcode UITests

Reijer
  • 98
  • 1
  • 9
  • It could be stable, if you implement label-coordinates-finding method and send these coordinates to the tapping method :-) Not the most elegant solution, but only possible with xctest tapping. – Václav Mar 13 '19 at 20:29
1

The short answer would be no, you can't tap on specific word from string, using default XCTest methods.

The long answer is - it is possible by finding coordinates of your label in relation to your app and tapping on certain point of your app that matches the position of the word on the label, you want to tap.

Václav
  • 990
  • 1
  • 12
  • 28