Skip to content

Commit

Permalink
Merge branch 'appium:master' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun authored Nov 15, 2024
2 parents 3d192e6 + 2e9be57 commit 4a2d0fb
Show file tree
Hide file tree
Showing 15 changed files with 128 additions and 20 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/functional-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@ jobs:
fail-fast: false
matrix:
test_targets:
- XCODE_VERSION: '16.0.0'
- HOST_OS: 'macos-15'
XCODE_VERSION: '16.0.0'
IOS_VERSION: '18.0'
IOS_MODEL: iPhone 15 Plus
- XCODE_VERSION: '15.3'
IOS_MODEL: iPhone 16 Plus
- HOST_OS: 'macos-14'
XCODE_VERSION: '15.3'
IOS_VERSION: '17.4'
IOS_MODEL: iPhone 15 Plus
- XCODE_VERSION: 14.3.1
- HOST_OS: 'macos-13'
XCODE_VERSION: 14.3.1
IOS_VERSION: '16.4'
IOS_MODEL: iPhone 14 Plus

# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md
runs-on: macos-14
runs-on: ${{matrix.test_targets.HOST_OS}}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## [8.11.1](https://github.com/appium/WebDriverAgent/compare/v8.11.0...v8.11.1) (2024-11-11)

### Miscellaneous Chores

* bump appium-ios-device ([#955](https://github.com/appium/WebDriverAgent/issues/955)) ([021f349](https://github.com/appium/WebDriverAgent/commit/021f34901866f4a7870914c00781b83bd0cbddc4))

## [8.11.0](https://github.com/appium/WebDriverAgent/compare/v8.10.1...v8.11.0) (2024-11-11)

### Features

* Add support for excluded_attributes in JSON source hierarchy ([#953](https://github.com/appium/WebDriverAgent/issues/953)) ([6112223](https://github.com/appium/WebDriverAgent/commit/6112223b21026fae5545fe1b1433a09c67ff524b))

## [8.10.1](https://github.com/appium/WebDriverAgent/compare/v8.10.0...v8.10.1) (2024-11-10)

### Miscellaneous Chores

* remove unnecessary lines ([#954](https://github.com/appium/WebDriverAgent/issues/954)) ([940df80](https://github.com/appium/WebDriverAgent/commit/940df80937381b481a2762fbf86b6249804591bd))

## [8.10.0](https://github.com/appium/WebDriverAgent/compare/v8.9.4...v8.10.0) (2024-11-07)

### Features

* add useClearTextShortcut setting ([#952](https://github.com/appium/WebDriverAgent/issues/952)) ([61bc051](https://github.com/appium/WebDriverAgent/commit/61bc051180d691d26233c66a5a76ed20b7fa09d2))

## [8.9.4](https://github.com/appium/WebDriverAgent/compare/v8.9.3...v8.9.4) (2024-10-17)

### Bug Fixes
Expand Down
6 changes: 6 additions & 0 deletions WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (NSDictionary *)fb_tree;

/**
@param excludedAttributes Set of possible attributes to be excluded i.e frame, enabled, visible, accessible, focused. If set to nil or an empty array then no attributes will be excluded from the resulting JSON
@return application elements tree in form of nested dictionaries
*/
- (NSDictionary *)fb_tree:(nullable NSSet<NSString *> *) excludedAttributes;

/**
Return application elements accessibility tree in form of nested dictionaries
*/
Expand Down
53 changes: 44 additions & 9 deletions WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,16 @@ - (BOOL)fb_deactivateWithDuration:(NSTimeInterval)duration error:(NSError **)err
}

- (NSDictionary *)fb_tree
{
return [self fb_tree:nil];
}

- (NSDictionary *)fb_tree:(nullable NSSet<NSString *> *) excludedAttributes
{
id<FBXCElementSnapshot> snapshot = self.fb_isResolvedFromCache.boolValue
? self.lastSnapshot
: [self fb_snapshotWithAllAttributesAndMaxDepth:nil];
return [self.class dictionaryForElement:snapshot recursive:YES];
return [self.class dictionaryForElement:snapshot recursive:YES excludedAttributes:excludedAttributes];
}

- (NSDictionary *)fb_accessibilityTree
Expand All @@ -167,7 +172,9 @@ - (NSDictionary *)fb_accessibilityTree
return [self.class accessibilityInfoForElement:snapshot];
}

+ (NSDictionary *)dictionaryForElement:(id<FBXCElementSnapshot>)snapshot recursive:(BOOL)recursive
+ (NSDictionary *)dictionaryForElement:(id<FBXCElementSnapshot>)snapshot
recursive:(BOOL)recursive
excludedAttributes:(nullable NSSet<NSString *> *) excludedAttributes
{
NSMutableDictionary *info = [[NSMutableDictionary alloc] init];
info[@"type"] = [FBElementTypeTransformer shortStringWithElementType:snapshot.elementType];
Expand All @@ -177,11 +184,35 @@ + (NSDictionary *)dictionaryForElement:(id<FBXCElementSnapshot>)snapshot recursi
info[@"value"] = FBValueOrNull(wrappedSnapshot.wdValue);
info[@"label"] = FBValueOrNull(wrappedSnapshot.wdLabel);
info[@"rect"] = wrappedSnapshot.wdRect;
info[@"frame"] = NSStringFromCGRect(wrappedSnapshot.wdFrame);
info[@"isEnabled"] = [@([wrappedSnapshot isWDEnabled]) stringValue];
info[@"isVisible"] = [@([wrappedSnapshot isWDVisible]) stringValue];
info[@"isAccessible"] = [@([wrappedSnapshot isWDAccessible]) stringValue];
info[@"isFocused"] = [@([wrappedSnapshot isWDFocused]) stringValue];

NSDictionary<NSString *, NSString * (^)(void)> *attributeBlocks = @{
@"frame": ^{
return NSStringFromCGRect(wrappedSnapshot.wdFrame);
},
@"enabled": ^{
return [@([wrappedSnapshot isWDEnabled]) stringValue];
},
@"visible": ^{
return [@([wrappedSnapshot isWDVisible]) stringValue];
},
@"accessible": ^{
return [@([wrappedSnapshot isWDAccessible]) stringValue];
},
@"focused": ^{
return [@([wrappedSnapshot isWDFocused]) stringValue];
}
};

for (NSString *key in attributeBlocks) {
if (excludedAttributes == nil || ![excludedAttributes containsObject:key]) {
NSString *value = ((NSString * (^)(void))attributeBlocks[key])();
if ([key isEqualToString:@"frame"]) {
info[key] = value;
} else {
info[[NSString stringWithFormat:@"is%@", [key capitalizedString]]] = value;
}
}
}

if (!recursive) {
return info.copy;
Expand All @@ -191,7 +222,9 @@ + (NSDictionary *)dictionaryForElement:(id<FBXCElementSnapshot>)snapshot recursi
if ([childElements count]) {
info[@"children"] = [[NSMutableArray alloc] init];
for (id<FBXCElementSnapshot> childSnapshot in childElements) {
[info[@"children"] addObject:[self dictionaryForElement:childSnapshot recursive:YES]];
[info[@"children"] addObject:[self dictionaryForElement:childSnapshot
recursive:YES
excludedAttributes:excludedAttributes]];
}
}
return info;
Expand Down Expand Up @@ -379,7 +412,9 @@ - (BOOL)fb_dismissKeyboardWithKeyNames:(nullable NSArray<NSString *> *)keyNames
id extractedElement = extractIssueProperty(issue, @"element");

id<FBXCElementSnapshot> elementSnapshot = [extractedElement fb_takeSnapshot];
NSDictionary *elementAttributes = elementSnapshot ? [self.class dictionaryForElement:elementSnapshot recursive:NO] : @{};
NSDictionary *elementAttributes = elementSnapshot
? [self.class dictionaryForElement:elementSnapshot recursive:NO excludedAttributes:nil]
: @{};

[resultArray addObject:@{
@"detailedDescription": extractIssueProperty(issue, @"detailedDescription") ?: @"",
Expand Down
2 changes: 1 addition & 1 deletion WebDriverAgentLib/Categories/XCUIElement+FBTyping.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ - (BOOL)fb_clearTextWithSnapshot:(FBXCElementSnapshotWrapper *)snapshot
[self fb_prepareForTextInputWithSnapshot:snapshot];
}

if (retry == 0) {
if (retry == 0 && FBConfiguration.useClearTextShortcut) {
// 1st attempt is via the IOHIDEvent as the fastest operation
// https://github.com/appium/appium/issues/19389
[[XCUIDevice sharedDevice] fb_performIOHIDEventWithPage:0x07 // kHIDPage_KeyboardOrKeypad
Expand Down
7 changes: 6 additions & 1 deletion WebDriverAgentLib/Commands/FBDebugCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ + (NSArray *)routes
withExcludedAttributes:excludedAttributes]
withScope:sourceScope]];
} else if ([sourceType caseInsensitiveCompare:SOURCE_FORMAT_JSON] == NSOrderedSame) {
result = application.fb_tree;
NSString *excludedAttributesString = request.parameters[@"excluded_attributes"];
NSSet<NSString *> *excludedAttributes = (excludedAttributesString == nil)
? nil
: [NSSet setWithArray:[excludedAttributesString componentsSeparatedByString:@","]];

result = [application fb_tree:excludedAttributes];
} else if ([sourceType caseInsensitiveCompare:SOURCE_FORMAT_DESCRIPTION] == NSOrderedSame) {
result = application.fb_descriptionRepresentation;
} else {
Expand Down
4 changes: 4 additions & 0 deletions WebDriverAgentLib/Commands/FBSessionCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ + (NSArray *)routes
FB_SETTING_DEFAULT_ALERT_ACTION: request.session.defaultAlertAction ?: @"",
FB_SETTING_MAX_TYPING_FREQUENCY: @([FBConfiguration maxTypingFrequency]),
FB_SETTING_RESPECT_SYSTEM_ALERTS: @([FBConfiguration shouldRespectSystemAlerts]),
FB_SETTING_USE_CLEAR_TEXT_SHORTCUT: @([FBConfiguration useClearTextShortcut]),
#if !TARGET_OS_TV
FB_SETTING_SCREENSHOT_ORIENTATION: [FBConfiguration humanReadableScreenshotOrientation],
#endif
Expand Down Expand Up @@ -449,6 +450,9 @@ + (NSArray *)routes
if (nil != [settings objectForKey:FB_SETTING_MAX_TYPING_FREQUENCY]) {
[FBConfiguration setMaxTypingFrequency:[[settings objectForKey:FB_SETTING_MAX_TYPING_FREQUENCY] unsignedIntegerValue]];
}
if (nil != [settings objectForKey:FB_SETTING_USE_CLEAR_TEXT_SHORTCUT]) {
[FBConfiguration setUseClearTextShortcut:[[settings objectForKey:FB_SETTING_USE_CLEAR_TEXT_SHORTCUT] boolValue]];
}

#if !TARGET_OS_TV
if (nil != [settings objectForKey:FB_SETTING_SCREENSHOT_ORIENTATION]) {
Expand Down
4 changes: 2 additions & 2 deletions WebDriverAgentLib/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>8.9.4</string>
<string>8.11.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>8.9.4</string>
<string>8.11.1</string>
<key>NSPrincipalClass</key>
<string/>
</dict>
Expand Down
9 changes: 9 additions & 0 deletions WebDriverAgentLib/Utilities/FBConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ typedef NS_ENUM(NSInteger, FBConfigurationKeyboardPreference) {
+ (void)setDismissAlertButtonSelector:(NSString *)classChainSelector;
+ (NSString *)dismissAlertButtonSelector;

/**
* Whether to use HIDEvent for text clear.
* By default this is enabled and HIDEvent is used for text clear.
*
* @param enabled Either YES or NO
*/
+ (void)setUseClearTextShortcut:(BOOL)enabled;
+ (BOOL)useClearTextShortcut;

#if !TARGET_OS_TV
/**
Set the screenshot orientation for iOS
Expand Down
12 changes: 12 additions & 0 deletions WebDriverAgentLib/Utilities/FBConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
static NSTimeInterval FBAnimationCoolOffTimeout;
static BOOL FBShouldUseCompactResponses;
static NSString *FBElementResponseAttributes;
static BOOL FBUseClearTextShortcut;
#if !TARGET_OS_TV
static UIInterfaceOrientation FBScreenshotOrientation;
#endif
Expand Down Expand Up @@ -438,6 +439,16 @@ + (NSString *)dismissAlertButtonSelector
return FBDismissAlertButtonSelector;
}

+ (void)setUseClearTextShortcut:(BOOL)enabled
{
FBUseClearTextShortcut = enabled;
}

+ (BOOL)useClearTextShortcut
{
return FBUseClearTextShortcut;
}

#if !TARGET_OS_TV
+ (BOOL)setScreenshotOrientation:(NSString *)orientation error:(NSError **)error
{
Expand Down Expand Up @@ -503,6 +514,7 @@ + (void)resetSessionSettings
FBAnimationCoolOffTimeout = 2.;
// 50 should be enough for the majority of the cases. The performance is acceptable for values up to 100.
FBSetCustomParameterForElementSnapshot(FBSnapshotMaxDepthKey, @50);
FBUseClearTextShortcut = YES;
#if !TARGET_OS_TV
FBScreenshotOrientation = UIInterfaceOrientationUnknown;
#endif
Expand Down
1 change: 1 addition & 0 deletions WebDriverAgentLib/Utilities/FBSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ extern NSString* const FB_SETTING_WAIT_FOR_IDLE_TIMEOUT;
extern NSString* const FB_SETTING_ANIMATION_COOL_OFF_TIMEOUT;
extern NSString* const FB_SETTING_MAX_TYPING_FREQUENCY;
extern NSString* const FB_SETTING_RESPECT_SYSTEM_ALERTS;
extern NSString* const FB_SETTING_USE_CLEAR_TEXT_SHORTCUT;


NS_ASSUME_NONNULL_END
1 change: 1 addition & 0 deletions WebDriverAgentLib/Utilities/FBSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@
NSString* const FB_SETTING_ANIMATION_COOL_OFF_TIMEOUT = @"animationCoolOffTimeout";
NSString* const FB_SETTING_MAX_TYPING_FREQUENCY = @"maxTypingFrequency";
NSString* const FB_SETTING_RESPECT_SYSTEM_ALERTS = @"respectSystemAlerts";
NSString* const FB_SETTING_USE_CLEAR_TEXT_SHORTCUT = @"useClearTextShortcut";
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ - (void)testApplicationTree
XCTAssertNotNil(self.testedApplication.fb_accessibilityTree);
}

- (void)testApplicationTreeAttributesFiltering
{
NSDictionary *applicationTree = [self.testedApplication fb_tree:[NSSet setWithArray:@[@"visible"]]];
XCTAssertNotNil(applicationTree);
XCTAssertNil([applicationTree objectForKey:@"isVisible"], @"'isVisible' key should not be present in the application tree");
}

- (void)testDeactivateApplication
{
NSError *error;
Expand Down
1 change: 1 addition & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface WDASettings {
waitForIdleTimeout?: number;
animationCoolOffTimeout?: number;
maxTypingFrequency?: number;
useClearTextShortcut?: boolean;
}

// WebDriverAgentLib/Utilities/FBCapabilities.h
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "appium-webdriveragent",
"version": "8.9.4",
"version": "8.11.1",
"description": "Package bundling WebDriverAgent",
"main": "./build/index.js",
"types": "./build/index.d.ts",
Expand Down Expand Up @@ -76,7 +76,7 @@
"@appium/base-driver": "^9.0.0",
"@appium/strongbox": "^0.x",
"@appium/support": "^5.0.3",
"appium-ios-device": "^2.5.0",
"appium-ios-device": "^2.7.25",
"appium-ios-simulator": "^6.0.0",
"async-lock": "^1.0.0",
"asyncbox": "^3.0.0",
Expand Down

0 comments on commit 4a2d0fb

Please sign in to comment.