Questions tagged [xcode-ui-testing]

UI Testing in Xcode was introduced in Xcode 7, allowing a developer to write UI tests in Swift/Objective-C. The primary method of interacting with an app is via an instance of XCUIApplication. Tests run via the Product > Test menu item or from the editor, with results displayed in the Test navigator. Not to be confused with the older UI Automation which used UIATarget and JavaScript.

1160 questions
26
votes
3 answers

Replicate pull to refresh in XCTest UI testing

I am trying to replicate a pull to refresh on a UITableView using the new Xcode UI testing framework in Xcode 7 (beta 3) My current approach is dragging from the table to whatever element below the table I can find. This works when there is a fixed…
Kevin
  • 16,696
  • 7
  • 51
  • 68
25
votes
2 answers

UITesting, XCTest current ViewController Class

Simple problem. I got button which perform segue to next view controller. I want to write UI XCTest to tell me did it open view controller i wanted.
Dejan Zuza
  • 359
  • 1
  • 6
  • 14
25
votes
2 answers

Accessing the host app code from the Xcode 7 UI Test target

I am developing an iOS project, and I need to access to the codes of the host app from the UI test target, but I found that it shows link error: undefined symbol when I tried to. I found the test host and bundle loader for this target are all empty,…
user412759
  • 2,375
  • 3
  • 22
  • 20
25
votes
6 answers

How to tell which device I'm on in Xcode UI Testing?

While an Xcode UI Test is running, I want to know which device/environment is being used (e.g. iPad Air 2, iOS 9.0, Simulator). How can I get this information?
Senseful
  • 86,719
  • 67
  • 308
  • 465
25
votes
1 answer

Connecting external framework to UI unit testing target, iOS

So, i have already existing project at my hands and i’m trying to create some UI tests by using this new fancy UI Testing Bundle provided by apple. The problem is that test target doesn't have access to any external framework (and i need to do some…
BigSzu
  • 271
  • 2
  • 8
24
votes
5 answers

Is there a way to find if the XCUIElement has focus or not?

One of my screen has multiple text fields, I can land to this screen from different other screens. In each case I am making one or another text field as first responder. I am not able to write test to determine whether the desired textField has…
Sandy
  • 3,021
  • 1
  • 21
  • 29
24
votes
6 answers

How can you see the XCUIElement tree?

Background: I'm experimenting with ui level testing in iOS 9.0 with XCode GM. Question: Is there a command in XCode GM that will allow you to see a 'tree' of accessible elements and their relationships? Something similar to the 'page' command in…
Joe Susnick
  • 6,544
  • 5
  • 44
  • 50
24
votes
4 answers

How do I reset the application data after each test with Xcode 7 UI Testing?

Apple introduced in Xcode 7 new UI Testing but I have a struggle whenever the tests launches the app, it starts with data that the application had before. It means tests cannot be independent and can be influenced by other tests. It is not possible…
Tomáš Linhart
  • 13,509
  • 5
  • 51
  • 54
22
votes
3 answers

addUIInterruptionMonitor(withDescription:handler:) not working on iOS 10 or 9

The following tests works fine on iOS 11. It dismisses the alert asking permissions to use the locations services and then zooms in in the map. On iOS 10 or 9, it does none of this and the test still succeeds func testExample() { let app =…
Titouan de Bailleul
  • 12,920
  • 11
  • 66
  • 121
22
votes
5 answers

Assertion Failure: UI Testing Failure - Failure fetching attributes for element

When UI testing in Xcode(7.2 and 7.3), my tests sometimes fail with a rather generic error: Assertion Failure: UI Testing Failure - Failure fetching attributes for element I tend to get this error when calling .hittable or .tap() on an element but…
Gordonium
  • 3,389
  • 23
  • 39
22
votes
3 answers

Swift UI Testing Access string in the TextField

I am using the UI Test Case class integrated in Xcode and XCTest to test app UI. I want to test something like this: app = XCUIApplication() let textField =…
leoluo
  • 249
  • 1
  • 2
  • 8
21
votes
3 answers

UI Testing Xcode 7- can't access element within subview

I'm trying to access an element within a subview and I'm finding it impossible to do so. The hierarchy being: View Controller: View tempView userEnterView zipCodeEntered I want to access the zipCodeEntered text field. I have an accessibility…
sebradloff
  • 385
  • 1
  • 3
  • 10
21
votes
5 answers

Xcode UI Testing - typing text with typeText() method and autocorrection

I've got a test like below: let navnTextField = app.textFields["First Name"] let name = "Henrik" navnTextField.tap() navnTextField.typeText("Henrik") XCTAssertEqual(navnTextField.value as? String, name) Problem is that by default my iPhone…
Apan
  • 1,027
  • 2
  • 10
  • 27
21
votes
4 answers

Xcode 7 UI Testing Failure: App accessibility isn't loaded

While I'm running UITests on Simulator with Xcode 7, it's failed when invoking XCUIApplication().launch() with App accessibility isn't loaded
Quanlong
  • 24,028
  • 16
  • 69
  • 79
21
votes
2 answers

XCUIElement - Obtain Image value

I have an variable that's of type .Image and class XCUIElement. Something like this: var image = app.descendantsMatchingType(.Image).elementAtIndex(0) Is there a way I can extract the actual image so I can compare it to another image? I've tried…
SalmonKiller
  • 2,183
  • 4
  • 27
  • 56
1 2
3
77 78