Skip to content

Commit ee722b3

Browse files
fix tests
1 parent 2549055 commit ee722b3

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

WebDriverAgentLib/Categories/XCUIElement+FBWebDriverAttributes.m

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ - (id)fb_valueForWDAttributeName:(NSString *)name
7070
return [self valueForKey:[FBElementUtils wdAttributeNameForAttributeName:name]];
7171
}
7272

73+
- (BOOL)fb_supportsInnerText
74+
{
75+
XCUIElementType elementType = self.elementType;
76+
return elementType == XCUIElementTypeTextView
77+
|| elementType == XCUIElementTypeTextField
78+
|| elementType == XCUIElementTypeSearchField
79+
|| elementType == XCUIElementTypeSecureTextField;
80+
}
81+
7382
- (NSString *)wdValue
7483
{
7584
id value = self.value;
@@ -82,10 +91,7 @@ - (NSString *)wdValue
8291
value = FBFirstNonEmptyValue(value, isSelected);
8392
} else if (elementType == XCUIElementTypeSwitch) {
8493
value = @([value boolValue]);
85-
} else if (elementType == XCUIElementTypeTextView ||
86-
elementType == XCUIElementTypeTextField ||
87-
elementType == XCUIElementTypeSearchField ||
88-
elementType == XCUIElementTypeSecureTextField) {
94+
} else if (self.fb_supportsInnerText) {
8995
NSString *placeholderValue = self.placeholderValue;
9096
value = FBFirstNonEmptyValue(value, placeholderValue);
9197
}
@@ -113,17 +119,16 @@ - (NSString *)wdName
113119

114120
- (NSString *)wdLabel
115121
{
116-
NSString *label = self.label;
117-
XCUIElementType elementType = self.elementType;
118-
if (elementType == XCUIElementTypeTextField || elementType == XCUIElementTypeSecureTextField ) {
119-
return label;
120-
}
121-
return FBTransferEmptyStringToNil(label);
122+
return self.fb_supportsInnerText
123+
? self.label
124+
: FBTransferEmptyStringToNil(self.label);
122125
}
123126

124127
- (NSString *)wdPlaceholderValue
125128
{
126-
return FBTransferEmptyStringToNil(self.placeholderValue);
129+
return self.fb_supportsInnerText
130+
? self.placeholderValue
131+
: FBTransferEmptyStringToNil(self.placeholderValue);
127132
}
128133

129134
- (NSString *)wdType

WebDriverAgentTests/IntegrationTests/FBXPathIntegrationTests.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ - (void)testSingleDescendantXMLRepresentation
5757
NSString *xmlStr = [FBXPath xmlStringWithRootElement:wrappedSnapshot
5858
options:nil];
5959
XCTAssertNotNil(xmlStr);
60-
NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\" placeholderValue=\"%@\"/>\n", wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, FBBoolToString(wrappedSnapshot.wdEnabled), FBBoolToString(wrappedSnapshot.wdVisible), FBBoolToString(wrappedSnapshot.wdAccessible), [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue], wrappedSnapshot.wdIndex, wrappedSnapshot.wdPlaceholderValue];
60+
NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\"/>\n", wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, FBBoolToString(wrappedSnapshot.wdEnabled), FBBoolToString(wrappedSnapshot.wdVisible), FBBoolToString(wrappedSnapshot.wdAccessible), [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue], wrappedSnapshot.wdIndex];
6161
XCTAssertEqualObjects(xmlStr, expectedXml);
6262
}
6363

@@ -70,7 +70,7 @@ - (void)testSingleDescendantXMLRepresentationWithScope
7070
NSString *xmlStr = [FBXPath xmlStringWithRootElement:wrappedSnapshot
7171
options:options];
7272
XCTAssertNotNil(xmlStr);
73-
NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@>\n <%@ type=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\" placeholderValue=\"%@\"/>\n</%@>\n", scope, wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, FBBoolToString(wrappedSnapshot.wdEnabled), FBBoolToString(wrappedSnapshot.wdVisible), FBBoolToString(wrappedSnapshot.wdAccessible), [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue], wrappedSnapshot.wdIndex, wrappedSnapshot.wdPlaceholderValue, scope];
73+
NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@>\n <%@ type=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\"/>\n</%@>\n", scope, wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, FBBoolToString(wrappedSnapshot.wdEnabled), FBBoolToString(wrappedSnapshot.wdVisible), FBBoolToString(wrappedSnapshot.wdAccessible), [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue], wrappedSnapshot.wdIndex, scope];
7474
XCTAssertEqualObjects(xmlStr, expectedXml);
7575
}
7676

@@ -83,7 +83,7 @@ - (void)testSingleDescendantXMLRepresentationWithoutAttributes
8383
NSString *xmlStr = [FBXPath xmlStringWithRootElement:wrappedSnapshot
8484
options:options];
8585
XCTAssertNotNil(xmlStr);
86-
NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" name=\"%@\" label=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" placeholderValue=\"%@\"/>\n", wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, FBBoolToString(wrappedSnapshot.wdAccessible), [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue], wrappedSnapshot.wdPlaceholderValue];
86+
NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" name=\"%@\" label=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\"/>\n", wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, FBBoolToString(wrappedSnapshot.wdAccessible), [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue]];
8787
XCTAssertEqualObjects(xmlStr, expectedXml);
8888
}
8989

0 commit comments

Comments
 (0)