xcode-ui-testing

Attempting to run multiple tests using Xcode's new UI testing fails

六眼飞鱼酱① 提交于 2019-12-22 10:17:35
问题 When I try to run multiple UI tests at the same time in the new Xcode beta, it fails after the first test, with the error "UI Testing Failure: App state is still not terminated" for each test after the first. Anyone got a fix for this? 回答1: I have faced the same issue. It seems that, at least in my case, application had never been terminated. I solved it by putting the following statement in the setUp() method: continueAfterFailure = false This should stop a running test process after first

How to access the App Delegate from a UI Test?

这一生的挚爱 提交于 2019-12-22 10:06:53
问题 I want to access a particular property router from the App Delegate of the launched app during a UI Test, but I can't figure out if this is possible or not. I have tried: let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate let router = appDelegate.router but this gives a failure and won't even build. I am using @testable on my project module. Any ideas? 回答1: Xcode UI testing is designed such that the test code can only see what a user can see, so no objects from the

How do I turn off the Accessibility Inspector in the iOS 9 simulator?

六眼飞鱼酱① 提交于 2019-12-22 09:58:08
问题 The accessibility inspector is turned on by my KIF tests (apparently it's necessary for KIF to work.) Problem is, its window occludes controls some subsequent UI tests need to tap on and those tests fail. How can I turn the Accessibility Inspector off when my KIF tests are done with it so my UI Tests can run? (Turning it off "manually" from the simulator's Settings app is not a solution—I'm looking for something I can call from code, set in the target or...?) 回答1: It is not on by default. You

Xcode 7 UI Testing with Cocoapods fails on device

梦想的初衷 提交于 2019-12-22 04:29:18
问题 When trying to run my UI Tests on my device I get the error: XCTRunner[1476:104021] The bundle “AppUITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle. 2015-11-23 20:58:53.903 XCTRunner[1476:104021] (dlopen_preflight(/var/mobile/Containers/Bundle/Application/FAC2EFB2-92C6-4668-96A7-C77CC5C4AE87/AppUITests-Runner.app/PlugIns/AppUITests.xctest/TrueMostUITests): Library not loaded: @rpath/UIColor_Hex_Swift.framework/UIColor_Hex_Swift

Unable to tap (x,y) coordinate in landscape mode

拜拜、爱过 提交于 2019-12-21 20:28:36
问题 In Xcode 8 / Swift 3, using the coordinate(withNormalizedOffset: CGVector) function to interact with an XCUIElement appears to work only in portrait mode. To test this functionality, I created a single screen project with a button centered in the view. I then ran the following UI test: func testExample() { XCUIDevice.shared().orientation = .portrait let window = XCUIApplication().windows.element(boundBy: 0) let centerPoint = window.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5))

Xcode UI test manual snapshot

女生的网名这么多〃 提交于 2019-12-21 17:28:11
问题 I want to manually take some snapshots from my applications using UI Tests intoduced in Xcode 7. By default, Xcode takes screenshots of every step and in result I got screenshots that was taken in the middle of transitions between view controllers. I want to manually take snapshot in the specific moments. Any ideas how to do this? I know how to take screenshot of UIView, but XCUIApplication doesn't provide any API to get UIView objects. 回答1: I've created a library for this: https://github.com

Replicate pull to refresh in XCTest UI testing

こ雲淡風輕ζ 提交于 2019-12-20 16:39:40
问题 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 item below the table like a UIToolbar or UITabBar I would rather not rely on having a UITabBar or UIToolbar but I can't figure out a way to do the pull to refresh/drag action without using the method in XCUIElement . func pressForDuration(duration:

Replicate pull to refresh in XCTest UI testing

家住魔仙堡 提交于 2019-12-20 16:39:07
问题 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 item below the table like a UIToolbar or UITabBar I would rather not rely on having a UITabBar or UIToolbar but I can't figure out a way to do the pull to refresh/drag action without using the method in XCUIElement . func pressForDuration(duration:

How to open url in Safari and the get back to the app under UITests in Xcode 7?

别等时光非礼了梦想. 提交于 2019-12-20 12:37:14
问题 This is my custom view where "LondonStreet" is a button. When I tap that button I get url and open it in Safari (it works). Then I can go back, using "Back to Wishlist" button (it also works). The problem is when I try to test this under UITests. itemsTable.cells.elementBoundByIndex(0).buttons["addressButton"].tap() //press the button to open link in Safari Along with this line: app.statusBars.buttons["Back to Wishlist"].tap() //go back, doesn't work, although it was recorded by Xcode itself.

Is it possible to “toggle software keyboard” via the code in UI test?

瘦欲@ 提交于 2019-12-20 09:35:52
问题 I have UI tests which testing login functionality (and uses it to test other stuff), but sometimes when focus is changed from one field to another - the keyboard hides, and although the cursor is blinking in the field, I getting error on field.typeText - no focused fields to fill . Somehow I realized, that clicking on a Hardware -> Keyboard -> toggle software keyboard makes keyboard to persist on the screen, so test is works well. But I need to make it working on any testing device, on any