xcode-ui-testing

Programmatically sending an app to background

元气小坏坏 提交于 2019-11-28 09:57:25
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? JMFR 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) // Before Swift 3: XCUIDevice().pressButton(XCUIDeviceButton.Home) XCUIApplication().launch() //

Xcode UI Tests can't find views that are added programatically

倖福魔咒の 提交于 2019-11-28 09:15:11
问题 So I'm adding a child view to my view programatically, and when I do I attach all accessibility params to it: [labelView setAccessibilityLabel:@"label"]; [labelView setIsAccessibilityElement:YES]; [labelView setUserInteractionEnabled:YES]; But when I query the UI like this: let app = XCUIApplication() app.staticTexts["label"] The test fails because it couldn't find the view. Any idea how to deal with this, how to make dynamically added views available for UI Testing ? 回答1: You need to make

Testing if an element is visible with Xcode 7 UITest

别说谁变了你拦得住时间么 提交于 2019-11-28 08:04:53
I want to verify if an element is visible or not depending on its .hidden property but I don't find a valid way to do that using the new Xcode 7 UI test stuff. I've tried with myelement.exists and myelement.hittable but they doesn't seems to work as I expected. I suppose they work on conjunction with the hidden property. An hidden element shouldn't exists and is not hittable... but this is not the current behaviour (I can understand the exists behaviour... but a hidden element should be not hittable IMO). Is there another way to verify the "hidden" property value? As of Xcode 7.1 Beta 3, UI

Xcode 7 UI Testing: Dismiss Push and Location alerts

廉价感情. 提交于 2019-11-28 08:04:04
I encountered a problem with Xcode 7 UI Testing. The app displays two alerts after my user logs in, the Request Location Alert and the Push Notifications Alert. Those notifications are shown one right after the other. The Location one appears first. I try to dismiss them automatically to start my tests. In order to do that, I add two UIInterruptionMonitor , the first one for the Location Alert and the second one for the Notification Push Alert. addUIInterruptionMonitorWithDescription("Location Dialog") { (alert) -> Bool in /* Dismiss Location Dialog */ if alert.collectionViews.buttons["Allow"]

Test target `MyAppTests` encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted)

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 07:53:12
问题 Problem arise with continuous integration when try to run bot on device. Test target MyAppTests encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted) Do you know why it happens? Any ideas? 回答1: The following worked for me. I don't know if some of the steps can be skipped, so I'm posting all of it. Update CocoaPods to version min. 1.1.0 on both dev machine and server sudo gem update cocoapods . As per terminal output during

How do I reset the application data after each test with Xcode 7 UI Testing?

拟墨画扇 提交于 2019-11-28 05:23:35
Apple introduced in Xcode 7 new UI Testing but I have a struggle whenever the tests launches the app, it starts with data that the application had before. It means tests cannot be independent and can be influenced by other tests. It is not possible to access user defaults and other data because the application that is running tests has no access to the bundle of the tested application. Scripts are also out of question because they can be run before or after testing. And there is no way how to execute NSTask on iOS to run a script before each test suite. Is there a way how do reset the

Running individual XCTest (UI, Unit) test cases for iOS apps from the command line

こ雲淡風輕ζ 提交于 2019-11-28 05:19:54
Is it possible to run individual test cases, or individual test suites, from an iOS app test target, instead of all the test cases, from a command line interface? You can run tests from command line with xcodebuild , out of the box. When you do so, you run all of the test cases contained in the test target you've selected. You can also do so with scan from Fastlane, though I believe you're restricted to running all of the tests of the build scheme you select (as above), so it's not different from xcodebuild. You can run specific tests with xctool from Facebook, but it doesn't use xcodebuild,

Xcode 7 UITests with localized UI

混江龙づ霸主 提交于 2019-11-28 03:49:53
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? SeanR I wanted to actually test the content of UI features and not just their existence, so setting a default language or using the accessibility identifiers wouldn't suit. This builds on Volodymyr 's and

Accessing the host app code from the Xcode 7 UI Test target

两盒软妹~` 提交于 2019-11-28 03:42:44
I am developing an iOS project, and I need to access to the codes of the host app from the UI test target, but I found that it shows link error: undefined symbol when I tried to. I found the test host and bundle loader for this target are all empty, so I set those to my host app and could get past the link error. However, at runtime it still fails when calling XCUIApplication.launch(). Has anyone figured out how to access the codes of the host app from this UI test target? Without being able to do this, we are forced to do all UI test, which is very flaky. We definitely need to have non-UI

Delay/Wait in a test case of Xcode UI testing

浪子不回头ぞ 提交于 2019-11-28 02:49:21
I am trying to write a test case using the new UI Testing available in Xcode 7 beta 2. The App has a login screen where it makes a call to the server to login. There is a delay associated with this as it is an asynchronous operation. Is there a way to cause a delay or wait mechanism in the XCTestCase before proceeding to further steps? There is no proper documentation available and I went through the Header files of the classes. Was not able to find anything related to this. Any ideas/suggestions? Asynchronous UI Testing was introduced in Xcode 7 Beta 4. To wait for a label with the text