-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
add support to set UiAutomator Congfigurator values #153
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,8 +42,11 @@ class AndroidDriver extends BaseDriver { | |
this.sessionChromedrivers = {}; | ||
this.jwpProxyActive = false; | ||
this.jwpProxyAvoid = _.clone(NO_PROXY); | ||
this.settings = new DeviceSettings({ignoreUnimportantViews: false}, | ||
this.onSettingsUpdate.bind(this)); | ||
this.settings = new DeviceSettings({ignoreUnimportantViews: false, | ||
setWaitForIdleTimeout: 10000, setWaitForSelectorTimeout:10000, | ||
setKeyInjectionDelay:0, | ||
setActionAcknowledgmentTimeout:3000, setScrollAcknowledgmentTimeout:200 | ||
}, this.onSettingsUpdate.bind(this)); | ||
this.chromedriver = null; | ||
this.apkStrings = {}; | ||
this.acceptSslCerts = !!opts.acceptSslCerts; | ||
|
@@ -155,6 +158,9 @@ class AndroidDriver extends BaseDriver { | |
if (key === "ignoreUnimportantViews") { | ||
await this.setCompressedLayoutHierarchy(value); | ||
} | ||
if (key === "configurator") { | ||
await this.setConfiguratorConfig(value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what would configurator 'values' look like here? wouldn't they actually be a combination of key and value? are they supposed to be JSON objects? |
||
} | ||
} | ||
|
||
async startAndroidSession () { | ||
|
@@ -287,6 +293,12 @@ class AndroidDriver extends BaseDriver { | |
await this.bootstrap.sendAction("compressedLayoutHierarchy", {compressLayout: compress}); | ||
} | ||
|
||
// Set UiAutomator Configurator related configurations | ||
// value sould be like {"method":"setWaitForIdleTimeout","value":5000} | ||
async setConfiguratorConfig (value) { | ||
await this.bootstrap.sendAction("configurator", JSON.parse(value)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah yes I see you're expecting JSON objects. I'd love to see a bit of nicer error handling, something like: let param;
try {
param = JSON.parse(value);
} catch (e) {
log.errorAndThrow(`Configurator values must be valid JSON! Original error: ${e}`);
}
await this.bootstrap.sendAction("configurator", param); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it might be best to also check that it is a String before trying to parse it. I can see problems if an actual JSON object (rather than a stringified version) was passed in. |
||
} | ||
|
||
async deleteSession () { | ||
log.debug("Shutting down Android driver"); | ||
await super.deleteSession(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs a little formatting work. first, let's do one key/value per line. second, we do
key: value
(with a space after colon. third, we do:to save horizontal space :-)