Hello everyone!
My name is Boris. I am an AQA iOS-engineer at Vivid Money.
This is an introductory article in a series of articles on iOS automation, in which I want to talk about the benefits of ui tests on a project, their effective use and writing.
iOS-, , XCUITest ui-.
, :
ui- .
.
ui- accessibilityidentifier.
UI-?
'', -. - , ?
ui-. !
β , : , , .
, , , , . .
UI-?
, , .
UI , , , .
:
, manual QA;
;
;
β - 100500 ;
.
, , ? :
, ;
ui-;
;
unit- ( β ui- );
unit- (unit- , ui- 5).
, , , ui- .
:
ui-, . , UI- .
, ui- :
File > New > Target.
UI Testing Bundle.
Next .
Finish.
Xcode UITest . .
, , ui . β Accessibilityidentifier .
Accessibilityidentifier?
Accessibilityidentifier β ui-.
Accessibilityidentifier ui- .
ui- accessibilityidentifier, , . accessibilityidentifier ui , , β .
id
accessibilityidentifier .
, storyboard
storyboard.
the Utilities.
Identity Inspector.
storyboard.
Enabled.
identifier ( : button).
, SwiftUI
View.
.accessibility(identifier: "nameOfID") .
,
ViewController.
accessibilityidentifier viewDidLoad .
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var button: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
button.accessibilityIdentifier = "button"
}
}
id
, accessibilityidentifier , , id .
Accessibility Inspector
Xcode. , id .
:
.
Xcode.
Open Developer Tools.
Accesibility Inspector.
Accessibility Inspector .
.
.
:
Basic
Label β , .
Value β , . , TextFields.
Traits β (: Button, Static Text).
Identifier β id .
Actions:
, . , .
Element:
Class β .
Address β .
Controller β View Controller, .
Hierarchy:
. id.
Console (lldb)
, , :
po XCUIApplication().debugDescription
po β print object , .
XCUIApplication β , ui .
debugDescription β , .
Attributes: Application, pid: 67835, label: 'UiTestssProjects'
Element subtree:
βApplication, 0x6000026290a0, pid: 67835, label: 'UiTestssProjects'
Window (Main), 0x600002629180, {{0.0, 0.0}, {375.0, 667.0}}
Other, 0x600002629260, {{0.0, 0.0}, {375.0, 667.0}}
Other, 0x600002629340, {{0.0, 0.0}, {375.0, 667.0}}
Other, 0x600002629420, {{0.0, 0.0}, {375.0, 667.0}}
Button, 0x600002629500, {{40.0, 156.0}, {46.0, 30.0}}, label: 'Button'
StaticText, 0x6000026295e0, {{40.0, 162.0}, {46.0, 18.0}}, label: 'Button'
StaticText, 0x6000026296c0, {{144.0, 161.0}, {42.0, 21.0}}, label: 'Label'
Button, 0x6000026297a0, {{40.0, 216.0}, {46.0, 30.0}}, identifier: 'ButtonID', label: 'Button'
StaticText, 0x600002629880, {{40.0, 222.0}, {46.0, 18.0}}, label: 'Button'
Switch, 0x600002629960, {{183.0, 245.0}, {51.0, 31.0}}, value: 1
Button, 0x600002629a40, {{40.0, 268.0}, {46.0, 30.0}}, label: 'Button'
StaticText, 0x600002629b20, {{40.0, 274.0}, {46.0, 18.0}}, label: 'Button'
TextField, 0x600002629c00, {{133.0, 374.0}, {97.0, 34.0}}
Window, 0x600002629ce0, {{0.0, 0.0}, {375.0, 667.0}}
Other, 0x600002629dc0, {{0.0, 0.0}, {375.0, 667.0}}
Other, 0x600002629ea0, {{0.0, 0.0}, {375.0, 667.0}}
Path to element:
βApplication, 0x6000026290a0, pid: 67835, label: 'UiTestssProjects'
Query chain:
βFind: Target Application 'fox.UiTestssProjects'
Output: {
Application, pid: 67835, label: 'UiTestssProjects'
}
, , , , , , , identifier.
Test Recorder
Test recorder β Apple, . .
:
UI test target() ;
, test.
record . id β , β , .
:
, , ui- iOS- ui-.