xcode-ui-testing

Possible to prevent XCode from envoking debugger after calling `XCUIApplication().terminate()`

空扰寡人 提交于 2019-12-19 20:47:34
问题 I'm using UITest for testing an objective C app, using swift for the tests. XCode 7.3, sim 9.3 Every test case invokes XCUIApplication.launch(), which kills any running application by sending SIGKILL. Xcode treats this like a crash - invoking the debugger on main.m . To proceed with the test suite I just click the continue button in the debugger. After hitting continue, my log says: Message from debugger: Terminated due to signal 9 This situation is frustrating because it happens after 1/4 of

Is it possible to open a screen directly in XCUITest?

心已入冬 提交于 2019-12-19 06:14:11
问题 I have 3 screens, lets say, Login Forgot Password Help screen By default the Login screen open when the app starts. The Forgot Password screen is shown when you click on the Forgot Password button, and Help Screen opens when the Help link is clicked. Can I somehow open the the Forgot Password Screen directly without going through the procedure of clicking the button using XCUITest ? I am suggesting something in the same lines as passing an adb intent to open a View directly. 回答1: As far as I

How to import my App module into MyAppUITests file?

本小妞迷上赌 提交于 2019-12-19 05:12:45
问题 This is my simple test case: import XCTest @testable import MyApp //it doesn't work because of this: class TabBarControllerTests: XCTestCase { override func setUp() { super.setUp() let defaults = NSUserDefaults.standardUserDefaults() defaults.setObject([], forKey: DBTabBarOrderedIndexesKey) //key is undefined, because of lack of my app module defaults.synchronize() continueAfterFailure = false XCUIApplication().launch() } func testIsOrderOfTabsSaved() { XCUIApplication().tabBars.buttons[

Make XCUIElement perform 3D touch for Automate UITest?

狂风中的少年 提交于 2019-12-18 20:12:36
问题 I'm creating Automate UITest test case where I'd like to test the scenario when users make 3D Touch interaction with an element, then shows them Peek and Pop view. I can't seem to find any possible ways to simulate 3D Touch on an element and continue. Anyone has any idea about this, or 3D Touch is still unavailable to test? Thanks 回答1: I was able to execute a force press / 3D Touch on an app icon on an iPhone 7 running iOS 10.3. It was not possible on 10.2. Objective-C First you have to

How to mock data in UITest on Xcode 7?

╄→гoц情女王★ 提交于 2019-12-18 11:31:58
问题 Someone has tried to include mock data with the new Xcode 7 UI tests? Have you used an specific framework? How have you managed targets? 回答1: I think there are a lot of ways to approach this one - the difficulty is that Apple has intentionally designed UITests to run entirely separate from the app under test. That said, there are a few hooks you can use to coordinate logic in the app with logic in your tests to feed in mock data or alter the behavior of your app in any way. The two I have

iOS UI Testing On an Isolated View

牧云@^-^@ 提交于 2019-12-17 21:46:05
问题 I'm trying to incorporate UI tests in my iOS project, but one thing that continues to hold me up is the fact that it seems all of the tests you write must start from the beginning of the app and work their way through. For example, if I want to test a view that is behind a login screen, my tests must first run on the login screen, enter a username/password, click login, then go to the view I want to test. Ideally, the tests for the login view and the next one would be completely isolated. Is

Programmatically sending an app to background

非 Y 不嫁゛ 提交于 2019-12-17 19:36:12
问题 Is there a way to send the application to background? Similarly to how you can call XCUIApplication.terminate() , I have some UI Elements to test on applicationDidBecomeActive(_:) . Does anyone know if this is at all possible? 回答1: I would recommend checking out XCUIDevice . Here is how you might press the home button and then relaunch the application func testExample() { // Has a nav bar. XCTAssert(XCUIApplication().navigationBars.element.exists) XCUIDevice().press(XCUIDeviceButton.home) //

Xcode 7 UITests with localized UI

随声附和 提交于 2019-12-17 17:29:58
问题 In my App I'm using NSLocalizedString to localize my app. Now I want to switch to UITests and habe Testcode like this: [tabBarsQuery.buttons["particiants"] tap]; This works for English but fails for other languages. [tabBarsQuery.buttons[NSLocalizedString("PARTICIPANTS",comment:nil)] tap]; Fails - probably because Localizable.strings is in another bundle. How can I test a localized app? 回答1: I wanted to actually test the content of UI features and not just their existence, so setting a

How to select a picker view item in an iOS UI test in Xcode?

孤者浪人 提交于 2019-12-17 16:26:49
问题 I have a picker view with few items: "Red", "Green", "Yellow", "Black". In my UI test I need to select a specific item "Green" from it. I am using the XCTest UI testing APIs that were intruduced with Xcode 7. What I managed to do so far is to swipe the whole picker view up in the unit test. It is not ideal because it always changes the picker view to the bottom item (when swiping up). let app = XCUIApplication() app.launch() app.pickers.elementAtIndex(0).swipeUp() XCTAssert(app.staticTexts[

Xcode UI test - UI Testing Failure - Failed to scroll to visible (by AX action) when tap on Search field "Cancel' button

二次信任 提交于 2019-12-17 15:20:05
问题 I am trying to dismiss the search field by tapping 'Cancel' button in search bar. The test case is failing to find the cancel button. It was working fine in Xcode 7.0.1 I have added predicate to wait for button to appear. The test case is failing when we tap of "cancel" button let button = app.buttons[“Cancel”] let existsPredicate = NSPredicate(format: "exists == 1") expectationForPredicate(existsPredicate, evaluatedWithObject: button, handler: nil) waitForExpectationsWithTimeout(5, handler: