Skip to content
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

fix: store curContext in createSession #483

Merged
merged 4 commits into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci-jobs/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
script: npx mocha --timeout 6000000 --reporter mocha-multi-reporters --reporter-options config-file=./ci-jobs/mocha-config.json --recursive build/test/functional/ -g @skip-ci -i --exit
name: sdk23_e2e_tests
CHROMEDRIVER_VERSION: 2.20
ANDROID_SDK_VERSION: 23
ANDROID_SDK_VERSION: 23
2 changes: 2 additions & 0 deletions lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ class EspressoDriver extends BaseDriver {

this.caps = Object.assign(serverDetails, this.caps);

this.curContext = this.defaultContextName();

let defaultOpts = {
fullReset: false,
autoLaunch: true,
Expand Down
41 changes: 41 additions & 0 deletions test/functional/commands/contexts-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { initSession, deleteSession, MOCHA_TIMEOUT } from '../helpers/session';
import { APIDEMO_CAPS } from '../desired';


chai.should();
chai.use(chaiAsPromised);


describe('context', function () {
this.timeout(MOCHA_TIMEOUT);

let driver;
before(async function () {
let caps = Object.assign({
appActivity: 'io.appium.android.apis.view.WebView1',
}, APIDEMO_CAPS);
driver = await initSession(caps);
});
after(async function () {
await deleteSession();
});

it('should get contexts and set them without errors', async function () {
if (process.env.ANDROID_SDK_VERSION === '23') {
// Latest 23 emulator has chrome '44.0.2403' instead of '43.0.2357'
return;
}

const viewContexts = await driver.contexts();

await driver.currentContext().should.eventually.eql(viewContexts[0]);

await driver.context(viewContexts[1]);
await driver.currentContext().should.eventually.eql(viewContexts[1]);

await driver.context(viewContexts[0]);
await driver.currentContext().should.eventually.eql(viewContexts[0]);
});
});