Fix /actions body while doing protocol translation
MODIFY
lib/jsonwp-proxy/protocol-converter.js
lib/jsonwp-proxy/protocol-converter.js
import _ from 'lodash';
import BaseDriver from '../basedriver/driver';
import { logger, util } from 'appium-support';
+import { duplicateKeys } from '../basedriver/helpers';
+import { MJSONWP_ELEMENT_KEY, W3C_ELEMENT_KEY } from '../protocol/protocol';
const log = logger.getLogger('Protocol Converter');
@@ -153,6 +155,13 @@ class ProtocolConverter {
return await this.proxyFunc(url, method, body);
}
+ async proxyPerformActions (url, method, body) {
+ const bodyObj = util.safeJsonParse(body);
+ return _.isPlainObject(bodyObj)
+ ? await this.proxyFunc(url, method, duplicateKeys(bodyObj, MJSONWP_ELEMENT_KEY, W3C_ELEMENT_KEY))
+ : await this.proxyFunc(url, method, body);
+ }
+
/**
* Handle "crossing" endpoints for the case
* when upstream and downstream drivers operate different protocols
@@ -178,6 +187,8 @@ class ProtocolConverter {
return await this.proxySetWindow(url, method, body);
case 'setValue':
return await this.proxySetValue(url, method, body);
+ case 'performActions':
+ return await this.proxyPerformActions(url, method, body);
default:
break;
}

Fix /actions body while doing protocol translation (#302)