Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to inspect element for xcode ui test like appium inspector

I am doing xcode ui test forl an app. Previously i used

appium

by which i can know the detail path of any element. Through its inspector, i can know the element name or xpath or anything.

But as per request, recently i switched to xcode ui test.

I am facing issue in this new technology. I can't get the element details.

It gives details through record but this does not work all time.

Sometimes it's too much long.

Is there any way to inspect the element like appium inspector so that
i can write my element path accordingly by myself without recording?
like image 459
Eric Ipsum Avatar asked Sep 13 '25 12:09

Eric Ipsum


1 Answers

There are total 3 ways to do this:

  1. Accessibility Inspector from Simulator: Enable it on simulator by going to Settings->General->Accessibility->Accessibility Inspector. Then hover over an element to get the accessibility Label or Identifier.

  2. Accessibility Inspector from Xcode developer tools: Right click on Xcode and open developer tool -> Accessibility Inspector.

  3. debugDescription: It prints the elements of the view, you can use it in the console like:

    XCUIApplication().debugDescription

or better:

var string = XCUIApplication().debugDescription
string = Array(arrayLiteral: string).reduce("") {$0 + ($1 == "" ? "\n" : $1)}
print(string)

Unlike Appium XCTest is more development centric, you will find it easy to work with if you set and own the accessibility of the application. You can set accessibilityIdentifier to elements and consume the values in your tests.

like image 124
itsViksIn Avatar answered Sep 16 '25 08:09

itsViksIn