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 'hideKeyboard' capability #942

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ appium:buildToolsVersion | The version of Android build tools to use. By default
appium:skipLogcatCapture | Being set to `true` disables automatic logcat output collection during the test run. `false` by default
appium:suppressKillServer | Being set to `true` prevents the driver from ever killing the ADB server explicitly. Could be useful if ADB is connected wirelessly. `false` by default
appium:ignoreHiddenApiPolicyError | Being set to `true` ignores a failure while changing hidden API access policies. Could be useful on some devices, where access to these policies has been locked by its vendor. `false` by default.
pium:hideKeyboard | Being set to `true` hides the on-screen keyboard while the session is running. Use it instead of the legacy `appium:unicodeKeyboard` one (which will be dropped in the future). This effect is achieved by assigning a custom "artificial" [input method](https://developer.android.com/develop/ui/views/touch-and-input/creating-input-method). Only use this feature for special/exploratory cases as it violates the way your application under test is normally interacted with by a human. Setting this capability explicitly to `false` enforces `adb shell ime reset` call on session startup, which resets the currently selected/enabled IMEs to the default ones as if the device is initially booted with the current locale. `undefined` by default.
appium:mockLocationApp | Sets the package identifier of the app, which is used as a system mock location provider since Appium 1.18.0+. This capability has no effect on emulators. If the value is set to `null` or an empty string, then Appium will skip the mocked location provider setup procedure. Defaults to Appium Setting package identifier (`io.appium.settings`).
appium:logcatFormat | The log print format, where `format` is one of: `brief` `process` `tag` `thread` `raw` `time` `threadtime` `long`. `threadtime` is the default value.
appium:logcatFilterSpecs | Series of `tag[:priority]` where `tag` is a log component tag (or * for all) and priority is: `V Verbose`, `D Debug`, `I Info`, `W Warn`, `E Error`, `F Fatal`, `S Silent (supress all output)`. '*' means '*:d' and `tag` by itself means `tag:v`. If not specified on the commandline, filterspec is set from ANDROID_LOG_TAGS. If no filterspec is found, filter defaults to '*:I'.
Expand Down
14 changes: 13 additions & 1 deletion lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@
* >}
*/
class EspressoDriver extends AndroidDriver {
/** @type {string|null} */
_originalIme;

/** @type {import('./types').EspressoDriverOpts} */
opts;
Expand All @@ -165,6 +167,7 @@
];
this.desiredCapConstraints = ESPRESSO_CONSTRAINTS;
this.jwpProxyAvoid = NO_PROXY;
this._originalIme = null;

this.settings = new DeviceSettings({}, this.onSettingsUpdate.bind(this));

Expand Down Expand Up @@ -379,7 +382,9 @@
}

// start an avd, set the language/locale, pick an emulator, etc...
// TODO with multiple devices we'll need to parameterize this
if (this.opts.hideKeyboard) {
this._originalIme = await this.adb.defaultIME();
}
await helpers.initDevice(this.adb, this.opts);

// https://github.com/appium/appium-espresso-driver/issues/72
Expand Down Expand Up @@ -611,6 +616,13 @@
this.log.warn(`Unable to reset animation: ${err.message}`);
}
}
if (this._originalIme) {
try {
await this.adb.setIME(this._originalIme);
} catch (e) {
this.log.warn(`Cannot restore the original IME: ${e.message}`);
}
}
if (!this.isChromeSession && this.opts.appPackage && !this.opts.dontStopAppOnReset) {
await this.adb.forceStop(this.opts.appPackage);
}
Expand Down Expand Up @@ -642,19 +654,19 @@
}

// eslint-disable-next-line no-unused-vars
proxyActive (sessionId) {

Check warning on line 657 in lib/driver.js

View workflow job for this annotation

GitHub Actions / node_test (20)

'sessionId' is defined but never used

Check warning on line 657 in lib/driver.js

View workflow job for this annotation

GitHub Actions / node_test (18)

'sessionId' is defined but never used

Check warning on line 657 in lib/driver.js

View workflow job for this annotation

GitHub Actions / node_test (16)

'sessionId' is defined but never used
// we always have an active proxy to the espresso server
return true;
}

// eslint-disable-next-line no-unused-vars
canProxy (sessionId) {

Check warning on line 663 in lib/driver.js

View workflow job for this annotation

GitHub Actions / node_test (20)

'sessionId' is defined but never used

Check warning on line 663 in lib/driver.js

View workflow job for this annotation

GitHub Actions / node_test (18)

'sessionId' is defined but never used

Check warning on line 663 in lib/driver.js

View workflow job for this annotation

GitHub Actions / node_test (16)

'sessionId' is defined but never used
// we can always proxy to the espresso server
return true;
}

// eslint-disable-next-line no-unused-vars
getProxyAvoidList (sessionId) {

Check warning on line 669 in lib/driver.js

View workflow job for this annotation

GitHub Actions / node_test (20)

'sessionId' is defined but never used

Check warning on line 669 in lib/driver.js

View workflow job for this annotation

GitHub Actions / node_test (18)

'sessionId' is defined but never used

Check warning on line 669 in lib/driver.js

View workflow job for this annotation

GitHub Actions / node_test (16)

'sessionId' is defined but never used
// we are maintaining two sets of NO_PROXY lists, one for chromedriver(CHROME_NO_PROXY)
// and one for Espresso(NO_PROXY), based on current context will return related NO_PROXY list
this.jwpProxyAvoid = _.isNil(this.chromedriver) ? NO_PROXY : CHROME_NO_PROXY;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
],
"dependencies": {
"appium-adb": "^11.0.1",
"appium-android-driver": "^7.1.3",
"appium-android-driver": "^7.2.1",
"asyncbox": "^2.3.1",
"bluebird": "^3.5.0",
"lodash": "^4.17.11",
Expand Down
Loading