Accessibility Identifier

suggest change

When Accessibility enabled in Utilities

When Accessibility disabled in Utilities

Setting up in UITest file

import XCTest

class StackOverFlowUITests: XCTestCase {

    private let app = XCUIApplication()

    //Views

    private var view: XCUIElement!

    //Buttons

    private var addButton: XCUIElement!

    override func setUp() {
        super.setUp()
    
        app.launch()
    
        //Views
    
        view = app.otherElements["view"]
    
        //Buttons
    
        addButton = app.buttons["addButton"]
    }

    func testMyApp() {

        addButton.tap()
        view.tap()
    }    
}

In add Accessibility Identifier for element.

UIView, UIImageView, UIScrollView

let imageView = app.images["imageView"]
let scrollView = app.scrollViews["scrollView"]
let view = app.otherElements["view"]

UILabel

let label = app.staticTexts["label"]

UIStackView

let stackView = app.otherElements["stackView"]

UITableView

let tableView = app.tables["tableView"]

UITableViewCell

let tableViewCell = tableView.cells["tableViewCell"]

UITableViewCell elements

let tableViewCellButton = tableView.cells.element(boundBy: 0).buttons["button"]

UICollectionView

let collectionView = app.collectionViews["collectionView"]

UIButton, UIBarButtonItem

let button = app.buttons["button"]
let barButtonItem = app.buttons["barButtonItem"]

UITextField

let textField = app.textFields[“textField”]

let passwordTextField = app.secureTextFields[“passwordTextField”]

UITextView

let textView = app.textViews["textView"]

UISwitch

let switch = app.switches["switch"]

Alerts

let alert = app.alerts["About yourself"] // Title of presented alert

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


UI Testing:
* Accessibility Identifier

Table Of Contents
12 UIView
15 UIColor
26 UIImage
28 CALayer
30 NSDate
40 iBeacon
49 NSTimer
79 NSURL
87 AWS SDK
96 NSData
101 Segues
104 EventKit
105 NSBundle
106 SiriKit
111 StoreKit
117 3D Touch
119 Keychain
122 Block
141 AirDrop
144 UISlider
145 Carthage
146 HealthKit
148 UI Testing
151 plist
157 MVVM
164 UIPhoenix
166 Simulator
168 NSArray
169 OpenGL
175 Core Data
179 MyLayout
180 UIFont
189 Security
200 Codable