How to use driver.switchContext method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

context-specs.js

Source:context-specs.js Github

copy

Full Screen

...89 driver.curContext = 'current_cntx';90 });91 it('should start chrome driver proxy if requested context is webview', async function () {92 driver.isChromedriverContext.returns(true);93 await driver.switchContext('context');94 driver.startChromedriverProxy.calledWithExactly('context').should.be.true;95 });96 it('should stop chromedriver proxy if current context is webview and requested context is not', async function () {97 driver.opts = {recreateChromeDriverSessions: true};98 driver.isChromedriverContext.withArgs('requested_cntx').returns(false);99 driver.isChromedriverContext.withArgs('current_cntx').returns(true);100 await driver.switchContext('requested_cntx');101 driver.stopChromedriverProxies.calledOnce.should.be.true;102 });103 it('should suspend chrome driver proxy if current context is webview and requested context is not', async function () {104 driver.opts = {recreateChromeDriverSessions: false};105 driver.isChromedriverContext.withArgs('requested_cntx').returns(false);106 driver.isChromedriverContext.withArgs('current_cntx').returns(true);107 await driver.switchContext('requested_cntx');108 driver.suspendChromedriverProxy.calledOnce.should.be.true;109 });110 it('should throw error if requested and current context are not webview', async function () {111 driver.isChromedriverContext.withArgs('requested_cntx').returns(false);112 driver.isChromedriverContext.withArgs('current_cntx').returns(false);113 await driver.switchContext('requested_cntx')114 .should.be.rejectedWith(/switching to context/);115 });116 });117 describe('defaultContextName', function () {118 it('should return NATIVE_WIN', async function () {119 await driver.defaultContextName().should.be.equal(NATIVE_WIN);120 });121 });122 describe('defaultWebviewName', function () {123 it('should return WEBVIEW with package', async function () {124 driver.opts = {appPackage: 'pkg'};125 await driver.defaultWebviewName().should.be.equal(WEBVIEW_BASE + 'pkg');126 });127 });...

Full Screen

Full Screen

readyMainTest.js

Source:readyMainTest.js Github

copy

Full Screen

...12 // For the apps downloadable from either the Apple App Store or Android Play Store,13 // click through the onboarding screens14 const contexts = await driver.getContexts();15 if (contexts[1].includes(WEBVIEW)) {16 await driver.switchContext(contexts[1]);17 await driver.setOrientation('LANDSCAPE');18 await driver.setOrientation('PORTRAIT');19 webview_context = contexts[1];20 } else {21 await browser.deleteSession();22 }23 await browser.pause(PAUSE_DURATION_MICROSECONDS);24 await selectClick('div[data-index="0"] .intro-story__btn--bottom'); // Click first next button25 await selectClick('div[data-index="1"] .intro-story__btn--bottom'); // Click second next button26 await selectClick('div[data-index="2"] .intro-story__btn--bottom'); // Click third next button27 } else {28 // navigate browser to WeVote QA site29 await browser.maximizeWindow();30 await browser.url('ready');31 await browser.pause(PAUSE_DURATION_MICROSECONDS * 5);32 }33 });34 it('should enter an address', async () => {35 await simpleTextInput('editAddressOneHorizontalRowTextForMapSearch', `Oakland, CA 94501`); // Enter address36 await simpleClick('editAddressOneHorizontalRowSaveButton');37 await browser.pause(PAUSE_DURATION_MICROSECONDS);38 });39 it('should search for candidates and opinions', async () => {40 if (isCordovaFromAppObservableStore && isIOS) {41 await hiddenSelectTextInput('[class^="MuiInputBase-input FindOpinionsForm-inputDefaultLarge-"]', 'President');42 await hiddenSelectClick('[class^="MuiButtonBase-root MuiIconButton-root FindOpinionsForm-iconButtonRoot-"]');43 } else {44 await hiddenTextInputNth('[id^=findCandidatesAndOpinionsSearch]', 2, 'President');45 await selectClick('[id^=findCandidatesAndOpinionsIconClick-]');46 }47 await browser.back();48 await browser.pause(PAUSE_DURATION_MICROSECONDS);49 });50 it('should test "We Vote makes being a voter easier', async () => {51 await simpleClick('showMoreReadyIntroductionCompressed'); // Click "Show More"52 await simpleClick('readMore'); // Click "More"53 await simpleClick('readMore'); // Click "More"54 await simpleClick('showLess'); // Click "Show Less"55 await simpleClick('showLess'); // Click "Show Less"56 await simpleClick('showMoreReadyIntroductionCompressed', 2); // Click "Show More"57 });58 it('should test "Voting?" Section', async() => {59 await scrollIntoViewSimple('showMoreReadyIntroductionCompressed');60 await simpleClick('decideOnCandidatesButton'); // Click "Decide on candidates" Button61 await browser.back(); // Go back62 await browser.pause(PAUSE_DURATION_MICROSECONDS);63 if (isCordovaFromAppObservableStore && isIOS) {64 await selectClick('[class^="MuiButtonBase-root MuiButton-root MuiButton-outlined"]'); // Click "Decide on measures" Button65 } else {66 await simpleClick('decideOnMeasuresButton'); // Click "Decide on measures" Button67 }68 await browser.pause(PAUSE_DURATION_MICROSECONDS);69 await browser.back(); // Go back70 await browser.pause(PAUSE_DURATION_MICROSECONDS);71 await simpleClick('howItWorksButton'); // Click "How It Works" Button72 await simpleClick('annotatedSlideShowStep1Next'); // Click next73 await simpleClick('annotatedSlideShowStep2Next'); // Click next74 await simpleClick('annotatedSlideShowStep3Next'); // Click next75 await simpleClick('annotatedSlideShowStep4Next'); // Click next76 await simpleClick('howItWorksGetStartedDesktopButton'); // Click "Get Started"77 await simpleClick('profileCloseSignInModal'); // Click "X"78 if (isCordovaFromAppObservableStore) {79 await simpleClick('readyTabFooterBar');80 await scrollIntoViewSimple('showMoreReadyIntroductionCompressed');81 }82 await simpleClick('showMoreBallotButtons'); // Click "show more"83 await simpleClick('whatsAPersonalizedScoreButton'); // Click "What's a personalized score?" Button84 await simpleClick('personalizedScoreIntroModalNextButton'); // Click "Say What?"85 await simpleClick('personalizedScoreIntroModalNextButton'); // Click "Next"86 await simpleClick('personalizedScoreIntroModalNextButton'); // Click "Tell Me!"87 await simpleClick('personalizedScoreIntroModalNextButton'); // Click "I'll Pretend"88 await simpleClick('personalizedScoreIntroModalNextButton'); // Click "Next"89 await simpleClick('personalizedScoreIntroModalNextButton'); // Click "Show"90 await simpleClick('personalizedScoreIntroModalNextButton'); // Click "Next"91 await simpleClick('popoverCloseButton'); // Close popover92 await simpleClick('personalizedScoreIntroModalNextButton'); // Click "Next"93 await simpleClick('personalizedScoreIntroModalNextButton'); // Click "Got it!"94 await simpleClick('personalizedScoreIntroModalNextButton'); // Click "All done!"95 });96// it('should test "Registered to Vote?" Section', async () => {97// await simpleClick('verifyRegisteredInStateButton'); // Click "Verify You Are Registered in your State"98// await simpleTextInput('outlined-age-native-simple', 'CA'); // Select California99// });100// it('should test Values To Follow', async () => {101// await scrollIntoViewSimple('verifyRegisteredInStateButton'); // Scroll to section102// await hiddenSelectClick('[id^="issueFollowButton"]'); // Follow a value103// await simpleClick('readMore'); // Click "More"104// await simpleClick('showLess'); // Click "Show Less"105// await hiddenClick('valuesToFollowPreviewShowMoreId'); // Click "Explore all values"106// await browser.back(); // Go back107// await browser.pause(PAUSE_DURATION_MICROSECONDS);108// });109 it('should test "When and Where Will You Vote?" Section', async () => {110 await simpleClick('makeYourPlanNowButton'); // Click "Make Your Plan Now" Button111 await simpleClick('selectVotingRoughDate'); // Choose voting date112 if (isCordovaFromAppObservableStore && isIOS) {113 await driver.switchContext('NATIVE_APP');114 await browser.pause(PAUSE_DURATION_MICROSECONDS);115 let options = await $('//XCUIElementTypePickerWheel');116 await browser.pause(PAUSE_DURATION_MICROSECONDS);117 await options.addValue('The day before election day');118 await browser.pause(PAUSE_DURATION_MICROSECONDS);119 await driver.switchContext(webview_context);120 await browser.pause(PAUSE_DURATION_MICROSECONDS);121 await simpleClick('selectApproximateTime'); // Choose time122 await driver.switchContext('NATIVE_APP');123 await browser.pause(PAUSE_DURATION_MICROSECONDS);124 options = await $('//XCUIElementTypePickerWheel');125 await browser.pause(PAUSE_DURATION_MICROSECONDS);126 await options.addValue('9:00 AM');127 await browser.pause(PAUSE_DURATION_MICROSECONDS);128 await driver.switchContext(webview_context);129 await browser.pause(PAUSE_DURATION_MICROSECONDS);130 await simpleClick('selectModeOfTransport'); // Choose mode of transport131 await driver.switchContext('NATIVE_APP');132 await browser.pause(PAUSE_DURATION_MICROSECONDS);133 options = await $('//XCUIElementTypePickerWheel');134 await browser.pause(PAUSE_DURATION_MICROSECONDS);135 await options.addValue('drive');136 await browser.pause(PAUSE_DURATION_MICROSECONDS);137 await driver.switchContext(webview_context);138 await browser.pause(PAUSE_DURATION_MICROSECONDS);139 await simpleClick('selectLocationToDeliverBallot'); // Choose location to deliver ballot140 await driver.switchContext('NATIVE_APP');141 await browser.pause(PAUSE_DURATION_MICROSECONDS);142 await browser.pause(PAUSE_DURATION_MICROSECONDS);143 options = await $('//XCUIElementTypePickerWheel');144 await browser.pause(PAUSE_DURATION_MICROSECONDS);145 await options.addValue('voting center');146 await browser.pause(PAUSE_DURATION_MICROSECONDS);147 await driver.switchContext(webview_context);148 } else if (isAndroid && isCordovaFromAppObservableStore) {149 await driver.switchContext('NATIVE_APP');150 await browser.pause(PAUSE_DURATION_MICROSECONDS);151 const selectVotingRoughDate = await $('//android.widget.CheckedTextView[@text="The day before election day"]');152 await browser.pause(PAUSE_DURATION_MICROSECONDS);153 await selectVotingRoughDate.click();154 await browser.pause(PAUSE_DURATION_MICROSECONDS);155 await driver.switchContext(webview_context);156 await browser.pause(PAUSE_DURATION_MICROSECONDS);157 await simpleClick('selectApproximateTime'); // Choose time158 await driver.switchContext('NATIVE_APP');159 await browser.pause(PAUSE_DURATION_MICROSECONDS);160 const selectApproximateTime = await $('//android.widget.CheckedTextView[@text="9:00 AM"]'); // Click "9:00 AM"161 await browser.pause(PAUSE_DURATION_MICROSECONDS);162 await selectApproximateTime.click();163 await browser.pause(PAUSE_DURATION_MICROSECONDS);164 await driver.switchContext(webview_context);165 await browser.pause(PAUSE_DURATION_MICROSECONDS);166 await simpleClick('selectModeOfTransport'); // Choose mode of transport167 await driver.switchContext('NATIVE_APP');168 await browser.pause(PAUSE_DURATION_MICROSECONDS);169 const selectModeOfTransport = await $('//android.widget.CheckedTextView[@text="drive"]'); // Choose "drive"170 await browser.pause(PAUSE_DURATION_MICROSECONDS);171 await selectModeOfTransport.click();172 await browser.pause(PAUSE_DURATION_MICROSECONDS);173 await driver.switchContext(webview_context);174 await browser.pause(PAUSE_DURATION_MICROSECONDS);175 await simpleClick('selectLocationToDeliverBallot'); // Choose location to deliver ballot176 await driver.switchContext('NATIVE_APP');177 await browser.pause(PAUSE_DURATION_MICROSECONDS);178 const selectLocationToDeliverBallot = await $('//android.widget.CheckedTextView[@text="voting center"]');179 await browser.pause(PAUSE_DURATION_MICROSECONDS);180 await selectLocationToDeliverBallot.click();181 await browser.pause(PAUSE_DURATION_MICROSECONDS);182 await driver.switchContext(webview_context);183 await browser.pause(PAUSE_DURATION_MICROSECONDS);184 } else {185 await hiddenSelectClick('option[value="asap"]'); // Choose ""186 await simpleClick('selectApproximateTime'); // Choose time187 await browser.keys(`9:00 AM${enter}`); // Click "9:00 AM"188 await simpleClick('selectModeOfTransport'); // Choose mode of transport189 await browser.keys(`drive${enter}`); // Choose "drive"190 await simpleClick('selectLocationToDeliverBallot'); // Choose location to deliver ballot191 await browser.keys(`voting center${enter}`); // Choose "voting center"192 }193 await simpleTextInput('enterVotingLocationAddress', xssTest); // Enter in address194 await simpleClick('findPollingLocationButton'); // Click "Find Voting Center"195 if (isCordovaFromAppObservableStore && isIOS) {196 await driver.switchContext('NATIVE_APP');197 const done = await $('//XCUIElementTypeButton[@name="Done"]'); // Click done198 await done.click(); // Click done199 await driver.switchContext(webview_context);200 } else if (isCordovaFromAppObservableStore && isAndroid) {201 await driver.switchContext('NATIVE_APP');202 await browser.pause(PAUSE_DURATION_MICROSECONDS);203 const close = await $('//android.widget.ImageButton[@resource-id="com.android.chrome:id/close_button"]');204 await browser.pause(PAUSE_DURATION_MICROSECONDS);205 await close.click(); // Click X206 await browser.pause(PAUSE_DURATION_MICROSECONDS);207 await driver.switchContext(webview_context);208 await browser.pause(PAUSE_DURATION_MICROSECONDS);209 } else {210 await browser.switchWindow(browser.getWindowHandle().toString()); // Switch back to ready page211 await browser.pause(PAUSE_DURATION_MICROSECONDS);212 await simpleClick('addedToCalendar'); // Click "I added this to my calendar"213 await simpleClick('addedToCalendar');214 await simpleClick('textMeReminder'); // Click "Please text me a reminder at:215 await selectTextInput('input[name="textMeReminderPhoneNumber"]', '15005550006'); // Enter in address216 await simpleClick('emailMeReminder'); // Click "Please email me a reminder at:"217 await selectTextInput('input[name="emailMeReminderEmailAddress"]', 'Luobrandon6@gmail.com'); // Enter in email address218 }219 await simpleClick('yourPlanForVotingSaveButton'); // Click save220 await browser.deleteSession();221 });...

Full Screen

Full Screen

apptest.js

Source:apptest.js Github

copy

Full Screen

...26const loginStat = flutterFinder.byValueKey('loginStatus');27const loginBtn= flutterFinder.byValueKey('loginBtn');28(async()=>{29 const driver = await wdio.remote(opts);30 await driver.switchContext('NATIVE_APP');31 // await driver.saveScreenshot('./native-screenshot.png');32 await driver.switchContext('FLUTTER');33 console.log("TEST SCENARIO: Registering User");34 console.log("*********************************");35 console.log("Test Case: Sign IN WITH INVALID EMAIL");36 console.log("*********************************");37 38 // await driver.elementClick(signupBtn);39 // await assert.strictEqual(await driver.getElementText(regStat),"incomplete");40 // await driver.elementSendKeys(usernameField,"Suresh Karki");41 // await driver.elementSendKeys(emailField,"sureshkarki") 42 // await driver.elementClick(signupBtn);43 // await assert.strictEqual(await driver.getElementText(regStat),"invalidEmail");44 console.log("Test Case: Valid Username and Email ")45 console.log("*********************************");46 await driver.elementSendKeys(usernameField,"Suresh Karki");47 await driver.elementSendKeys(emailField,"aatitkarki12@gmail.com") 48 await driver.elementSendKeys(passwordField,"password");49 await driver.elementSendKeys(confirmPassworField,"password");50 await driver.elementClick(signupBtn);51 // await assert.strictEqual(await driver.getElementText(regStat),"regSuccess");52 // console.log("Test Case: Switching Back to Check previous Field")53 // await driver.elementClick(signupBtn); 54 // await driver.switchContext('NATIVE_APP');55 // await driver.back();56 // await driver.switchContext('FLUTTER');57 console.log("This is the good ****************************")58 // await driver.elementSendKeys(usernameField,"Suresh Karki");59 // await driver.elementSendKeys(emailField,"aatitkarki12@gmail.com") 60 // await driver.elementSendKeys(passwordField,"password");61 // await driver.elementSendKeys(confirmPassworField,"password");62 63 // await driver.elementClick(signupBtn);64 // await driver.elementSendKeys(usernameField,"Suresh Karki")65 // assert.strictEqual(await driver.getElementText(usernameField),"Suresh Karki");66 // await driver.saveScreenshot('./native-screenshot1.png');67 // assert.strictEqual(await driver.getElementText(counterTextFinder),'5');68 // await driver.elementClick(buttonFinder);69 // await driver.elementClick(buttonFinder);70 // await driver.elementClick(buttonFinder);...

Full Screen

Full Screen

behavior.tabbing.test.js

Source:behavior.tabbing.test.js Github

copy

Full Screen

...21 await browser.switchToFrame(null);22 }23 // This guarantees the presence of the software keyboard in iOS24 const [appContext, webContext] = await driver.getContexts();25 await driver.switchContext(appContext);26 const address = await driver.$("//*[@label='arbitrary-input-0']");27 await address.touchAction('tap');28 await driver.switchContext(webContext);29 await browser.pause(500);30 } else {31 await firstInput.click();32 await browser.execute(function () {33 document.querySelector('[data-test=arbitrary-input-0]').focus();34 });35 }36 assert(await firstInput.isFocused());37 if (environmentIs(DEVICES.IOS)) {38 const [appContext, webContext] = await driver.getContexts();39 await driver.switchContext(appContext);40 const next = await driver.$("//*[@label='Next']");41 while (!destinationReached) {42 await next.click();43 await driver.switchContext(webContext);44 destinationReached = await lastInput.isFocused();45 if (!destinationReached) await driver.switchContext(appContext);46 }47 } else if (environmentIs(DEVICES.ANDROID)) {48 const TAB_KEY = 61;49 while (!destinationReached) {50 await driver.pressKeyCode(TAB_KEY);51 destinationReached = await lastInput.isFocused();52 }53 } else {54 // Non-mobile is much simpler55 while (!destinationReached) {56 await browser.keys('Tab');57 destinationReached = await lastInput.isFocused();58 }59 }60 // IE11 cannot perform tab progression in reverse from within an <iframe>61 // Android devices do not support reverse tab progression62 if (environmentIs(BROWSERS.IE_11)) {63 return;64 }65 destinationReached = false;66 if (environmentIs(DEVICES.IOS)) {67 const [appContext, webContext] = await driver.getContexts();68 await driver.switchContext(appContext);69 const prev = await driver.$("//*[@label='Previous']");70 while (!destinationReached) {71 await prev.click();72 await driver.switchContext(webContext);73 destinationReached = await firstInput.isFocused();74 if (!destinationReached) await driver.switchContext(appContext);75 }76 } else if (environmentIs(DEVICES.ANDROID)) {77 const TAB_KEY = 61;78 while (!destinationReached) {79 await driver.pressKeyCode(TAB_KEY, 1);80 destinationReached = await lastInput.isFocused();81 }82 } else {83 while (!destinationReached) {84 await browser.keys(['Shift', 'Tab']);85 destinationReached = await firstInput.isFocused();86 }87 }88 }];...

Full Screen

Full Screen

wifi.ios.spec.js

Source:wifi.ios.spec.js Github

copy

Full Screen

...11 driver.background(-1);12 // Now launch the settings13 driver.execute('mobile: launchApp', {bundleId: 'com.apple.Preferences'});14 // Change the context to `NATIVE_APP`15 driver.switchContext('NATIVE_APP');16 // Go to the wifi17 const wifiRow = '**/XCUIElementTypeCell[`name CONTAINS "Wi-Fi"`]';18 const wifiSwitch = '**/XCUIElementTypeSwitch[`name CONTAINS "Wi-Fi"`]';19 $(`-ios class chain:${wifiRow}`).waitForDisplayed(DEFAULT_TIMEOUT);20 $(`-ios class chain:${wifiRow}`).click();21 // Disable it22 $(`-ios class chain:${wifiSwitch}`).waitForDisplayed(DEFAULT_TIMEOUT);23 // We use a touchaction because for some reason the button is not intractable by a default click24 $(`-ios class chain:${wifiSwitch}`).touchAction([25 'press',26 'release'27 ]);28 // Put it in the background29 driver.background(-1);30 // Launch the browser31 driver.execute('mobile: launchApp', {bundleId: 'com.apple.mobilesafari'});32 // Switch back to the previous context33 driver.switchContext(currentContext);34 // and load the url again35 driver.url('https://www.saucelabs.com');36 // For demo purpose37 driver.pause(5000);38 // Now reset the Wi-Fi again39 driver.switchContext('NATIVE_APP');40 driver.execute('mobile: launchApp', {bundleId: 'com.apple.Preferences'});41 // Enable it42 $(`-ios class chain:${wifiSwitch}`).waitForDisplayed(DEFAULT_TIMEOUT);43 // We use a touchaction because for some reason the button is not intractable by a default click44 $(`-ios class chain:${wifiSwitch}`).touchAction([45 'press',46 'release'47 ]);48 });49});50// //XCUIElementTypeSwitch[@name="bluetooth-button"]51// //XCUIElementTypeSwitch[@name="wifi-button"]52// //XCUIElementTypeSwitch[@name="cellular-data-button"]53// //XCUIElementTypeSwitch[@name="airplane-mode-button"]

Full Screen

Full Screen

index.e2e.js

Source:index.e2e.js Github

copy

Full Screen

...30// // const buttonFinder = byValueKey('increment');31// const driver = await wdio.remote(opts);32// assert.strictEqual(await driver.execute('flutter:checkHealth'), 'ok');33// if (process.env.APPIUM_OS === 'android') {34// await driver.switchContext('NATIVE_APP');35// await (await driver.$('~fab')).click();36// await driver.switchContext('FLUTTER');37// } else {38// console.log('Switching context to `NATIVE_APP` is currently only applicable to Android demo app.')39// }40// assert.strictEqual(await driver.getElementText(counterTextFinder), '0');41// await driver.elementClick(buttonFinder);42// await driver.touchAction({43// action: 'tap',44// element: { elementId: buttonFinder }45// });46// assert.strictEqual(await driver.getElementText(counterTextFinder), '2');47// driver.deleteSession();...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...26// const buttonFinder = byValueKey('increment');27 const driver = await wdio.remote(opts);28 assert.strictEqual(await driver.execute('flutter:checkHealth'), 'ok');29// if (process.env.APPIUM_OS === 'android') {30// await driver.switchContext('NATIVE_APP');31// await (await driver.$('~fab')).click();32// await driver.switchContext('FLUTTER');33// } else {34// console.log('Switching context to `NATIVE_APP` is currently only applicable to Android demo app.')35// }36// assert.strictEqual(await driver.getElementText(counterTextFinder), '0');37// await driver.elementClick(buttonFinder);38// await driver.touchAction({39// action: 'tap',40// element: { elementId: buttonFinder }41// });42// assert.strictEqual(await driver.getElementText(counterTextFinder), '2');43 driver.deleteSession();...

Full Screen

Full Screen

TC_003_Webview.js

Source:TC_003_Webview.js Github

copy

Full Screen

...4 it('should get all contexts', function () {5 NavBar.webview_icon.click()6 let contexts = driver.getContexts()7 console.log("All contexts: ", contexts)8 driver.switchContext("WEBVIEW_com.wdiodemoapp")9 $(DOCS_LINK).waitForDisplayed({timeout:30000})10 $(DOCS_LINK).click()11 driver.switchContext("NATIVE_APP")12 NavBar.login_icon.click()13 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .forBrowser('chrome')4 .build();5driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');6driver.findElement(webdriver.By.name('btnG')).click();7driver.wait(function() {8 return driver.getTitle().then(function(title) {9 return title === 'webdriver - Google Search';10 });11}, 1000);12driver.switchContext("WEBVIEW_chrome");13driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');14driver.findElement(webdriver.By.name('btnG')).click();15driver.wait(function() {16 return driver.getTitle().then(function(title) {17 return title === 'webdriver - Google Search';18 });19}, 1000);20driver.quit();21var webdriver = require('selenium-webdriver');22var driver = new webdriver.Builder()23 .forBrowser('chrome')24 .build();25driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');26driver.findElement(webdriver.By.name('btnG')).click();27driver.wait(function() {28 return driver.getTitle().then(function(title) {29 return title === 'webdriver - Google Search';30 });31}, 1000);32driver.switchContext("NATIVE_APP");33driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');34driver.findElement(webdriver.By.name('btnG')).click();35driver.wait(function() {36 return driver.getTitle().then(function(title) {37 return title === 'webdriver - Google Search';38 });39}, 1000);40driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var desired = {4};5var driver = wd.promiseChainRemote('localhost', 4723);6 .init(desired)7 .contexts()8 .then(function (contexts) {9 .context(contexts[0])10 .elementById('nameField')11 .sendKeys('Appium User')12 .elementById('emailField')13 .sendKeys('

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.switchContext("WEBVIEW_1");2driver.switchContext("NATIVE_APP");3driver.switchContext("WEBVIEW_2");4driver.switchContext("WEBVIEW_3");5driver.switchContext("WEBVIEW_4");6driver.switchContext("WEBVIEW_5");7driver.switchContext("WEBVIEW_6");8driver.switchContext("WEBVIEW_7");9driver.switchContext("WEBVIEW_8");10driver.switchContext("WEBVIEW_9");11driver.switchContext("WEBVIEW_10");12driver.switchContext("WEBVIEW_11");

Full Screen

Using AI Code Generation

copy

Full Screen

1await driver.switchContext('WEBVIEW_chrome');2await driver.switchContext('NATIVE_APP');3let context = await driver.getContext();4let contexts = await driver.getContexts();5let currentActivity = await driver.getCurrentActivity();6let currentPackage = await driver.getCurrentPackage();7let currentWindow = await driver.getWindowHandle();8let windowHandles = await driver.getWindowHandles();9await driver.closeWindow();10await driver.closeApp();11await driver.launchApp();12await driver.resetApp();13let appStrings = await driver.getAppStrings();14let appState = await driver.queryAppState();15let deviceTime = await driver.deviceTime();16let networkConnection = await driver.getNetworkConnection();17await driver.setNetworkConnection(6);18let availablePerformanceDataTypes = await driver.getPerformanceDataTypes();19let performanceData = await driver.getPerformanceData('com.example.android.apis', 'memoryinfo', 1000);20let settings = await driver.getSettings();21await driver.updateSettings({});22let displayDensity = await driver.getDisplayDensity();23let displaySize = await driver.getDisplaySize();24let location = await driver.location();25await driver.location({latitude: 37.422, longitude: -122.084});26let systemBars = await driver.getSystemBars();27let devicePixelRatio = await driver.getDevicePixelRatio();28let displayRotation = await driver.getDisplayRotation();29let displayOrientation = await driver.getDisplayOrientation();30let clipboard = await driver.getClipboard();

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var androidDriver = require('appium-android-driver');3var driver = new webdriver.Builder()4 .withCapabilities({5 })6 .build();7driver.switchContext('WEBVIEW_com.example.myapp');8driver.getPageSource().then(function(source) {9 console.log(source);10});11driver.quit();12var webdriver = require('selenium-webdriver');13var iosDriver = require('appium-ios-driver');14var driver = new webdriver.Builder()15 .withCapabilities({16 })17 .build();18driver.switchContext('WEBVIEW_1');19driver.getPageSource().then(function(source) {20 console.log(source);21});22driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .forBrowser('chrome')4 .build();5driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');6driver.findElement(webdriver.By.name('btnG')).click();7driver.wait(function() {8 return driver.getTitle().then(function(title) {9 return title === 'webdriver - Google Search';10 });11}, 1000);12driver.quit();

Full Screen

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