IOS UITest - transition to all available screens

I am using iOS UITest for a Swift application. I use something like

func testAllScreenNavigation() {

    let app = XCUIApplication()
    app.tabBars.buttons["Home"].tap()
    app.navigationBars["Home"].buttons["More"].tap()
    app.sheets.buttons["Cancel"].tap()
}

etc .. for navigating some specific tabs, buttons, etc. and switching to the appropriate screens. But I want to focus on all the screens of my application (it can be BFS style navigation or DFS style navigation, it doesn't matter). Is there a way that iOS provides so that I can get all the navigation elements and then explore deeper and deeper automatically for my application?

I also need to keep track of which xcuoelement on the screen has already been processed and which have not yet been processed.

+4
source share
2

, .

, "" .

,

- UITabBarController
-- UISplitViewController
--- UINavigationController
---- UIViewController
----- UIBarButtonItems
----- UIView
----- UIButton
----- UISwitch
----- UITableViewCell

UITabBarController ( , , SplitViewControllers iPhone).

:

XCUIApplication().tabBars

, : ViewController , ViewController, .

UIButton -> Touch Up Inside
UISwitch -> Value Changed
UITableViewCell -> DidSelectRowAtIndexPath
UIView -> UILongPressGestureRecognizer

: UIViewController View ( ).

. UIViews UIButtons TouchUpInside . , , , UITableViews UIWebViews, , -.

, , UIBarButtonItems, , , "" , .


, , (, , , ValueChangeListeners - )

, , TabBar , accessibilityLabel, . accessibilityLabel .xib /.storyboard:

// just to illustrate, so you get an idea:
self.tabBarController.isAccessibilityElement = true
self.tabBarController.accessibilityLabel = "tabBar"

:

let tabBar = XCUIApplication().tabBars["tabBar"]

Apple accessibilityLabels: https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/iPhoneAccessibility/Making_Application_Accessible/Making_Application_Accessible.html

Apple: https://developer.apple.com/library/content/technotes/TestingAccessibilityOfiOSApps/TestAccessibilityiniOSSimulatorwithAccessibilityInspector/TestAccessibilityiniOSSimulatorwithAccessibilityInspector.html


, XCUIElementType , . . : "tabBars", "navBars", "", "" .. .

, " ". Apple (imho) , : https://blog.metova.com/guide-xcode-ui-test/ , , .

XCUIElementTypes . , elementType , . XCUIElementType - , iOS ( MacOS X). :

Alert
Button
NavigationBar
TabBar
ToolBar
ActivityIndicator
SegmentedControl
Picker
Image
StaticText
TextField
DatePicker
TextView
WebView

https://developer.apple.com/reference/xctest/xcuielementtype?language=objc

+3

, , - Xcode UI test recorder. /, XCUIApplication() . / / , , .

, .

, Mukund

+2

Source: https://habr.com/ru/post/1670896/


All Articles