Questions tagged [xcode-ui-testing]

1

votes
1

answer
124

Views

UITests failing when run in group but succeed when run independently

I'm currently working on a project with many asynchronous code and I'm writing the UITests for this project. During the development I run them one by one but never in a group. So I thought the tests are succeeding. But when testing them all together most of them are failing. I implemented the setup...
Tom Kuschka
1

votes
1

answer
33

Views

XCTest: Is there a way to find a view of any type by ID in UI tests?

In XCTest there's a way to get all UI elements by type, and then filter by accessibilityIdentifier like: app.buttons[someID] But what if I don't know the type of the view? If I'm looking for a UIView, I can write: app.otherElements[someID] but this excludes UIButton views. I can implement this by ca...
battlmonstr
1

votes
0

answer
53

Views

application.textViews[“Personal Information”] does not give me a textview in UI Test case

Recently I have started learning basics of UITest case writing. I am trying to get a textview like this. I am not sure what I am doing wrong here. let taskPersonalInformationTextView = application.textViews['Personal Information'] taskPersonalInformationTextView.tap() taskPersonalInformationTextV...
Anil Kukadeja
1

votes
0

answer
158

Views

Testing rotation on multiple devices

I am wanting to create a testing routine, which will create a screenshot from my most important screens. I will then view these screenshots separately to make sure I didn't mess things up. My question is how do I properly initiate a rotation throughout a testing function. For some reason, when I tin...
Joseph
1

votes
0

answer
158

Views

How to use GPX file for UI Tests only

I'm trying to use a GPX file, for simulating my location when I run UI Tests. I have selected the GPX file under 'Test Location'. But it's not working. I just get an error, which tells me 'Location not available'. I know, I can go into Run -> Debug and then activate 'Allow Location Simulation' and t...
Grumme
1

votes
0

answer
48

Views

Why when launching Xcode UITests takes too much time with Network Link Conditioner enabled?

When I run my UITests on my iPhone 6s with Network Link Conditioner enabled (very bad network setting and connected to my mac), Xcode takes too much time to start the tests. I understand that the interaction within my app will be slower because of the link conditioner, but I don't understand why tak...
rgkobashi
1

votes
0

answer
110

Views

Converting HTML to String is crashing when running UITests

I'm trying to convert HTML response from RSS Feed to String and display in UILabel. Here is my code in String extension: var html2AttributedString: NSAttributedString? { guard let data = data(using: String.Encoding.utf8) else { return nil } do { return try NSAttributedString(data: data , options: [N...
Bernard
1

votes
1

answer
92

Views

Cucumberish Issue : Step not implemented

I am doing XCUI Testing using the Cucumberish Framework. Sometimes when the test case starts it halts at the very first step This is intermittent. Most of the times it runs seamlessly. I am are very confused what's going wrong. I tried hard but can't get a stable solution.
Vikas
1

votes
0

answer
162

Views

Getting wrong count of UICollectionView in XCTestCase

Now problem is in my one of the screen UICollectionView is returning me a wrong count. Since I went through couple of questions already I didn't find those answers helpful to me. Here is my code below Solution 1 for element in app.collectionViews.cells.allElementsBoundByIndex { element.swipeLeft()...
Anil Kukadeja
1

votes
1

answer
493

Views

Write custom strings to logs during UI testing / unit testing

Is there any way to add text to the logs of a test? Neither NSLog nor Swift.print seem to log any remaining text to any logs that I can see, when running UI and/or unit testing in Xcode 9. I am running on device. Whatever I do, I do not see any NSLog/print stuff in Report navigator, clicking on the...
Jonny
1

votes
0

answer
86

Views

Asynchronous wait failed for XCUI tests:Exceeded timeout of 60 seconds, with unfulfilled expectations

let button = app.buttons['BACK TO DASHBOARD'] let exists = NSPredicate(format: 'exists == 1') expectation(for: exists, evaluatedWith: button) { // If the button exists, also check that it is enabled if button.isEnabled { button.tap() return true } else { // Do not fulfill the expectation...
Mohamed Rasool
1

votes
2

answer
180

Views

How to query “Main Window” in iOS UI tests?

At one point in my tests I need to interact with views that are inside Main Window. When I do a po app.windows, I get this: Find: Target Application 0x1c40d7680 Output: { Application, 0x1c4389170, pid: 4765, {{0.0, 0.0}, {375.0, 667.0}}, label: 'Mercedes PRO [testb2b]' } ↪︎Find: Descendants matc...
lagoman
1

votes
0

answer
208

Views

How can I UITest the change of the image of a UIButton in Swift?

When I tap a UIButton, the image should change to reflect its new state (e.g. Record -> Pause etc). In my XCode UITest function, how do I interrogate the buttons current image after the tap to assert that its image has changed correctly to the correct image's .png file?
Robert
1

votes
2

answer
301

Views

“Neither element nor any descendant has keyboard focus” when running XCTestCase in a real iPhone

I'm trying to run a UI test case where there are two input fields exists. Following is my code let usernameTextField = app.webViews.otherElements['Identity Server'].textFields['Username'] let passwordField = app.webViews.otherElements['Identity Server'].secureTextFields['Password'] _ = usernameTextF...
AnujAroshA
1

votes
0

answer
87

Views

XCTest can't find the test bundle

I am trying to write XCUItests for an iOS app that is build using Appcelerator-Alloy. I opened the xcodeproject from the build folder, added a UI test bundle and then a UI test class (it has an autogenerated test method). I followed this tutorial: https://blog.novoda.com/getting-started-with-xcuites...
Naman
1

votes
0

answer
33

Views

How to UI test workflows that uses controllers provided by the system

I wanna UI test an app workflow that calls, beside others, an UIDocumentPickerViewController. I tried to record this workflow in Xcode, but when i reach this controller i get an error message saying Timestamped Event Matching Error: Failed to find matching element I there a way to pass such controll...
Tobe
1

votes
1

answer
42

Views

Play audio file as microphone input using AudioKit - for iOS simulator dictation testing

I am looking for a way of play an audio file and have it as input for the iOS simulator microphone. I am creating a bunch of UI tests for an iOS app that uses dictation (speech-to-text) and I didn't find a way of doing it using applications like SoundFlower, etc as I want to run in the CI and bypass...
Fabio
1

votes
1

answer
82

Views

Waiting for focus using predicate on XCUIElement [duplicate]

This question already has an answer here: Is there a way to find if the XCUIElement has focus or not? 5 answers I'm currently using NSPredicate to wait for conditions on XCUITest elements, as follows: class func waitForCondition(condition: String, element: XCUIElement) -> Bool { let predicate = NSP...
arvere
1

votes
1

answer
65

Views

How to tap on a specific point on Xcode simulator

I work with swift's UI testing, and I need to be able to tap a specific point on my app. I followed the answers from How to tap on a specific point using Xcode UITests, which worked great for testing on iPad. However, when doing the same on the simulator nothing happens. No errors, the program simpl...
Parakit
1

votes
0

answer
19

Views

UITest cannot find element when contained in Modal View Controller

I have an application that has the following structure: A root UIViewController (A). Inside it is a UINavigationController (B) that pushes and pops different UIViewControllers (C). Sometimes, the UIViewControllers (C) inside the UINavigationController (B) will present Modal UIViewControllers (D). Wh...
Danny Bravo
1

votes
0

answer
46

Views

Cannot access swift object's function from objc even adding the @objcMembers tag while running UI testing

I'm working on UI testing code for iOS app recently, my UI testing code is using swift, but the project itself has some objective-c code, and I create a singleton object for launch arguments settings, which also written by swift, so I adding the @objcMembers tag to the class. but while running the U...
Seraph J. Lin
1

votes
0

answer
121

Views

Xcode UI Test Keyboard and MenuItems Buttons Broken

I wrote some UI tests for Xcode that have been working for years. I tried running them again on Xcode 10.1 and iOS 12.1 and the same error is coming up in different parts of the code. 'NSInternalInconsistencyException', '-[XCAXClient_iOS interruptingUIElementsAffectingSnapshot:] called with nil inpu...
Alex
1

votes
0

answer
32

Views

UITest MacOS Click to MenuBar app not work

I try create simple UITest for my MacOS MenuBar app. Test case: Just click to app icon, click to 'Customize stations ...' then check stations more than 2 exist in table. func testStationsExistInTable() { let app = XCUIApplication() let menuBarsQuery = app.menuBars menuBarsQuery.children(matching: ....
memoris
1

votes
0

answer
24

Views

Xcode UI test: How can I check something in the UI while a gesture is in progress?

My app supports a kind of dragging/panning gesture: The gesture begins after a short delay when the user presses the screen with one finger, and keeps pressing. The user can then drag/pan pan around the screen while keeping the finger on the screen. The gesture ends when the user lifts the finger. W...
herzbube
1

votes
0

answer
21

Views

Performing UIAccessibilityCustomAction from UITests

I've got a subclass of UIView, let's say it's class DemoView: UIView { } which contains UILabel and UIButton. I needed to group it and add UIAccessibilityCustomAction so I've overriden the var accessibilityElements: [Any]? and used union to connect both elements. I've also assigned 'Users' string to...
codddeer123
1

votes
0

answer
21

Views

iOS UI test target is missing entitlement icloud-services

I have an app that uses iCloud. This works fine. I now tried to write a UI test that checks first if the iCloud account is accessible, i.e. that the user is logged in to iCloud and iCloud is enabled for the app. To do so, I tried to call (CloudKit is imported) let container = CKContainer(ident...
Reinhard Männer
1

votes
3

answer
595

Views

How to check what screen the application is currently running?

Is there a way to check directly what screen an XCUIApplication is currently running / is visible on screen? I want to be able to XCTAssert that the application is currently displaying screen 'X'. I was thinking I might just create a hidden UIElement or button specific to each screen and then assert...
atgrubb
1

votes
2

answer
641

Views

XCode 7 UI Testing - Actions Available

One thing Apple talked about when introducing Xcode 7's UI testing on iOS 9 was that everything came from accessibility. I'm wondering if anyone knows how to find out if an element has 'Actions Available' on it. I have a UITableView where some cells can be deleted by swiping from right to left revea...
RyanJM
1

votes
1

answer
87

Views

UI XCTestCase on IO9 not playing back

I have an older project that I am trying to add XCTest cases for UI testing. I compile the project using iOS9 SDK, i use the iOS9 Simulator. I can record UI Tests in Xcode 7 just fine. I can also create a sample Xcode 7/iO9 project, add UI tests, record one, and play it back, and it works fine. But,...
Frank Mantek
1

votes
1

answer
58

Views

xcode7 ui testing: how does xcode determines that method is Test

How does xcode determines that method is uiTest? Look at the pic:
Che
1

votes
1

answer
1.2k

Views

Xcode 7 UI Testing - Assertion Failure: UI Testing Failure - Timeout waiting to launch Target Application

I'm running close to 30 Xcode 7 UI test scripts and my tests fail 10 - 15 scripts in with this error: Assertion Failure: UI Testing Failure - Timeout waiting to launch Target Application 0x1004c5400 :0: error: -[Name_Tests test_FormName] : UI Testing Failure - Timeout waiting to launch Target Applic...
James Goe
1

votes
1

answer
2.3k

Views

Xcode UI Testing (Objective C): find element by Accessibility Label

My app under test has an element (a UIAStaticText) which has accessibility enabled (with the accessibility-label 'Progress'). Accessing this element using Swift is easy and well-documented. But my app's source is in Objective C. How do I access this element using Xcode UI Testing and Objective C?
Vish
1

votes
1

answer
642

Views

Xcode UI Testing Error keyboard

XCUIApplication *app = [[XCUIApplication alloc] init]; [app.buttons[@'Committee'] tap]; [app.buttons[@'Login'] tap]; [app.buttons[@'Add Presenter'] tap]; XCUIElement *nameTextField = app/*@[email protected]*/.textFields[@'Name']/*[['.scrollViews.textFields[@\'Name\']','.textFields[@\'Name\']'],[[[-1...
Walee
1

votes
2

answer
963

Views

iOS UI Testing with Mocks and Screenshots

I want to setup a UI testing system with iOS that allows me to test just a single ViewController OR UIView such that a) I can provide it with Mocked data b) I can render its view to the simulator c) I can take a Screenshot of it, save it to disk and aggregate the snapshots (like snapshot) Why? 1) T...
John Twigg
1

votes
1

answer
570

Views

Xcode-Ui-Test: Can i specify a particular test that i want to run from terminal

i wrote a ui test in new xcode 7 with swift 2.0. I have a script, that i run from terminal to execute the ui-tests. Here is the command line: xcodebuild -workspace App.xcworkspace -scheme 'App-Scheme' -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.1' test The problem is...
emoleumassi
1

votes
1

answer
1.2k

Views

How to use a dynamic identifier to check for values of UI elements?

I am getting started with UI testing with Xcode and I am trying to check for the value of a UITextField. I can easily do this by XCTAssertTrue(app.staticTexts[@'value of string'].exists); I do, however, want to do the very same thing with dynamic content. Ideally, I would need something like NSStri...
Sebastian Hojas
1

votes
1

answer
824

Views

Xcode UI Testing with multiple predicates

Xcode 7 introduces new UI Testing tools. I want to filter an element that matching more than one query. For instance. A table with cells that each cell has 4 labels inside them. I want to find element that contain. label 1 text = 'A' label 1 text = 'B' label 1 text = 'C' label 1 text = 'D' Framew...
Swift Hipster
1

votes
1

answer
697

Views

Ui Testing failure - No matches found for “CREATE PIN” Navigationbar

var pcheck = XCUIApplication().navigationBars['CREATE PIN'].staticTexts['CREATE PIN'].label if pCheck == 'CREATE PIN' { app.childrenMatchingType(.Window).elementBoundByIndex(0).childrenMatchingType(.Other).element.childrenMatchingType(.Other).element.childrenMatchingType(.Other).element.childrenMatc...
TallGamer
1

votes
2

answer
416

Views

XCUITest and dynamically generated views

For XCUITest related work, how can I access classes of my app? I have a set of screens that are dynamically generated (in this case, onboarding questions I ask the user across multiple view controllers) off a JSON structure I control server-side. I won't know what content the JSON API will produce,...
Joey
1

votes
3

answer
1.4k

Views

UI Test (XCTest) with localized app.staticTexts

I am writing UI tests for my app that uses an UIWebView for its content. When buttons in the webview are pressed, it writes the test case as following: func testExample() { let app = XCUIApplication() app.staticTexts['Log In'].tap() } The problem here is that if the app is in a different localizatio...
Paul Peelen

View additional questions