fix(appium): if a sessionless plugin is used for createSession, promote it to a session plugin
so it can share state within itself
MODIFY
packages/appium/lib/appium.js
packages/appium/lib/appium.js
@@ -492,6 +492,7 @@ class AppiumDriver extends BaseDriver {
// if we make it here, we know that the default behavior is handled
cmdHandledBy.default = true;
+
if (isGetStatus) {
return await this.getStatus();
}
@@ -516,6 +517,17 @@ class AppiumDriver extends BaseDriver {
// handling the command and which didn't
plugins.length && this.logPluginHandlerReport({cmd, cmdHandledBy});
+ // And finally, if the command was createSession, we want to migrate any plugins which were
+ // previously sessionless to use the new sessionId, so that plugins can share state between
+ // their createSession method and other instance methods
+ if (cmd === 'createSession' && this.sessionlessPlugins.length && !res.error) {
+ const sessionId = res.value[0];
+ log.info(`Promoting ${this.sessionlessPlugins.length} sessionless plugins to be attached ` +
+ `to session ID ${sessionId}`);
+ this.pluginsForSession[sessionId] = this.sessionlessPlugins;
+ this.sessionlessPlugins = [];
+ }
+
return res;
}
@@ -602,6 +614,8 @@ class AppiumDriver extends BaseDriver {
return false;
}
+
+
proxyActive (sessionId) {
const dstSession = this.sessions[sessionId];
return dstSession && _.isFunction(dstSession.proxyActive) && dstSession.proxyActive(sessionId);

fix(appium): if a sessionless plugin is used for createSession, promote it to a session plugin
so it can share state within itself