天道酬勤,学无止境

xcode-ui-testing

XCUIElement tap() not working

I have a very simple XCTestCase implementation that tests a tap on a button and expects an Alert controller to show up. The problem is that the tap() method doesn't work. Placing a breakpoint in the associated button's IBAction I realise the logic doesn't even get called. class uitestsampleUITests: XCTestCase { var app: XCUIApplication! override func setUp() { super.setUp() continueAfterFailure = false app = XCUIApplication() app.launch() } func testButton() { let button = app.buttons["Button"] button.tap() expectationForPredicate(NSPredicate(format: "exists == 1"), evaluatedWithObject: button

2021-11-28 16:10:51    分类:问答    ios   swift   integration-testing   xcode-ui-testing

Handler of addUIInterruptionMonitor is not called for Alert related to Photos

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?

2021-11-27 23:22:00    分类:问答    ios   swift   xcode-ui-testing

Xcode UI Testing passwordless authentication

How should I test my iPhone app's passwordless authentication? To sign up or log in, UI Testing in Xcode needs the random code that gets emailed to me.

2021-11-26 14:26:31    分类:问答    authentication   login   xcode-ui-testing

Xcode UI Test environment variables not being passed from Scheme

In Xcode 9.2, for my iOS app, I have a Scheme for running my UI Test suite. In this scheme, under the "Test" tab, I have both environment variables and arguments defined. When my tests run, these variables aren't available to my app code. However, I am able to programmatically set both the arguments and the launchEnvironment in the test code, and those ones are available to the app while it's running under test. I also have environment variables and arguments set in the "Run" tab, and those are available when I merely run the app in the simulator. They are not available when I run my UI tests

2021-11-24 18:33:28    分类:问答    ios   xcode   xcode-ui-testing

在 UI 测试中执行完整的向左滑动操作?(Perform a full swipe left action in UI Tests?)

问题 我已经在表格视图中实现了前导和尾随滑动操作。 现在,我正在尝试在 XCTest UI 测试中测试它们。 要测试在任一方向上的常规滑动很容易: tableCell.swipeRight() tableCell.swipeLeft() 使用其中一个会导致显示第一个操作按钮,然后我可以.tap()在按钮上。 然而,测试完全滑动被证明更具挑战性。 我已经从如何更快或更精确地滑动? 我也从问题 Xcode7 ui testing: staticTexts[“XX”].swipeRight() swipes not far enough 中得到了这个答案。 这两个本质上都是使用XCUIElement的coordinate(withNormalizedOffset:)方法从一个点滑动到另一个点,类似如下: let startPoint = tableCell.coordinate(withNormalizedOffset: CGVector.zero) let finishPoint = startPoint.withOffset(CGVector(dx:xOffsetValue, dy:yOffsetValue)) startPoint.press(forDuration: 0, thenDragTo: finishPoint) 我结束了与成功执行完全向右滑动,即可延长

2021-11-24 14:51:15    分类:技术分享    ios   swift   xctest   xcode-ui-testing

How to do automated UI testing for system button on XCode7?

My Storyboard has only one UI, and it has navigation bar with one UIBarButtonItem with System Item: Add. It also has another info UIButton. When doing UI testing in English everything works good without any problem. But if you switch the language to another one, it is always failed. Here is the testing code snippet: app.navigationBars["My Product"].buttons["Add"].tap() app.buttons["More Info"].tap() According to the error log, Xcode find it in another language. Here it is: Assertion Failure: UI Testing Failure - No matches found for "More Info" Button Query input was Button 0x7fa4ca65a1d0

2021-11-23 03:54:28    分类:问答    ios   objective-c   uibutton   uibarbuttonitem   xcode-ui-testing

Testing UIWebView with Xcode UI Testing

I'm using new Xcode UI Testing from XCTest Framework with the Xcode 7 GM. I've got an app with simple UIWebView (it's just a navigation controller + view controller with web view and button) and I want to check following scenario: Web View loads page www.example.com User taps on button Web View loads some page with URL: www.example2.com I want to check which page is loaded in UIWebView after pressing button. Is this possible with UI Testing right now? Actually I'm getting web view like this: let app:XCUIApplication = XCUIApplication() let webViewQury:XCUIElementQuery = app

2021-11-22 06:40:47    分类:问答    uiwebview   ios9   xctest   xcode-ui-testing

UITesting Xcode 7: How to tell if XCUIElement is visible?

I am automating an app using UI Testing in Xcode 7. I have a scrollview with XCUIElements (including buttons, etc) all the way down it. Sometimes the XCUIElements are visible, sometimes they hidden too far up or down the scrollview (depending on where I am on the scrollview). Is there a way to scroll items into view or maybe tell if they are visible or not? Thanks

2021-11-22 06:25:18    分类:问答    swift   automation   xcode7   ui-testing   xcode-ui-testing

Xcode 7: is chasm between app tests and UI tests unbridgeable?

Xcode 7† has a new way to test your UI directly, including a new testing target "iOS UI Testing Bundle" (or "OS X"). In the UI testing target, it appears there's no built-in access to the model or classes that comprise your App. E.g. [UIApplication sharedApplication] would not be callable from your UI tests. This implies that "app tests" and "UI tests" exist across a possibly unbridgeable chasm. As stated here: The problem is that Xcode’s UI testing does not allow access to the actual app. Questions: Can this chasm be bridged? If so, how, in detail, with build and linker settings and possibly

2021-11-21 13:30:56    分类:问答    xcode   automated-tests   xcode7   ui-testing   xcode-ui-testing

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

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?

2021-11-20 17:30:25    分类:问答    xcode   continuous-integration   xcode-ui-testing   xcode-server