diff --git a/ci-jobs/pr-validation.yml b/ci-jobs/pr-validation.yml index 640e4fbd0..e05edf94c 100644 --- a/ci-jobs/pr-validation.yml +++ b/ci-jobs/pr-validation.yml @@ -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 \ No newline at end of file + ANDROID_SDK_VERSION: 23 diff --git a/lib/driver.js b/lib/driver.js index d7a5f48eb..c503838ea 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -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, diff --git a/test/functional/commands/contexts-e2e-specs.js b/test/functional/commands/contexts-e2e-specs.js new file mode 100644 index 000000000..ceb6993df --- /dev/null +++ b/test/functional/commands/contexts-e2e-specs.js @@ -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]); + }); +});