xcode-ui-testing

Handler of addUIInterruptionMonitor is not called for Alert related to Photos

你。 提交于 2019-12-05 15:57:00
问题 private func acceptPermissionAlert() { _ = addUIInterruptionMonitor(withDescription: "") { alert -> Bool in if alert.buttons["Don’t Allow"].exists { //doesnt get here second time alert.buttons.element(boundBy: 1).tapWhenExists() return true } return false } } and this doesnt work for: In the beginning of the app, it works perfect while acepting permission for notifications, but here... doesnt work. Do you know why? 回答1: Add: app.tap() at the end of the method. This is because you need to

Where is the screenshot file from Xcode UI Test?

旧巷老猫 提交于 2019-12-05 14:35:20
问题 I'm interested how to find the location of a screenshot which is created during UI Tests of my app. I would like to understand how Fastlane Snapshot grabs this screenshot. After couple of hours of research I can't find location of those screenshots. 回答1: Screenshots are stored inside your Derived Data folder. You can find this by going to Xcode, Window > Projects and click the little arrow next to your derived data path for the project. From your project derived data folder (should be the

How can I change the time required to get a snapshot in Xcode UI Test (XCUITest)?

帅比萌擦擦* 提交于 2019-12-05 12:29:57
I'm doing some performance experiments and I keep getting this error with my Xcode UI Tests since no new UI Test statement is hit: UITesting Failure - Failed to get snapshot within 15.0s How can I change this 15.0s variable to something longer? Is there some configuration or setting that I can change? You can use expectations to allocate an arbitrary amount of time to run any test case. You just create an additional expectation right before 15.0s has passed, and repeat this process as many times as necessary. Here's a short code sample to illustrate: var timeToDelay = 60.0 repeat { let delay =

Xcode UI Test UIKeyInput typeText

房东的猫 提交于 2019-12-05 08:44:30
During Xcode UI Testing, how do I insertText for a UIView that conforms to UIKeyInput ? I created a CodeInputView that conforms to UIKeyInput . When I record myself manually entering a code, Xcode writes app.typeText("1234") . But, when I try to play that back, I get the error UI Testing Failure - Neither element nor any descendant has keyboard focus . And, none of the solutions to that question has worked. I've found solution for UIKeyInput. Please, use: app.keys["1"].tap() app.keys["2"].tap() app.keys["3"].tap() app.keys["4"].tap() // Instead of app.typeText("1234") The CodeInputView needs

How can I verify existence of text inside a table view row given its index in an XCTest UI Test?

六月ゝ 毕业季﹏ 提交于 2019-12-05 08:23:35
I am using XCTest UI Test framework to check rows in a table view. In my test I need to verify the existence of text in a table view row given its index. I was thinking of using tableRows.elementBoundByIndex method, but it did not return anything. The number of rows returned by calling tableRows.count is zero. The table is present and filled because I can query the text inside the rows successfully: XCTAssertEqual(app.tables.staticTexts["Cute Alpaca"].exists) How can I verify existence of a text in a row given its index in an XCTest UI test? Kevin It turns out that tableRows doesn't actually

iOS UI Testing tap on first index of the table

情到浓时终转凉″ 提交于 2019-12-05 08:19:46
I just started studying for UI testing in iOS. When I press record and tap on first index of the table, it generate codes like this. XCUIApplication *app = [[XCUIApplication alloc] init]; [app.tables.staticTexts[@"Apr 04 16:28"] tap]; It is good if all my data are constant. But those text will be changed from time to time. How can I modify these code so that it will always tap on the first index of the table? Use -elementBoundByIndex on your app's cells . XCUIApplication *app = [[XCUIApplication alloc] init]; [[app.cells elementBoundByIndex: 0] tap]; Swift 4 @Joe Masilotti 's solution didn't

Xcode UI testing - login/logout with stored credentials

為{幸葍}努か 提交于 2019-12-05 07:59:40
I want to run functional (UI) tests for the login procedure in my iOS app (Xcode 7.2.1). The app's behaviour is that upon successful login, user credentials are stored in order to automatically login (without showing the login screen) in the next launches. So I set up a sequence of UI events in the login screen to make the login test pass on the first time the app launches in the iOS Simulator. However, next times I run my tests will fail, since the login screen doesn't even show up as expected. I see two options here, none of them seem to fit well: Reset iOS Simulator's content and settings

Access to project code from XCTestCase - UI Test

…衆ロ難τιáo~ 提交于 2019-12-05 05:30:43
I'm trying to setup UI Test in my project. I'm making a UI test that tries to login through my apps login prompt. In order to ensure that the login prompt is shown when the test launches, I'm trying to run ServerManager.logout() , which is in the project's codebase. This will cause the Login prompt to be shown on launch. import XCTest class SmokeTest: XCTestCase { override func setUp() { super.setUp() // Put setup code here. This method is called before the invocation of each test method in the class. // In UI tests it is usually best to stop immediately when a failure occurs.

Xcode 7 UI Testing with Cocoapods fails on device

会有一股神秘感。 提交于 2019-12-05 03:06:11
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 Referenced from: /var/mobile/Containers/Bundle/Application/FAC2EFB2-92C6-4668-96A7-C77CC5C4AE87/AppUITests

Any way to automate SFSafariViewController in UI tests?

血红的双手。 提交于 2019-12-05 01:55:09
Is there any way to automate SFSafariViewController? I like the Xcode 7 UI test feature, but it seems it does not support SFSafariViewController automation. Some of the UI flows I am testing require a web browser so the app uses SFSafariViewController to make it safer vs a web view. If it's similar to launching extensions (currently broken with direct interactions), try tapping the screen at the point where the element you're looking for is: Example of tapping an action sheet which launches an extension: func tapElementInActionSheetByPosition(element: XCUIElement!) { let tableSize = app.tables