xcode-ui-testing

Timestamped Event Matching Error: Failed to find matching element

独自空忆成欢 提交于 2019-11-29 04:19:23
问题 I'm trying to generate a UItest in Xcode. When I try to swipe UIview I get an error: Timestamped Event Matching Error: Failed to find matching element error window This also happens if I try to tap UIView. 回答1: You should verify that the 'Accessibility' option is enabled for the UIView object you are swiping from, for example: 回答2: Usually this issue is observed when the parent element of the element yo want to record is set to isAccessibilityElement=true. In general, you have to have the

Possible to bring the app from background to foreground?

隐身守侯 提交于 2019-11-29 03:39:49
When running an XCT UI test it is possible to put the application under test in the background with: XCUIDevice().pressButton(XCUIDeviceButton.Home) It it possible in some way to bring the app back to foreground (active state) without relaunching the application? Update for Xcode 9 : Starting in Xcode 9, you can now simply call activate() on any XCUIApplication. let myApp = XCUIApplication() myApp.activate() // bring to foreground https://developer.apple.com/documentation/xctest/xcuiapplication/2873317-activate Yes, it is. But, you'll need XCUIElement's private headers (which are available via

XCUIElement - Obtain Image value

天涯浪子 提交于 2019-11-29 03:21:37
I have an variable that's of type .Image and class XCUIElement . Something like this: var image = app.descendantsMatchingType(.Image).elementAtIndex(0) Is there a way I can extract the actual image so I can compare it to another image? I've tried caling the value method, but it returns a string. Casting it to a UIImage always fails. I have had a conversation about this with the Apple Developer Tools evangelist recently. There is currently no way of accessing the actual image from an image view, button, etc. Similarly, there is no way to access other properties of views that might be of

addUIInterruptionMonitor(withDescription:handler:) not working on iOS 10 or 9

烈酒焚心 提交于 2019-11-29 02:30:13
问题 The following tests works fine on iOS 11. It dismisses the alert asking permissions to use the locations services and then zooms in in the map. On iOS 10 or 9, it does none of this and the test still succeeds func testExample() { let app = XCUIApplication() var handled = false var appeared = false let token = addUIInterruptionMonitor(withDescription: "Location") { (alert) -> Bool in appeared = true let allow = alert.buttons["Allow"] if allow.exists { allow.tap() handled = true return true }

Can't get access to string localizations in UI Test (Xcode 7)

女生的网名这么多〃 提交于 2019-11-28 19:35:56
So I have a situation in which I have a few textFields that are validated. I'm trying to run a UI test, and when they fail they will get an alert to pop up with an error message (potentially a different message depending on what fields are invalid and in what way). I'd like to test that not only that an alert appeared, but that the correct message is displayed. The problem I'm having is that I need to get the localized text for comparison (if I run tests in another language other than english), but when I call NSLocalizedString in the UITest it can't gather the correct localized string (just

How to detect if iOS app is running in UI Testing mode

微笑、不失礼 提交于 2019-11-28 19:08:06
I would like my app to run special code (e.g. resetting its state) when running in UI Testing mode. I looked at environment variables that are set when the app is running from UI Testing and there aren't any obvious parameters to differentiate between the app running normally vs in UI Testing. Is there a way to find out? Two workarounds that I'm not satisfied with are: Set XCUIApplication.launchEnvironment with some variable that I later check in the app. This isn't good because you have to set it in the setUp method of each test file. I tried setting the environment variable from the scheme

UI Test deleting text in text field

元气小坏坏 提交于 2019-11-28 17:20:48
问题 In my test I have a text field with a pre-existing text. I want to delete the content and type a new string. let textField = app.textFields textField.tap() // delete "Old value" textField.typeText("New value") When deleting string with hardware keyboard Recording generated for me nothing. After doing the same with software keyboard I got: let key = app.keys["Usuń"] // Polish name for the key key.tap() key.tap() ... // x times or app.keys["Usuń"].pressForDuration(1.5) I was worried that my

iOS UI Testing On an Isolated View

[亡魂溺海] 提交于 2019-11-28 16:23:20
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 there a way to do this, or am I missing the philosophy behind UI tests completely? Absolutely! What you

UI Testing Failure - Neither element nor any descendant has keyboard focus on secureTextField

无人久伴 提交于 2019-11-28 15:26:54
This is my case: let passwordSecureTextField = app.secureTextFields["password"] passwordSecureTextField.tap() passwordSecureTextField.typeText("wrong_password") //here is an error UI Testing Failure - Neither element nor any descendant has keyboard focus. Element: What is wrong? This is working nice for normal textFields , but problem arise only with secureTextFields . Any workarounds? This issue caused me a world of pain, but I've managed to figure out a proper solution. In the Simulator, make sure 'Hardware -> Keyboard -> Connect hardware keyboard' is off. AlexDenisov Recently we found a

Check Email during Xcode UI Testing?

天涯浪子 提交于 2019-11-28 13:47:20
问题 UPDATE: Is this still possible with the new way of UI testing with Xcode? Can I programmatically access my email from an iOS UI Automation script? I want to access the signup code that my iPhone app emails to my email account. 回答1: If you have a way for your device/simulator to receive the code while still in the app then you can write a script an iOS UIA script to do this. However with the current state of the built in iOS UIA tool, you cannot access anything that is outside of your app. So