forked from appium/WebDriverAgent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFBElementAttributeTests.m
More file actions
206 lines (182 loc) · 7.54 KB
/
Copy pathFBElementAttributeTests.m
File metadata and controls
206 lines (182 loc) · 7.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <XCTest/XCTest.h>
#import "FBIntegrationTestCase.h"
#import "FBFindElementCommands.h"
#import "FBTestMacros.h"
#import "FBXCodeCompatibility.h"
#import "XCUIElement+FBAccessibility.h"
#import "XCUIElement+FBIsVisible.h"
#import "XCUIElement+FBWebDriverAttributes.h"
@interface FBElementAttributeTests : FBIntegrationTestCase
@end
@implementation FBElementAttributeTests
- (void)setUp
{
[super setUp];
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[self launchApplication];
[self goToAttributesPage];
});
}
- (void)testElementAccessibilityAttributes
{
// "Button" is accessibility element, and therefore isn't accessibility container
XCUIElement *buttonElement = self.testedApplication.buttons[@"Button"];
XCTAssertTrue(buttonElement.exists);
XCTAssertTrue(buttonElement.fb_isAccessibilityElement);
XCTAssertFalse(buttonElement.isWDAccessibilityContainer);
}
- (void)testContainerAccessibilityAttributes
{
// "not_accessible" isn't accessibility element, but contains accessibility elements, so it is accessibility container
XCUIElement *inaccessibleButtonElement = self.testedApplication.buttons[@"not_accessible"];
XCTAssertTrue(inaccessibleButtonElement.exists);
XCTAssertFalse(inaccessibleButtonElement.fb_isAccessibilityElement);
// FIXME: Xcode 11 environment returns false even if iOS 12
// We must fix here to XCTAssertTrue if Xcode version will return the value properly
XCTAssertFalse(inaccessibleButtonElement.isWDAccessibilityContainer);
}
- (void)testIgnoredAccessibilityAttributes
{
// Images are neither accessibility elements nor contain them, so both checks should fail
XCUIElement *imageElement = self.testedApplication.images.allElementsBoundByIndex.firstObject;
XCTAssertTrue(imageElement.exists);
XCTAssertFalse(imageElement.fb_isAccessibilityElement);
XCTAssertFalse(imageElement.isWDAccessibilityContainer);
}
- (void)testButtonAttributes
{
XCUIElement *element = self.testedApplication.buttons[@"Button"];
XCTAssertTrue(element.exists);
XCTAssertEqualObjects(element.wdType, @"XCUIElementTypeButton");
XCTAssertEqualObjects(element.wdName, @"Button");
XCTAssertEqualObjects(element.wdLabel, @"Button");
XCTAssertNil(element.wdValue);
XCTAssertFalse(element.wdSelected);
XCTAssertTrue(element.fb_isVisible);
[element tap];
XCTAssertTrue(element.wdValue.boolValue);
XCTAssertTrue(element.wdSelected);
}
- (void)testLabelAttributes
{
XCUIElement *element = self.testedApplication.staticTexts[@"Label"];
XCTAssertTrue(element.exists);
XCTAssertEqualObjects(element.wdType, @"XCUIElementTypeStaticText");
XCTAssertEqualObjects(element.wdName, @"Label");
XCTAssertEqualObjects(element.wdLabel, @"Label");
XCTAssertEqualObjects(element.wdValue, @"Label");
}
- (void)testIndexAttributes
{
XCUIElement *element = self.testedApplication.buttons[@"Button"];
XCTAssertTrue(element.exists);
XCTAssertEqual(element.wdIndex, 2);
XCUIElement *element2 = self.testedApplication;
XCTAssertTrue(element2.exists);
XCTAssertEqual(element2.wdIndex, 0);
}
- (void)testTextFieldAttributes
{
XCUIElement *element = self.testedApplication.textFields[@"Value"];
XCTAssertTrue(element.exists);
XCTAssertEqualObjects(element.wdType, @"XCUIElementTypeTextField");
XCTAssertNil(element.wdName);
XCTAssertEqualObjects(element.wdLabel, @"");
XCTAssertEqualObjects(element.wdValue, @"Value");
}
- (void)testTextFieldWithAccessibilityIdentifiersAttributes
{
XCUIElement *element = self.testedApplication.textFields[@"aIdentifier"];
XCTAssertTrue(element.exists);
XCTAssertEqualObjects(element.wdType, @"XCUIElementTypeTextField");
XCTAssertEqualObjects(element.wdName, @"aIdentifier");
XCTAssertEqualObjects(element.wdLabel, @"aLabel");
XCTAssertEqualObjects(element.wdValue, @"Value2");
}
- (void)testSegmentedControlAttributes
{
XCUIElement *element = self.testedApplication.segmentedControls.element;
XCTAssertTrue(element.exists);
XCTAssertEqualObjects(element.wdType, @"XCUIElementTypeSegmentedControl");
XCTAssertNil(element.wdName);
XCTAssertNil(element.wdLabel);
XCTAssertNil(element.wdValue);
}
- (void)testSliderAttributes
{
XCUIElement *element = self.testedApplication.sliders.element;
XCTAssertTrue(element.exists);
XCTAssertEqualObjects(element.wdType, @"XCUIElementTypeSlider");
XCTAssertNil(element.wdName);
XCTAssertNil(element.wdLabel);
XCTAssertTrue([element.wdValue containsString:@"50"]);
}
- (void)testActivityIndicatorAttributes
{
XCUIElement *element = self.testedApplication.activityIndicators.element;
XCTAssertTrue(element.exists);
XCTAssertEqualObjects(element.wdType, @"XCUIElementTypeActivityIndicator");
XCTAssertEqualObjects(element.wdName, @"Progress halted");
XCTAssertEqualObjects(element.wdLabel, @"Progress halted");
XCTAssertEqualObjects(element.wdValue, @"0");
}
- (void)testSwitchAttributes
{
XCUIElement *element = self.testedApplication.switches.element;
XCTAssertTrue(element.exists);
XCTAssertEqualObjects(element.wdType, @"XCUIElementTypeSwitch");
XCTAssertNil(element.wdName);
XCTAssertNil(element.wdLabel);
XCTAssertNil(element.wdPlaceholderValue);
XCTAssertEqualObjects(element.wdValue, @"1");
XCTAssertFalse(element.wdSelected);
XCTAssertEqual(element.wdHittable, element.hittable);
[element tap];
XCTAssertEqualObjects(element.wdValue, @"0");
XCTAssertFalse(element.wdSelected);
}
- (void)testPickerWheelAttributes
{
XCUIElement *element = self.testedApplication.pickerWheels[@"Today"];
XCTAssertTrue(element.exists);
XCTAssertEqualObjects(element.wdType, @"XCUIElementTypePickerWheel");
XCTAssertNil(element.wdName);
XCTAssertNil(element.wdLabel);
XCTAssertEqualObjects(element.wdValue, @"Today");
}
- (void)testPageIndicatorAttributes
{
XCUIElement *element = self.testedApplication.pageIndicators.element;
XCTAssertTrue(element.exists);
XCTAssertEqualObjects(element.wdType, @"XCUIElementTypePageIndicator");
XCTAssertNil(element.wdName);
XCTAssertNil(element.wdLabel);
XCTAssertEqualObjects(element.wdValue, @"page 1 of 3");
}
- (void)testTextViewAttributes
{
XCUIElement *element = self.testedApplication.textViews.element;
XCTAssertTrue(element.exists);
XCTAssertEqualObjects(element.wdType, @"XCUIElementTypeTextView");
XCTAssertNil(element.wdName);
XCTAssertNil(element.wdLabel);
XCTAssertEqualObjects(element.wdValue, @"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901");
}
- (void)testNativeHittableAttribute
{
XCUIElement *button = self.testedApplication.buttons[@"Button"];
XCTAssertTrue(button.exists);
id<FBXCElementSnapshot> snapshot = [button fb_standardSnapshot];
FBXCElementSnapshotWrapper *wrapped = [FBXCElementSnapshotWrapper ensureWrapped:snapshot];
XCTAssertEqual([wrapped isWDResolvedHittable], button.hittable);
}
@end