Skip to content

Commit

Permalink
stop chromedriver proxies when reset command is called. fixes #12083
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonahss committed Jan 30, 2019
1 parent dfbb074 commit cb5fa9e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/commands/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ commands.getContexts = async function () {
};

commands.setContext = async function (name) {
if (name === null) {
if (name === null || name === undefined) {
name = this.defaultContextName();
} else if (name === WEBVIEW_WIN) {
// handle setContext "WEBVIEW"
Expand Down
7 changes: 2 additions & 5 deletions lib/commands/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import androidHelpers from '../android-helpers';
import { util } from 'appium-support';
import B from 'bluebird';
import log from '../logger';
import { NATIVE_WIN } from '../webview-helpers';
import moment from 'moment';
import { waitForCondition } from 'asyncbox';

Expand Down Expand Up @@ -227,8 +226,7 @@ commands.startActivity = async function (appPackage, appActivity,
commands.reset = async function () {
await androidHelpers.resetApp(this.adb, Object.assign({}, this.opts, {fastReset: true}));
// reset context since we don't know what kind on context we will end up after app launch.
this.curContext = NATIVE_WIN;

await this.setContext();
return await this.isChromeSession ? this.startChromeSession() : this.startAUT();
};

Expand Down Expand Up @@ -258,8 +256,7 @@ commands.setUrl = async function (uri) {
commands.closeApp = async function () {
await this.adb.forceStop(this.opts.appPackage);
// reset context since we don't know what kind on context we will end up after app launch.
this.curContext = NATIVE_WIN;
await this.stopChromedriverProxies();
await this.setContext();
};

commands.getDisplayDensity = async function () {
Expand Down
5 changes: 3 additions & 2 deletions lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class AndroidDriver extends BaseDriver {
for (let [cmd, fn] of _.toPairs(commands)) {
AndroidDriver.prototype[cmd] = fn;
}

// needs to be after the line which assigns commands to AndroidDriver.prototype, so that `this.defaultContextName` is defined.
this.curContext = this.defaultContextName();
}

async createSession (...args) {
Expand Down Expand Up @@ -99,8 +102,6 @@ class AndroidDriver extends BaseDriver {
this.opts.fastReset = !this.opts.fullReset && !this.opts.noReset;
this.opts.skipUninstall = this.opts.fastReset || this.opts.noReset;

this.curContext = this.defaultContextName();

if (this.isChromeSession) {
log.info("We're going to run a Chrome-based session");
let {pkg, activity} = helpers.getChromePkg(this.opts.browserName);
Expand Down

0 comments on commit cb5fa9e

Please sign in to comment.