Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add useClearTextShortcut setting #952

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.useHIDClear) {
// 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
8 changes: 8 additions & 0 deletions WebDriverAgentLib/Commands/FBSessionCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ + (NSArray *)routes
[FBConfiguration forceSimulatorSoftwareKeyboardPresence];
}

if (capabilities[FB_CAP_USE_HID_CLEAR]) {
mykola-mokhnach marked this conversation as resolved.
Show resolved Hide resolved
[FBConfiguration setUseHIDClear:[capabilities[FB_CAP_USE_HID_CLEAR] boolValue]];
}

NSString *bundleID = capabilities[FB_CAP_BUNDLE_ID];
NSString *initialUrl = capabilities[FB_CAP_INITIAL_URL];
XCUIApplication *app = nil;
Expand Down Expand Up @@ -351,6 +355,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_HID_CLEAR: @([FBConfiguration useHIDClear]),
#if !TARGET_OS_TV
FB_SETTING_SCREENSHOT_ORIENTATION: [FBConfiguration humanReadableScreenshotOrientation],
#endif
Expand Down Expand Up @@ -449,6 +454,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_HID_CLEAR]) {
[FBConfiguration setUseHIDClear:[[settings objectForKey:FB_SETTING_USE_HID_CLEAR] boolValue]];
}

#if !TARGET_OS_TV
if (nil != [settings objectForKey:FB_SETTING_SCREENSHOT_ORIENTATION]) {
Expand Down
2 changes: 2 additions & 0 deletions WebDriverAgentLib/Utilities/FBCapabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ extern NSString* const FB_CAP_USE_NATIVE_CACHING_STRATEGY;
extern NSString* const FB_CAP_FORCE_SIMULATOR_SOFTWARE_KEYBOARD_PRESENCE;
/** Sets the application state change timeout for the initial app startup */
extern NSString* const FB_CAP_APP_LAUNCH_STATE_TIMEOUT_SEC;
/** Whether to use HIDEvent for text clear */
extern NSString* const FB_CAP_USE_HID_CLEAR;
1 change: 1 addition & 0 deletions WebDriverAgentLib/Utilities/FBCapabilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@
NSString* const FB_CAP_USE_NATIVE_CACHING_STRATEGY = @"useNativeCachingStrategy";
NSString* const FB_CAP_FORCE_SIMULATOR_SOFTWARE_KEYBOARD_PRESENCE = @"forceSimulatorSoftwareKeyboardPresence";
NSString* const FB_CAP_APP_LAUNCH_STATE_TIMEOUT_SEC = @"appLaunchStateTimeoutSec";
NSString* const FB_CAP_USE_HID_CLEAR = @"useHIDClear";
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)setUseHIDClear:(BOOL)enabled;
+ (BOOL)useHIDClear;

#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 FBUseHIDClear;
#if !TARGET_OS_TV
static UIInterfaceOrientation FBScreenshotOrientation;
#endif
Expand Down Expand Up @@ -438,6 +439,16 @@ + (NSString *)dismissAlertButtonSelector
return FBDismissAlertButtonSelector;
}

+ (void)setUseHIDClear:(BOOL)enabled
{
FBUseHIDClear = enabled;
}

+ (BOOL)useHIDClear
{
return FBUseHIDClear;
}

#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);
FBUseHIDClear = 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_HID_CLEAR;


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_HID_CLEAR = @"useHIDClear";
mykola-mokhnach marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 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;
useHIDClear?: boolean;
}

// WebDriverAgentLib/Utilities/FBCapabilities.h
Expand All @@ -48,4 +49,5 @@ export interface WDACapabilities {
forceSimulatorSoftwareKeyboardPresence?: boolean;
defaultAlertAction?: 'accept' | 'dismiss';
appLaunchStateTimeoutSec?: number;
useHIDClear?: boolean;
}
Loading