Halo semuanya!
Nama saya Boris. Saya adalah insinyur AQA iOS di Vivid Money.
Ini adalah artikel pengantar dalam serangkaian artikel tentang otomatisasi iOS, di mana saya ingin berbicara tentang manfaat tes ui pada suatu proyek, penggunaan dan penulisannya yang efektif.
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-.