From c7b41c81465c3e853f98ea3371c6d6a0f2d99fd6 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Mon, 7 Feb 2022 15:25:22 +0100 Subject: [PATCH] fix: Update the way driver settings are updated --- lib/commands/general.js | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/lib/commands/general.js b/lib/commands/general.js index d423cafd3..59f7692ad 100644 --- a/lib/commands/general.js +++ b/lib/commands/general.js @@ -1,7 +1,7 @@ import _ from 'lodash'; import log from '../logger'; import B from 'bluebird'; -import { errors, BASEDRIVER_HANDLED_SETTINGS } from '@appium/base-driver'; +import { errors } from '@appium/base-driver'; import { fs, tempDir } from '@appium/support'; import { APK_EXTENSION } from '../extensions'; @@ -231,39 +231,14 @@ commands.openNotifications = async function () { }; commands.updateSettings = async function (settings) { - // we have some settings that are set on the settings object in the driver - // only, for example image finding settings. The uiauto2 server does not know - // what to do with them, so just set them on this driver's settings instance, - // and don't forward them to the server - let driverOnlySettings = {}; - let serverSettings = {}; - for (let [setting, value] of _.toPairs(settings)) { - if (BASEDRIVER_HANDLED_SETTINGS.includes(setting)) { - driverOnlySettings[setting] = value; - } else { - serverSettings[setting] = value; - } - } - if (!_.isEmpty(driverOnlySettings)) { - log.info(`Found some settings designed to be handled by BaseDriver: ` + - `${JSON.stringify(_.keys(driverOnlySettings))}. Not ` + - `sending these on to the UiAutomator2 server and instead ` + - `setting directly on the driver`); - await this.settings.update(driverOnlySettings); - } - if (!_.isEmpty(serverSettings)) { - log.info('Forwarding the following settings to the UiAutomator2 server: ' + - JSON.stringify(_.keys(serverSettings))); - await this.uiautomator2.jwproxy.command('/appium/settings', 'POST', - {settings: serverSettings}); - } + await this.settings.update(settings); + await this.uiautomator2.jwproxy.command('/appium/settings', 'POST', {settings}); }; commands.getSettings = async function () { - // as above, we might have some driver-only settings to return as well - const driverOnlySettings = this.settings.getSettings(); + const driverSettings = this.settings.getSettings(); const serverSettings = await this.uiautomator2.jwproxy.command('/appium/settings', 'GET'); - return {...driverOnlySettings, ...serverSettings}; + return {...driverSettings, ...serverSettings}; }; /**