How to use driver.createSession method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

driver-specs.js

Source:driver-specs.js Github

copy

Full Screen

...20 describe('createSession', function () {21 it('should throw an error if app can not be found', async function () {22 let driver = new AndroidUiautomator2Driver({}, false);23 defaultStub(driver);24 await driver.createSession({app: 'foo.apk'}).should.be.rejectedWith('does not exist or is not accessible');25 });26 it('should set sessionId', async function () {27 let driver = new AndroidUiautomator2Driver({}, false);28 defaultStub(driver);29 sinon.mock(driver).expects('checkAppPresent')30 .once()31 .returns(B.resolve());32 sinon.mock(driver).expects('startUiAutomator2Session')33 .once()34 .returns(B.resolve());35 await driver.createSession({cap: 'foo', browserName: 'chrome'});36 driver.sessionId.should.exist;37 driver.caps.cap.should.equal('foo');38 });39 it('should set the default context', async function () {40 let driver = new AndroidUiautomator2Driver({}, false);41 defaultStub(driver);42 sinon.mock(driver).expects('checkAppPresent')43 .returns(B.resolve());44 sinon.mock(driver).expects('startUiAutomator2Session')45 .returns(B.resolve());46 await driver.createSession({browserName: 'chrome'});47 driver.curContext.should.equal('NATIVE_APP');48 });49 });50 describe('checkAppPresent', async function () {51 it('should resolve if app present', async function () {52 let driver = new AndroidUiautomator2Driver({}, false);53 defaultStub(driver);54 let app = path.resolve('.');55 sinon.mock(driver).expects('startUiAutomator2Session')56 .returns(B.resolve());57 sinon.mock(driver.helpers).expects('configureApp')58 .returns(app);59 await driver.createSession({app});60 await driver.checkAppPresent(); // should not error61 // configureApp is shared between the two,62 // so restore mock or the next test will fail63 driver.helpers.configureApp.restore();64 });65 it('should reject if app not present', async function () {66 let driver = new AndroidUiautomator2Driver({}, false);67 defaultStub(driver);68 let app = path.resolve('asdfasdf');69 sinon.mock(driver).expects('checkAppPresent')70 .returns(B.resolve());71 sinon.mock(driver).expects('startUiAutomator2Session')72 .returns(B.resolve());73 sinon.mock(driver.helpers).expects('configureApp')74 .returns(app);75 await driver.createSession({app});76 driver.checkAppPresent.restore();77 await driver.checkAppPresent().should.eventually.be.rejectedWith('Could not find');78 });79 });80 describe('proxying', function () {81 let driver;82 before(function () {83 driver = new AndroidUiautomator2Driver({}, false);84 defaultStub(driver);85 driver.sessionId = 'abc';86 });87 describe('#proxyActive', function () {88 it('should exist', function () {89 driver.proxyActive.should.be.an.instanceof(Function);90 });91 it('should return true', function () {92 driver.proxyActive('abc').should.be.true;93 });94 it('should throw an error if session id is wrong', function () {95 (() => {96 driver.proxyActive('aaa');97 }).should.throw;98 });99 });100 describe('#getProxyAvoidList', function () {101 it('should exist', function () {102 driver.getProxyAvoidList.should.be.an.instanceof(Function);103 });104 it('should return jwpProxyAvoid array', function () {105 let avoidList = driver.getProxyAvoidList('abc');106 avoidList.should.be.an.instanceof(Array);107 avoidList.should.eql(driver.jwpProxyAvoid);108 });109 it('should throw an error if session id is wrong', function () {110 (() => {111 driver.getProxyAvoidList('aaa');112 }).should.throw;113 });114 describe('nativeWebScreenshot', function () {115 let proxyAvoidList;116 let nativeWebScreenshotFilter = (item) => item[0] === "GET" && item[1].test('/session/xxx/screenshot/');117 beforeEach(function () {118 driver = new AndroidUiautomator2Driver({}, false);119 defaultStub(driver);120 sinon.mock(driver).expects('checkAppPresent')121 .once()122 .returns(B.resolve());123 sinon.mock(driver).expects('startUiAutomator2Session')124 .once()125 .returns(B.resolve());126 });127 describe('on webview mode', function () {128 beforeEach(function () {129 driver.chromedriver = true;130 });131 it('should proxy screenshot if nativeWebScreenshot is off on chromedriver mode', async function () {132 await driver.createSession({platformName: 'Android', deviceName: 'device', browserName: 'chrome', nativeWebScreenshot: false});133 proxyAvoidList = driver.getProxyAvoidList().filter(nativeWebScreenshotFilter);134 proxyAvoidList.should.be.empty;135 });136 it('should not proxy screenshot if nativeWebScreenshot is on on chromedriver mode', async function () {137 await driver.createSession({platformName: 'Android', deviceName: 'device', browserName: 'chrome', nativeWebScreenshot: true});138 proxyAvoidList = driver.getProxyAvoidList().filter(nativeWebScreenshotFilter);139 proxyAvoidList.should.not.be.empty;140 });141 });142 describe('on native mode', function () {143 it('should never proxy screenshot regardless of nativeWebScreenshot setting (on)', async function () {144 // nativeWebScreenshot on145 await driver.createSession({platformName: 'Android', deviceName: 'device', browserName: 'chrome', nativeWebScreenshot: true});146 proxyAvoidList = driver.getProxyAvoidList().filter(nativeWebScreenshotFilter);147 proxyAvoidList.should.not.be.empty;148 });149 it('should never proxy screenshot regardless of nativeWebScreenshot setting (off)', async function () {150 // nativeWebScreenshot off151 await driver.createSession({platformName: 'Android', deviceName: 'device', browserName: 'chrome', nativeWebScreenshot: false});152 proxyAvoidList = driver.getProxyAvoidList().filter(nativeWebScreenshotFilter);153 proxyAvoidList.should.not.be.empty;154 });155 });156 });157 });158 describe('#canProxy', function () {159 it('should exist', function () {160 driver.canProxy.should.be.an.instanceof(Function);161 });162 it('should return true', function () {163 driver.canProxy('abc').should.be.true;164 });165 it('should throw an error if session id is wrong', function () {...

Full Screen

Full Screen

driver-e2e-specs.js

Source:driver-e2e-specs.js Github

copy

Full Screen

...23 let appActivity = await driver.getCurrentActivity();24 return {appPackage, appActivity};25 }26 it('should start android session focusing on default pkg and act', async () => {27 await driver.createSession(defaultCaps);28 let {appPackage, appActivity} = await getPackageAndActivity(driver);29 appPackage.should.equal('io.appium.android.apis');30 appActivity.should.equal('.ApiDemos');31 });32 it('should start android session focusing on custom pkg and act', async () => {33 let caps = Object.assign({}, defaultCaps);34 caps.appPackage = 'io.appium.android.apis';35 caps.appActivity = '.view.SplitTouchView';36 await driver.createSession(caps);37 let {appPackage, appActivity} = await getPackageAndActivity(driver);38 appPackage.should.equal(caps.appPackage);39 appActivity.should.equal(caps.appActivity);40 });41 it('should error out for not apk extention', async () => {42 let caps = Object.assign({}, defaultCaps);43 caps.app = 'foo';44 caps.appPackage = 'io.appium.android.apis';45 caps.appActivity = '.view.SplitTouchView';46 await driver.createSession(caps).should.eventually.be.rejectedWith(/apk/);47 });48 it('should error out if neither an app or a browser is defined', async () => {49 let caps = Object.assign({}, defaultCaps);50 caps.app = '';51 await driver.createSession(caps).should.eventually.be.rejectedWith(/include/);52 });53 it('should error out for invalid app path', async () => {54 let caps = Object.assign({}, defaultCaps);55 caps.app = 'foo.apk';56 caps.appPackage = 'io.appium.android.apis';57 caps.appActivity = '.view.SplitTouchView';58 await driver.createSession(caps).should.eventually.be.rejectedWith(/Could not find/);59 });60 it('should be able to start session without launching or installing app', async () => {61 let caps = Object.assign({}, defaultCaps);62 caps.appPackage = 'io.appium.android.apis';63 caps.appActivity = '.view.SplitTouchView';64 caps.autoLaunch = false;65 await driver.createSession(caps);66 let {appPackage, appActivity} = await getPackageAndActivity(driver);67 expect(appPackage).to.not.equal(caps.appPackage);68 expect(appActivity).to.not.equal(caps.appActivity);69 });70 it('should be able to launch activity with custom intent parameter category', async () => {71 let caps = Object.assign({}, defaultCaps);72 caps.appPackage = 'io.appium.android.apis';73 caps.appActivity = 'io.appium.android.apis.app.HelloWorld';74 caps.intentCategory = 'appium.android.intent.category.SAMPLE_CODE';75 await driver.createSession(caps);76 let appActivity = await driver.getCurrentActivity();77 appActivity.should.include('HelloWorld');78 });79 it('should be able to load an app via package', async () => {80 let caps = Object.assign({}, defaultCaps);81 caps.app = '';82 caps.appPackage = 'io.appium.android.apis';83 caps.appActivity = '.ApiDemos';84 await driver.createSession(caps);85 let appPackage = await driver.getCurrentPackage();86 appPackage.should.include('io.appium.android.apis');87 });88 it('should error out if package is not on the device', async () => {89 let caps = Object.assign({}, defaultCaps);90 caps.app = '';91 caps.appPackage = 'sipa.diordna.muippa.oi';92 caps.appActivity = '.ApiDemos';93 await driver.createSession(caps).should.eventually.be.rejectedWith(/Could not find/);94 });95 it('should get updated capabilities', async () => {96 let caps = Object.assign({}, defaultCaps);97 caps.appPackage = 'io.appium.android.apis';98 caps.appActivity = '.view.SplitTouchView';99 await driver.createSession(caps);100 let serverCaps = await driver.getSession();101 serverCaps.takesScreenshot.should.exist;102 });103 it('should get device name, udid, model, manufacturer and screen size in session details', async () => {104 let caps = Object.assign({}, defaultCaps);105 caps.appPackage = 'io.appium.android.apis';106 caps.appActivity = '.view.SplitTouchView';107 let session = await driver.createSession(caps);108 session[1].deviceName.should.exist;109 session[1].deviceUDID.should.exist;110 let serverCaps = await driver.getSession();111 serverCaps.deviceName.should.exist;112 serverCaps.deviceUDID.should.exist;113 serverCaps.deviceScreenSize.should.exist;114 serverCaps.deviceModel.should.exist;115 serverCaps.deviceManufacturer.should.exist;116 });117 it('should error out for activity that fails to load after app wait activity timeout', async () => {118 let caps = Object.assign({}, defaultCaps);119 caps.appWaitActivity = 'non.existent.activity';120 caps.appWaitDuration = 1000; // 1 second121 await driver.createSession(caps).should.eventually.be.rejectedWith(/never started/);122 });123 it('should be able to grant permissions', async function () {124 // TODO: why is there no entry for 5.1?125 let adb = new ADB();126 let apiLevel = await adb.getApiLevel();127 if (apiLevel < 23) {128 return this.skip();129 }130 let caps = Object.assign({}, defaultCaps);131 caps.appPackage = 'io.appium.android.apis';132 caps.appActivity = 'io.appium.android.apis.app.HelloWorld';133 caps.intentCategory = 'appium.android.intent.category.SAMPLE_CODE';134 caps.autoGrantPermissions = true;135 await driver.createSession(caps);136 expect(await driver.adb.getGrantedPermissions('io.appium.android.apis')).to.include.members(['android.permission.RECEIVE_SMS']);137 });138 describe('W3C compliance', function () {139 it('should accept W3C parameters', async function () {140 const [sessionId, caps] = await driver.createSession(null, null, {141 alwaysMatch: Object.assign({}, defaultCaps),142 firstMatch: [{}],143 });144 sessionId.should.exist;145 caps.should.exist;146 });147 });148});149describe('close', function () {150 let driver;151 before(() => {152 driver = new AndroidDriver();153 });154 afterEach(async () => {155 await driver.deleteSession();156 });157 it('should close application', async () => {158 await driver.createSession(defaultCaps);159 await driver.closeApp();160 let appPackage = await driver.getCurrentPackage();161 if (appPackage) {162 appPackage.should.not.equal("io.appium.android.apis");163 }164 });...

Full Screen

Full Screen

chrome-pool-cookies-test.js

Source:chrome-pool-cookies-test.js Github

copy

Full Screen

1/**2* Copyright (c) 2017 ZipRecruiter3*4* Permission is hereby granted, free of charge, to any person obtaining a copy5* of this software and associated documentation files (the "Software"), to deal6* in the Software without restriction, including without limitation the rights7* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell8* copies of the Software, and to permit persons to whom the Software is9* furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice shall be included in all12* copies or substantial portions of the Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE17* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21* */22const chai = require('chai');23const expect = chai.expect;24const HttpServer = require('..').HttpServer;25const Driver = require('../clients/js/chrome_driver_proxy');26const Chrome = require('selenium-webdriver/chrome').Driver;27const ChromeOptions = require('selenium-webdriver/chrome').Options;28const chromedriverBin = process.env.CHROMEDRIVER_BIN || '/usr/bin/chromedriver';29describe('Proxy with chrome pool cookie test', () => {30 let server;31 let driver;32 let options;33 const mockServerUrl = 'http://127.0.0.1:8080';34 beforeEach((done) => {35 const config = {36 proxy: {37 port: 4444,38 baseUrl: '/wd/hub',39 },40 chromedriver: {41 chromedriverPath: chromedriverBin,42 port: 4445,43 autoRestart: false,44 },45 chromePool: {46 enable: true,47 reuse: true,48 chromePath: '/usr/bin/google-chrome',49 clearStorage: [50 {51 origin: '.localhost',52 storageTypes: 'cookies,localstorage',53 },54 ],55 },56 };57 server = new HttpServer(config.proxy);58 server.start(config, () => {59 const chromeOptions = new ChromeOptions();60 chromeOptions.addArguments(61 'headless',62 'disable-gpu',63 'no-first-run',64 'no-sandbox',65 );66 options = chromeOptions.toCapabilities();67 driver = Driver.createSession('http://127.0.0.1:4444/wd/hub', options);68 done();69 });70 });71 afterEach((done) => {72 server.stop(done);73 });74 it('can clear cookies between sessions', (done) => {75 driver.get(`${mockServerUrl}/base.html`).then(() => driver.manage().addCookie({ name: 'foo', value: 'bar' })).then(() => driver.get(`${mockServerUrl}/cookies`)).then(() => driver.getPageSource())76 .then(source => driver.findElement({ css: '#foo span.value' }))77 .then(elem => elem.getText())78 .then((cookieValue) => {79 expect(cookieValue).to.equal('bar');80 return driver.quit();81 })82 .then(() => {83 driver = Driver.createSession('http://127.0.0.1:4444/wd/hub', options);84 return driver.get(`${mockServerUrl}/base.html`);85 })86 .then(() => driver.manage().getCookie('foo'))87 .then((cookie) => {88 expect(cookie).to.be.null;89 })90 .then(() => driver.quit())91 .then(() => {92 done();93 })94 .catch((err) => {95 done(err);96 });97 });98 it('can override default for clearing local storage', (done) => {99 driver.get(`${mockServerUrl}/base.html`).then(() => driver.setClearStorage([])).then(() => driver.get(`${mockServerUrl}/cookies`)).then(() => driver.executeScript('window.localStorage.setItem("foo", "bar")'))100 .then(() => driver.executeScript('return window.localStorage.getItem("foo")'))101 .then((value) => {102 expect(value).to.equal('bar');103 return driver.quit();104 })105 .then(() => {106 // TODO find a better way to wait for the browser to be available in the pool107 return driver.sleep(5);108 }).then(() => {109 driver = Driver.createSession('http://127.0.0.1:4444/wd/hub', options);110 return driver.get(`${mockServerUrl}/base.html`);111 })112 .then(() => driver.executeScript('return window.localStorage.getItem("foo")'))113 .then((value) => {114 expect(value).to.equal('bar');115 })116 .then(() => driver.quit())117 .then(() => {118 done();119 })120 .catch((err) => {121 done(err);122 });123 });124 it('can clear local storage between sessions', (done) => {125 driver.get(`${mockServerUrl}/base.html`).then(() => driver.manage().addCookie({ name: 'foo', value: 'bar' })).then(() => driver.get(`${mockServerUrl}/cookies`)).then(() => driver.executeScript('window.localStorage.setItem("foo", "bar")'))126 .then(() => driver.executeScript('return window.localStorage.getItem("foo")'))127 .then((value) => {128 expect(value).to.equal('bar');129 return driver.quit();130 })131 .then(() => {132 driver = Driver.createSession('http://127.0.0.1:4444/wd/hub', options);133 return driver.get(`${mockServerUrl}/base.html`);134 })135 .then(() => driver.executeScript('return window.localStorage.getItem("foo")'))136 .then((value) => {137 expect(value).to.be.null;138 })139 .then(() => driver.quit())140 .then(() => {141 done();142 })143 .catch((err) => {144 done(err);145 });146 });147 it('can close extra windows between sessions', (done) => {148 driver.get(`${mockServerUrl}/base.html`).then(() => driver.executeScript(`open("${mockServerUrl}/base.html"); open("${mockServerUrl}/base.html")`)).then(() => driver.getAllWindowHandles()).then((handles) => {149 expect(handles.length).to.equal(3);150 return driver.quit();151 })152 .then(() => {153 driver = Driver.createSession('http://127.0.0.1:4444/wd/hub', options);154 return driver.get(`${mockServerUrl}/base.html`);155 })156 .then(() => driver.getAllWindowHandles())157 .then((handles) => {158 expect(handles.length).to.equal(1);159 return driver.quit();160 })161 .then(() => {162 done();163 })164 .catch((err) => {165 done(err);166 });167 });...

Full Screen

Full Screen

unlocker-e2e-specs.js

Source:unlocker-e2e-specs.js Github

copy

Full Screen

...25 await driver.deleteSession();26 });27 it('should unlock an Android 19 device using a PIN', async () => {28 let caps = _.extend(defaultCaps, {unlockType: "pin", unlockKey: "1111", avd: AVD_ANDROID_19_PIN_UNLOCK});29 await driver.createSession(caps);30 let isLock = await driver.adb.isScreenLocked();31 isLock.should.equal(false);32 });33 it('should unlock an Android 23 device using a PIN', async () => {34 let caps = _.extend(defaultCaps, {unlockType: "pin", unlockKey: "1111", avd: AVD_ANDROID_23_PIN_UNLOCK});35 await driver.createSession(caps);36 let isLock = await driver.adb.isScreenLocked();37 isLock.should.equal(false);38 });39 it('should unlock an Android 19 device using a PASSWORD', async () => {40 let caps = _.extend(defaultCaps, {unlockType: "password", unlockKey: "appium", avd: AVD_ANDROID_19_PASSWORD_UNLOCK});41 await driver.createSession(caps);42 let isLock = await driver.adb.isScreenLocked();43 isLock.should.equal(false);44 });45 it('should unlock an Android 23 device using a PASSWORD', async () => {46 let caps = _.extend(defaultCaps, {unlockType: "password", unlockKey: "appium", avd: AVD_ANDROID_23_PASSWORD_UNLOCK});47 await driver.createSession(caps);48 let isLock = await driver.adb.isScreenLocked();49 isLock.should.equal(false);50 });51 it('should unlock an Android 19 device using a PATTERN', async () => {52 let caps = _.extend(defaultCaps, {unlockType: "pattern", unlockKey: "729856143", avd: AVD_ANDROID_19_PATTERN_UNLOCK});53 await driver.createSession(caps);54 let isLock = await driver.adb.isScreenLocked();55 isLock.should.equal(false);56 });57 it('should unlock an Android 23 device using a PATTERN', async () => {58 let caps = _.extend(defaultCaps, {unlockType: "pattern", unlockKey: "729856143", avd: AVD_ANDROID_23_PATTERN_UNLOCK});59 await driver.createSession(caps);60 let isLock = await driver.adb.isScreenLocked();61 isLock.should.equal(false);62 });63 it('should unlock an Android 23 device using FINGERPRINT', async () => {64 let caps = _.extend(defaultCaps, {unlockType: "pattern", unlockKey: "729856143", avd: AVD_ANDROID_23_FINGERPRINT_UNLOCK});65 await driver.createSession(caps);66 let isLock = await driver.adb.isScreenLocked();67 isLock.should.equal(false);68 });69 });...

Full Screen

Full Screen

edge_driver_test.js

Source:edge_driver_test.js Github

copy

Full Screen

1// Copyright 2020 Microsoft2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License. 14const assert = require('assert');15const edge = require("../lib/edge");16describe('JS selenium binding tests', function () {17 this.timeout(0);18 it.skip('test default', async function () {19 let driver = await edge.Driver.createSession();20 let cap = await driver.getCapabilities();21 await assert.equal(cap.get('browserName'), 'MicrosoftEdge');22 await driver.quit();23 });24 it.skip('test legacy edge', async function () {25 let options = await new edge.Options().setEdgeChromium(false);26 let driver = await edge.Driver.createSession(options);27 let cap = await driver.getCapabilities();28 await assert.equal(cap.get('browserName'), 'MicrosoftEdge');29 await driver.quit();30 });31 it('test chromium edge', async function () {32 let options = await new edge.Options().setEdgeChromium(true);33 let driver = await edge.Driver.createSession(options);34 let cap = await driver.getCapabilities();35 await assert.equal(cap.get('browserName'), 'msedge');36 await driver.quit();37 });38 it('test legacy options to capabilities', async function () {39 let options = await new edge.Options();40 let cap = await options.toCapabilities();41 await assert.equal(cap.get('browserName'), 'MicrosoftEdge');42 await assert.equal(cap.has('ms:edgeOptions'), false);43 await assert.equal(cap.has('ms:edgeChromium'), true);44 await assert.equal(cap.get('ms:edgeChromium'), false);45 });46 it('test chromium options to capabilities', async function () {47 let options = await new edge48 .Options()49 .setEdgeChromium(true);50 let cap = await options.toCapabilities();51 await assert.equal(cap.get('browserName'), 'MicrosoftEdge');52 await assert.equal(cap.has('ms:edgeOptions'), true);53 await assert.equal(cap.get('ms:edgeOptions').getEdgeChromium(), true);54 await assert.equal(cap.has('ms:edgeChromium'), true);55 await assert.equal(cap.get('ms:edgeChromium'), true);56 });57 it('test webview options', function() {58 let options = new edge.Options();59 options.setEdgeChromium(true);60 options.setUseWebView(true);61 let cap = options.toCapabilities();62 assert.equal(cap.get('browserName'), 'webview2');63 });...

Full Screen

Full Screen

orientation-e2e-specs.js

Source:orientation-e2e-specs.js Github

copy

Full Screen

...15 await driver.setOrientation('PORTRAIT');16 await driver.deleteSession();17 });18 it('should have portrait orientation if requested', async function () {19 await driver.createSession(Object.assign({}, DEFAULT_CAPS, {20 appActivity: '.view.TextFields',21 orientation: 'PORTRAIT',22 }));23 await driver.getOrientation().should.eventually.eql('PORTRAIT');24 });25 it('should have landscape orientation if requested', async function () {26 await driver.createSession(Object.assign({}, DEFAULT_CAPS, {27 appActivity: '.view.TextFields',28 orientation: 'LANDSCAPE',29 }));30 await driver.getOrientation().should.eventually.eql('LANDSCAPE');31 });32 it('should have portrait orientation if nothing requested', async function () {33 await driver.createSession(Object.assign({}, DEFAULT_CAPS, {34 appActivity: '.view.TextFields',35 }));36 await driver.getOrientation().should.eventually.eql('PORTRAIT');37 });38 });39 describe('setting -', function () {40 before(async function () {41 driver = new AndroidDriver();42 await driver.createSession(Object.assign({}, DEFAULT_CAPS, {43 appActivity: '.view.TextFields'44 }));45 });46 after(async () => {47 await driver.deleteSession();48 });49 it('should rotate screen to landscape', async function () {50 await driver.setOrientation('PORTRAIT');51 await B.delay(3000);52 await driver.setOrientation('LANDSCAPE');53 await B.delay(3000);54 await driver.getOrientation().should.eventually.become('LANDSCAPE');55 });56 it('should rotate screen to landscape', async function () {...

Full Screen

Full Screen

local.js

Source:local.js Github

copy

Full Screen

1import {2 ServiceBuilder as ChromeServiceBuilder,3 Driver as ChromeDriver,4 Options as ChromeOptions,5} from 'selenium-webdriver/chrome';6import {7 ServiceBuilder as FirefoxServiceBuilder,8 Driver as FirefoxDriver,9 Options as FirefoxOptions,10 Profile as FirefoxProfile,11} from 'selenium-webdriver/firefox';12function getChromeService(binaryPath) {13 return new ChromeServiceBuilder(binaryPath);14}15function getChromeOptions() {16 return new ChromeOptions().addArguments([17 '--no-sandbox',18 'start-maximized',19 ]);20}21function getChromeDriver(binaryPath) {22 return ChromeDriver.createSession(23 getChromeOptions(),24 getChromeService(binaryPath).build()25 );26}27function getChromeDriverWithVerboseLogging(binaryPath, logPath) {28 const service = getChromeService(binaryPath)29 .enableVerboseLogging()30 .loggingTo(logPath || __dirname + '/../chromedriver.log')31 .build();32 return ChromeDriver.createSession(getChromeOptions(), service);33}34function getFirefoxService(binaryPath) {35 return new FirefoxServiceBuilder(binaryPath);36}37export function getFirefoxOptions() {38 const profile = new FirefoxProfile();39 profile.setPreference('devtools.jsonview.enabled', false);40 return new FirefoxOptions().setProfile(profile);41}42function getFirefoxDriver(binaryPath) {43 return FirefoxDriver.createSession(44 getFirefoxOptions(),45 getFirefoxService(binaryPath).build()46 );47}48function getFirefoxDriverWithVerboseLogging(binaryPath, logPath) {49 const service = getFirefoxService(binaryPath)50 .enableVerboseLogging()51 .build();52 return FirefoxDriver.createSession(getFirefoxOptions(), service);53}54export default function getLocalDriver(55 browser,56 { binaryPath, verbose, logPath }57) {58 switch (browser) {59 case 'chrome':60 if (verbose) {61 return getChromeDriverWithVerboseLogging(binaryPath, logPath);62 }63 return getChromeDriver(binaryPath);64 case 'firefox':65 if (verbose) {66 return getFirefoxDriverWithVerboseLogging(binaryPath, logPath);67 }68 return getFirefoxDriver(binaryPath);69 default:70 throw new Error(`No local driver found for "${browser}"`);71 }...

Full Screen

Full Screen

general-specs.js

Source:general-specs.js Github

copy

Full Screen

...17 sandbox.stub(driver, 'initAUT');18 sandbox.stub(driver, 'startEspressoSession');19 });20 it('update settings', async function () {21 await driver.createSession({platformName: 'Android', deviceName: 'device', appPackage: driver.caps.appPackage});22 await driver.updateSettings().should.be.rejectedWith('Method has not yet been implemented');23 });24 it('get settings', async function () {25 await driver.createSession({platformName: 'Android', deviceName: 'device', appPackage: driver.caps.appPackage});26 await driver.getSettings().should.be.rejectedWith('Method has not yet been implemented');27 });28 });29 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver'),2 until = webdriver.until;3var driver = new webdriver.Builder()4 .forBrowser('chrome')5 .build();6driver.findElement(By.name('q')).sendKeys('webdriver');7driver.findElement(By.name('btnG')).click();8driver.wait(until.titleIs('webdriver - Google Search'), 1000);9driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .end();9var webdriverio = require('webdriverio');10var options = {11 desiredCapabilities: {12 }13};14 .remote(options)15 .init()16 .end();17var webdriverio = require('webdriverio');18var options = {19 desiredCapabilities: {20 }21};22 .remote(options)23 .init()24 .end();25var webdriverio = require('webdriverio');26var options = {27 desiredCapabilities: {28 }29};30 .remote(options)31 .init()32 .end();33var webdriverio = require('webdriverio');34var options = {35 desiredCapabilities: {36 }37};38 .remote(options)39 .init()40 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2 .withCapabilities({3 }).build();4driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');5driver.findElement(webdriver.By.name('btnG')).click();6driver.wait(function() {7 return driver.getTitle().then(function(title) {8 return title === 'webdriver - Google Search';9 });10}, 1000);11driver.quit();12{13 "scripts": {14 },15 "dependencies": {16 }17}

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var driver = wd.remote("localhost", 4723);3driver.init({4 }, function(err, sessionID, caps) {5 if (err) {6 throw err;7 } else {8 console.log("sessionID is: " + sessionID);9 console.log("caps are: " + JSON.stringify(caps));10 }11 });12driver.quit();13var wd = require('wd');14var driver = wd.remote("localhost", 4723);15driver.init({16 }, function(err, sessionID, caps) {17 if (err) {18 throw err;19 } else {20 console.log("sessionID is: " + sessionID);21 console.log("caps are: " + JSON.stringify(caps));22 }23 });24driver.quit();25var wd = require('wd');26var driver = wd.remote("localhost", 4723);27driver.init({28 }, function(err, sessionID, caps) {29 if (err) {30 throw err;31 } else {32 console.log("sessionID is: " + sessionID);33 console.log("caps are: " + JSON.stringify(caps));34 }35 });36driver.elementById("myButton", function(err, element) {37 if (err) {38 throw err;39 } else {40 element.click(function(err) {41 if (err) {

Full Screen

Using AI Code Generation

copy

Full Screen

1const AppiumDriver = require('appium-android-driver');2let driver = new AppiumDriver();3driver.createSession({4 desiredCapabilities: {5 }6}).then(() => {7});8const AppiumDriver = require('appium-ios-driver');9let driver = new AppiumDriver();10driver.createSession({11 desiredCapabilities: {12 }13}).then(() => {14});15const AppiumDriver = require('appium-windows-driver');16let driver = new AppiumDriver();17driver.createSession({18 desiredCapabilities: {19 }20}).then(() => {21});22const AppiumDriver = require('appium-mac-driver');23let driver = new AppiumDriver();24driver.createSession({25 desiredCapabilities: {26 }27}).then(() => {28});29const AppiumDriver = require('appium-youiengine-driver');30let driver = new AppiumDriver();31driver.createSession({32 desiredCapabilities: {33 }34}).then(() => {35});36const AppiumDriver = require('app

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .getTitle().then(function(title) {9 console.log('Title was: ' + title);10 })11 .end();12var webdriverio = require('webdriverio');13var options = {14 desiredCapabilities: {15 }16};17 .remote(options)18 .createSession(options)19 .init()20 .getTitle().then(function(title) {21 console.log('Title was: ' + title);22 })23 .end();24var webdriverio = require('webdriverio');25var options = {26 desiredCapabilities: {27 }28};29 .remote(options)30 .init()31 .getTitle().then(function(title) {32 console.log('Title was: ' + title);33 })34 .end();35var webdriverio = require('webdriverio');36var options = {37 desiredCapabilities: {38 }39};40 .remote(options)41 .createSession(options)42 .init()43 .getTitle().then(function(title) {44 console.log('Title was: ' + title);45 })46 .end();

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