-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
Conversation
@@ -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, |
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:
foo({
new: 'line',
before: 'keys/values'
});
to save horizontal space :-)
couple comments, then again a test would be nice! |
OK, I've had more time to grok what you are trying to do here, and I'd like to suggest a change in the approach. Currently, you're asking the client to do something like:
with a request body of: {"settings": {"configurator": "{\"setKeyIntervalDelay\": 1000}"}} In other words, you're creating a "configurator" group of settings that have their own internal API. Instead what I'd like to see is simply all the configurator options as top-level settings. So the client request body would look like: {"settings": {"keyIntervalDelay": 1000}} (Notice also no need to put Then you'll need to change the way the code here works. Instead of: if (key === "configurator") {
await this.setConfiguratorConfig(value);
} You'd have: if (key === "keyIntervalDelay") {
await this.setConfiguratorConfig({"setKeyIntervalDelay": value});
} And so on with all the configurator config options you want to expose to the clients via this settings API. (And you'd no longer need to Does all this make sense? I think this is a great addition to the driver, thanks! |
ok, I am now on vacation until next Monday. Will get on it after vocation. Thanks for the advice:) Concerning about the test, maybe we should create more methods to implement getting these configurations from Configurator? So tests could be done by setting firstly and then verifying via getting Sent from my mobile device.
|
@jlipps Sorry for the late reply. I tried to refactor as per your last comment using top level setting for all Configurator related configurations, it seems not making it less complex:
async onSettingsUpdate (key, value) {
if (key === "ignoreUnimportantViews") {
await this.setCompressedLayoutHierarchy(value);
}
else if (key === "waitForIdleTimeout") {
await this.setConfiguratorConfig({"waitForIdleTimeout": value});
}
else if (key === "waitForSelectorTimeout") {
await this.setConfiguratorConfig({"waitForSelectorTimeout": value});
}
else if (key === "keyInjectionDelay") {
await this.setConfiguratorConfig({"keyInjectionDelay": value});
}
else if (key === "actionAcknowledgmentTimeout") {
await this.setConfiguratorConfig({"actionAcknowledgmentTimeout": value});
}
else if (key === "scrollAcknowledgmentTimeout") {
await this.setConfiguratorConfig({"scrollAcknowledgmentTimeout": value});
}
}
// Set UiAutomator Configurator related configurations
// value sould be like {"waitForIdleTimeout":5000}
async setConfiguratorConfig (value) {
for (let k in value) { // maybe need to check value object is a dictionary?
await this.bootstrap.sendAction(k, value);
}
}
map.put("waitForIdleTimeout", new ConfiguratorHandler());
map.put("waitForSelectorTimeout", new ConfiguratorHandler());
map.put("keyInjectionDelay", new ConfiguratorHandler());
map.put("actionAcknowledgmentTimeout", new ConfiguratorHandler());
map.put("scrollAcknowledgmentTimeout", new ConfiguratorHandler()); Is that all you expected? |
Hi @truebit the point wasn't necessarily to make the code less complex, it was to make it more compatible and user-friendly. But some improvements I could make to your examples: async onSettingsUpdate (key, value) {
if (key === "ignoreUnimportantViews") {
await this.setCompressedLayoutHierarchy(value);
} else {
await this.setConfiguratorConfig({key, value});
}
} and // Set UiAutomator Configurator related configurations
// value sould be like {"waitForIdleTimeout":5000}
async setConfiguratorConfig (config) {
await this.bootstrap.sendAction(config.key, config.value);
} but yeah, this is generally the right idea! |
but the second param of |
Concerning about the tests, after update settings, how should we get the real Configurator result to verify it? |
Sure that makes sense! |
How would you verify that it is working as a user? |
IMO this could hardly verify from a user's perspective in code. I could think the only verification method by using corresponding Configurator's |
Yeah that's the trick, it doesn't have such a method. Hmm. I suppose you could expose one from the bootstrap just for testing... |
Where are we on this PR? |
@imurchie Recently I found that |
@truebit what about putting a value on the result of the |
@truebit what do you think about that idea? |
@jlipps not sure if you are the right person to ping but can it be related to https://stackoverflow.com/questions/49628336/appium-android-set-custom-timeout-between-click-tap ? |
Closed as obsolete |
This is a sub PR for appium/appium#6561