How to use driver.getCurrentContext method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

context-specs.js

Source: context-specs.js Github

copy

Full Screen

...41 });42 describe('getCurrentContext', function () {43 it('should return current context', async function () {44 driver.curContext = 'current_context';45 await driver.getCurrentContext().should.become('current_context');46 });47 it('should return NATIVE_APP if no context is set', async function () {48 driver.curContext = null;49 await driver.getCurrentContext().should.become(NATIVE_WIN);50 });51 });52 describe('getContexts', function () {53 it('should get Chromium context where appropriate', async function () {54 sandbox.stub(webviewHelpers, 'getWebViewsMapping');55 driver = new AndroidDriver({browserName: 'Chrome'});56 expect(await driver.getContexts()).to.include(CHROMIUM_WIN);57 webviewHelpers.getWebViewsMapping.calledOnce.should.be.true;58 });59 it('should use ADB to figure out which webviews are available', async function () {60 sandbox.stub(webviewHelpers, 'parseWebviewNames').returns(['DEFAULT', 'VW', 'ANOTHER']);61 sandbox.stub(webviewHelpers, 'getWebViewsMapping');62 expect(await driver.getContexts()).to.not.include(CHROMIUM_WIN);63 webviewHelpers.parseWebviewNames.calledOnce.should.be.true;...

Full Screen

Full Screen

basic-specs.js

Source: basic-specs.js Github

copy

Full Screen

...11 const driver = setup(this, desired).driver;12 describe('context', function () {13 it('getting current context should work initially', async function () {14 await B.delay(500);15 (await driver.getCurrentContext()).should.be.ok;16 });17 });18 describe('implicit wait', function () {19 it('should set the implicit wait for finding web elements', async function () {20 await driver.implicitWait(7 * 1000);21 let before = new Date().getTime() /​ 1000;22 let hasThrown = false;23 /​**24 * we have to use try catch to actually halt the process here25 */​26 try {27 await driver.findElement('tag name', 'notgonnabethere');28 } catch (e) {29 hasThrown = true;...

Full Screen

Full Screen

CommonUtilities.js

Source: CommonUtilities.js Github

copy

Full Screen

...103 });104 };105106 this.switchAppContext = function (context) {107 return browser.driver.getCurrentContext().then(function (currentContext) {108 console.log("******* Current context is: " + currentContext);109 browser.driver.selectContext(context).then(function () {110 browser.driver.getCurrentContext().then(function (newContext) {111 console.log("******* Switched context to: " + newContext);112 return newContext;113 });114 });115 });116 };117118 this.acceptAlertIfExists = function() {119 browser.wait(expCondn.alertIsPresent(), 3000).catch(function(){console.log("alert not found")});120 browser.driver.switchTo().alert().accept().catch(function(){console.log("alert found")});121 };122123 /​**124 * Sets the picker wheel to the value specified. ...

Full Screen

Full Screen

webview-browser-tester-e2e-specs.js

Source: webview-browser-tester-e2e-specs.js Github

copy

Full Screen

...46 it('should start android session using webview browser tester', async () => {47 /​/​ await driver.setUrl('http:/​/​google.com');48 await driver.setUrl(`http:/​/​${HOST}:${PORT}/​test/​guinea-pig`);49 /​/​ make sure we are in the right context50 await driver.getCurrentContext().should.eventually.eql("CHROMIUM");51 let el = await driver.findElOrEls('id', 'i am a link', false);52 await driver.click(el.ELEMENT);53 el = await driver.findElOrEls('id', 'I am another page title', false);54 el.should.exist;55 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .withCapabilities({4 })5 .build();6driver.getCurrentContext().then(function (currentContext) {7 console.log('currentContext', currentContext);8});9driver.quit();

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

How To Use Appium Inspector For Mobile Apps

Let’s put it short: Appium Desktop = Appium Server + Inspector. When Appium Server runs automation test scripts, Appium Inspector can identify the UI elements of every application under test. The core structure of an Appium Inspector is to ensure that you discover every visible app element when you develop your test scripts. Before you kickstart your journey with Appium Inspector, you need to understand the details of it.

August ’21 Updates: Live With iOS 14.5, Latest Browsers, New Certifications, & More!

Hey Folks! Welcome back to the latest edition of LambdaTest’s product updates. Since programmer’s day is just around the corner, our incredible team of developers came up with several new features and enhancements to add some zing to your workflow. We at LambdaTest are continuously upgrading the features on our platform to make lives easy for the QA community. We are releasing new functionality almost every week.

Difference Between Web vs Hybrid vs Native Apps

Native apps are developed specifically for one platform. Hence they are fast and deliver superior performance. They can be downloaded from various app stores and are not accessible through browsers.

Top 12 Mobile App Testing Tools For 2022: A Beginner’s List

This article is a part of our Content Hub. For more in-depth resources, check out our content hub on Mobile App Testing Tutorial.

11 Best Automated UI Testing Tools In 2022

The web development industry is growing, and many Best Automated UI Testing Tools are available to test your web-based project to ensure it is bug-free and easily accessible for every user. These tools help you test your web project and make it fully compatible with user-end requirements and needs.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Android Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful