xcode-ui-testing

Mock API Requests Xcode 7 Swift Automated UI Testing

两盒软妹~` 提交于 2019-12-05 00:53:41
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. In its current implementation, this is not directly possible with UI Testing. The only interface the

How can I get Xcode 7 to keep around the logging output from the UI Test target?

与世无争的帅哥 提交于 2019-12-04 17:42:13
问题 I've started using the UI Test features of Xcode 7, and when I run a test, I get the output from testing showing up in the content pane of the debugging area. However, as soon as the testing is finished, that output gets replaced by the logging from the application itself. Is there a way to keep both sets of logged data visible? Adding an example, of what I want to see: 回答1: Might not completely solve your issue: I was having a similar problem (and found your question!) and just found out

Swift2 UI Test - Wait for Element to Appear

二次信任 提交于 2019-12-04 17:10:32
问题 I want to have a test pause and wait for an element to appear on screen before proceeding. I don't see a good way to create an expectation for this and wait using public func waitForExpectationsWithTimeout(timeout: NSTimeInterval, handler: XCWaitCompletionHandler?) The method to create an expectation I have been using has been public func expectationForPredicate(predicate: NSPredicate, evaluatedWithObject object: AnyObject, handler: XCPredicateExpectationHandler?) -> XCTestExpectation But

UITesting, XCTest current ViewController Class

最后都变了- 提交于 2019-12-04 16:11:01
问题 Simple problem. I got button which perform segue to next view controller. I want to write UI XCTest to tell me did it open view controller i wanted. 回答1: The UI Testing framework doesn't have access to your applications code which makes class assertions on instances impossible. You are not able to directly tell the class of the controller which is on screen. However, if you think about your test a little differently you can make a very similar assertion. Write your tests as if you are the

How do I install the XCUITest runner app and ipa on a real device and get the results?

帅比萌擦擦* 提交于 2019-12-04 16:06:06
How do I install the XCUITest runner app and ipa on a real device and get the results? I have a runner.app that was generated by building it for testing, and a deployed/signed .ipa. Now what I would like to happen is to have it installed on a real device, execute it, and get the device log. Edited with answer... It is possible to achieve this. In order to build an ipa of the UI Testing app bundle you can follow these steps: Open your project containing in Xcode. Select the device you'd like to build the ipa for next to the scheme. This can be an actual device or a simulator. Product > Build

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

夙愿已清 提交于 2019-12-04 12:34:52
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)) centerPoint.tap() } This successfully taps the button. However, if I run the same test in landscapeLeft

How to obtain reference to TextField in UI Tests in Xcode 7

倖福魔咒の 提交于 2019-12-04 11:26:29
问题 I am trying to use UI tests in xcode 7 beta. I have a storyboard with two text fields. Both text fields have outlets and different Restoration IDs. I recorded the test but generated code is quite unreadable and it doesn't work: app.otherElements.containingType(.TextField, identifier:"y").childrenMatchingType(.TextField).elementBoundByIndex(0).typeText("hello") I also tried the following and will work based on Placeholder text?!? app.textFields["PlaceholderText"].typeText("hello") What is the

Xcode UI test manual snapshot

本小妞迷上赌 提交于 2019-12-04 10:02:45
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. I've created a library for this: https://github.com/zmeyc/UITestUtils The idea is to take the screenshot in the app itself and send it to the test app via

XCTestCase: Wait for app to idle

痞子三分冷 提交于 2019-12-04 08:41:17
问题 My UI-test fails because the test waits endless until the app idles. I can not see that there is anything happening in the background, like a loading spinner. It just occurs on one tab. All others tabs are tapable but the test fails on Screen 3. I I click on another tab after the test is caught on Screen 3 the test resumes and finishes successfully. Any ideas? - (void)testExample { XCUIElementQuery* tabBarsQuery = self.app.tabBars; [tabBarsQuery.buttons[@"Screen2"] tap]; [tabBarsQuery.buttons

Testing Action Extension with UI Tests

旧巷老猫 提交于 2019-12-04 06:39:43
Is it possible to perform UI tests on Action Extension targets? I am unable to create a UI testing target with the Action Extension as the "Target to be Tested." I am trying to load the Action Extension from within Safari (or Photos, although Safari/both is prefered) If I record my interactions I can get as far as: app.icons["Safari"].tap() I can then manually add: XCUIDevice.sharedDevice().pressButton(.Home) before the generated code, but it doesn't work as expected (the simulator is left on the home screen). I have also tried: UIApplication.sharedApplication().openURL(NSURL(string: "https:/