xcode-ui-testing

Swift UI Test - User Notifications System Alert

依然范特西╮ 提交于 2019-12-07 05:18:34
问题 I'm trying to get past the User Notification system alert by following the flow presented in the follow post, which is the same flow mentioned in the UI testing cheat sheet and a few other posts on SO. Xcode7 | Xcode UI Tests | How to handle location service alert? I'm having a strange problem where I can't hit the OK button. Here is my code addUIInterruptionMonitorWithDescription("User Notifications") { (alert) -> Bool in let okButton = alert.buttons["OK"] let dontAllowButton = alert.buttons

Xcode UI Test UIKeyInput typeText

你说的曾经没有我的故事 提交于 2019-12-07 04:13:56
问题 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. 回答1: I've found solution for UIKeyInput. Please, use: app.keys["1"].tap() app.keys["2"]

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

淺唱寂寞╮ 提交于 2019-12-07 03:22:39
问题 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

Xcode UI testing - login/logout with stored credentials

你离开我真会死。 提交于 2019-12-07 03:11:56
问题 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

XCTest UI Testing - How to close and open an app without relaunch?

▼魔方 西西 提交于 2019-12-07 03:01:24
问题 I want to make my app to go to background, and then comeback to the foreground. To make an app to go background: XCUIDevice.shared().press(XCUIDeviceButton.home) To terminate an app(force tap): XCUIApplication().terminate() To launch the app: XCUIApplication().launch() Problem : when I try to close and open the app, the launch() method clears the app from background and it opens the app freshly. I saw this comment regarding this. But cant able to figure out it in UI test. I'm using Swift.

iOS UI Testing tap on first index of the table

安稳与你 提交于 2019-12-07 02:17:11
问题 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? 回答1: Use -elementBoundByIndex on your app's cells . XCUIApplication *app = [

XCUITesting for permission popup: alert appears, but UIInterruptionMonitor does not fire

我只是一个虾纸丫 提交于 2019-12-06 23:48:31
问题 I would like to write a test like so: When my app goes to a certain pane, it should request permission to use the camera. I want to test whether or not the pane appears. I am using XC's builtin UITest framework to do this. Per what I found on google and here, it seems like I should do the following: let dialogAppearedExpectation = expectationWithDescription("Camera Permission Dialog Appears") addUIInterruptionMonitorWithDescription("Camera Permission Alert") { (alert) -> Bool in

Mock API Requests Xcode 7 Swift Automated UI Testing

偶尔善良 提交于 2019-12-06 21:17:39
问题 Is there a way to mock requests when writing automated UI tests in Swift 2.0. As far as I am aware the UI tests should be independent of other functionality. Is there a way to mock the response from server requests in order to test the behaviour of the UI dependant on the response. For example, if the server is down, the UI tests should still run. Quick example, for login, mock if password failed then UI should show alert, however, if the login is successful the next page should be shown. 回答1

Incomplete universal character name in UI Testing

白昼怎懂夜的黑 提交于 2019-12-06 18:40:52
问题 I am using Xcode 7's new feature : UI Testing. After recording the interaction, Xcode generated the code automatically : - (void)testDoubleTapToolBarItem { [[[XCUIApplication alloc] init].tabBars.buttons[@"\U5173\U6ce8"] doubleTap]; ~~~~~~~~~~~~~~~~ } However, warning showed as well. Any one know how to fix this? Incomplete universal character name Edit: This seems to be a BUG since Xcode 7.0 GM 回答1: You can use the following workaround as this seems to be a bug in xcode: replace all \U to \u

XCTestCase not launching application in setUp class method

China☆狼群 提交于 2019-12-06 07:43:05
I am using XCode 8 and XCTestCase. I created a class setUp function to be ran once before all tests, and the other setUp to be ran before each test case. I want the application to be launched once before all test cases. If I use the launch in the class setUp, it never gets executed. If I use the launch in the setUp that is ran before each test, it does launch the test. It prints: IN CLASS SETUP END CLASS SETUP IN SETUP IN TEST METHOD But the application never gets launched. If I uncomment the line to launch the application in the second setUp, it will get launched. How can I have the