How to use webdriverio.remote method in Appium

Best JavaScript code snippet using appium

new-browser.js

Source:new-browser.js Github

copy

Full Screen

1'use strict';2const webdriverio = require('webdriverio');3const logger = require('lib/utils/logger');4const signalHandler = require('lib/signal-handler');5const history = require('lib/browser/history');6const {mkNewBrowser_: mkBrowser_, mkSessionStub_} = require('./utils');7describe('NewBrowser', () => {8 const sandbox = sinon.sandbox.create();9 let session;10 beforeEach(() => {11 session = mkSessionStub_();12 sandbox.stub(logger);13 sandbox.stub(webdriverio, 'remote').resolves(session);14 });15 afterEach(() => sandbox.restore());16 describe('constructor', () => {17 it('should create session with properties from browser config', async () => {18 await mkBrowser_().init();19 assert.calledOnceWith(webdriverio.remote, {20 protocol: 'http',21 hostname: 'test_host',22 port: 4444,23 path: '/wd/hub',24 queryParams: {query: 'value'},25 capabilities: {browserName: 'browser', version: '1.0'},26 automationProtocol: 'webdriver',27 waitforTimeout: 100,28 waitforInterval: 50,29 logLevel: 'trace',30 connectionRetryTimeout: 3000,31 connectionRetryCount: 0,32 baseUrl: 'http://base_url'33 });34 });35 it('should pass default port if it is not specified in grid url', async () => {36 await mkBrowser_({gridUrl: 'http://some-host/some-path'}).init();37 assert.calledWithMatch(webdriverio.remote, {port: 4444});38 });39 describe('should create session with extended "browserVersion" in desiredCapabilities if', () => {40 it('it is already exists in capabilities', async () => {41 await mkBrowser_(42 {desiredCapabilities: {browserName: 'browser', browserVersion: '1.0'}},43 'browser',44 '2.0'45 ).init();46 assert.calledWithMatch(webdriverio.remote, {47 capabilities: {browserName: 'browser', browserVersion: '2.0'}48 });49 });50 it('w3c protocol is used', async () => {51 await mkBrowser_(52 {sessionEnvFlags: {isW3C: true}},53 'browser',54 '2.0'55 ).init();56 assert.calledWithMatch(webdriverio.remote, {57 capabilities: {browserName: 'browser', browserVersion: '2.0'}58 });59 });60 });61 describe('extendOptions command', () => {62 it('should add command', async () => {63 await mkBrowser_().init();64 assert.calledWith(session.addCommand, 'extendOptions');65 });66 it('should add new option to wdio options', async () => {67 await mkBrowser_().init();68 session.extendOptions({newOption: 'foo'});69 assert.propertyVal(session.options, 'newOption', 'foo');70 });71 });72 });73 describe('init', () => {74 it('should resolve promise with browser', async () => {75 const browser = mkBrowser_();76 await assert.eventually.equal(browser.init(), browser);77 });78 it('should use session request timeout for create a session', async () => {79 await mkBrowser_({sessionRequestTimeout: 100500, httpTimeout: 500100}).init();80 assert.calledWithMatch(webdriverio.remote, {connectionRetryTimeout: 100500});81 });82 it('should use http timeout for create a session if session request timeout not set', async () => {83 await mkBrowser_({sessionRequestTimeout: null, httpTimeout: 500100}).init();84 assert.calledWithMatch(webdriverio.remote, {connectionRetryTimeout: 500100});85 });86 it('should reset options to default after create a session', async () => {87 await mkBrowser_().init();88 assert.callOrder(webdriverio.remote, session.extendOptions);89 });90 it('should reset http timeout to default after create a session', async () => {91 await mkBrowser_({sessionRequestTimeout: 100500, httpTimeout: 500100}).init();92 assert.propertyVal(session.options, 'connectionRetryTimeout', 500100);93 });94 it('should not set page load timeout if it is not specified in a config', async () => {95 await mkBrowser_({pageLoadTimeout: null}).init();96 assert.notCalled(session.setTimeout);97 assert.notCalled(session.setTimeouts);98 });99 describe('commands-history', () => {100 beforeEach(() => {101 sandbox.spy(history, 'initCommandHistory');102 });103 it('should NOT init commands-history if it is off', async () => {104 await mkBrowser_({saveHistory: false}).init();105 assert.notCalled(history.initCommandHistory);106 });107 it('should save history of executed commands if it is enabled', async () => {108 await mkBrowser_({saveHistory: true}).init();109 assert.calledOnceWith(history.initCommandHistory, session);110 });111 it('should init commands-history before any commands have added', async () => {112 await mkBrowser_({saveHistory: true}).init();113 assert.callOrder(history.initCommandHistory, session.addCommand);114 });115 });116 describe('set page load timeout if it is specified in a config', () => {117 let browser;118 beforeEach(() => {119 browser = mkBrowser_({pageLoadTimeout: 100500});120 });121 it('should set timeout', async () => {122 await browser.init();123 assert.calledOnceWith(session.setTimeout, {'pageLoad': 100500});124 });125 [126 {name: 'not in edge browser without w3c support', browserName: 'yabro', isW3C: false},127 {name: 'not in edge browser with w3c support', browserName: 'yabro', isW3C: true},128 {name: 'in edge browser without w3c support', browserName: 'MicrosoftEdge', isW3C: false}129 ].forEach(({name, browserName, isW3C}) => {130 it(`should throw if set timeout failed ${name}`, async () => {131 session.capabilities = {browserName};132 session.isW3C = isW3C;133 session.setTimeout.withArgs({pageLoad: 100500}).throws(new Error('o.O'));134 await assert.isRejected(browser.init(), 'o.O');135 assert.notCalled(logger.warn);136 });137 });138 it('should not throw if set timeout failed in edge browser with w3c support', async () => {139 session.capabilities = {browserName: 'MicrosoftEdge'};140 session.isW3C = true;141 session.setTimeout.withArgs({pageLoad: 100500}).throws(new Error('o.O'));142 await assert.isFulfilled(browser.init());143 assert.calledOnceWith(logger.warn, 'WARNING: Can not set page load timeout: o.O');144 });145 });146 });147 describe('reset', () => {148 it('should be fulfilled', () => assert.isFulfilled(mkBrowser_().reset()));149 });150 describe('flushHistory', () => {151 let stack;152 beforeEach(() => {153 stack = {154 flush: sinon.stub().named('stack').returns([{some: 'data'}])155 };156 sandbox.stub(history, 'initCommandHistory').returns(stack);157 });158 it('should flush a history if it if on', async () => {159 const browser = await mkBrowser_({saveHistory: true}).init();160 const res = browser.flushHistory();161 assert.deepEqual(res, [{some: 'data'}]);162 assert.called(stack.flush);163 });164 it('should return an empty array if it if off', async () => {165 const browser = await mkBrowser_({saveHistory: false}).init();166 const res = browser.flushHistory();167 assert.deepEqual(res, []);168 assert.notCalled(stack.flush);169 });170 });171 describe('quit', () => {172 it('should finalize webdriver.io session', async () => {173 const browser = await mkBrowser_().init();174 await browser.quit();175 assert.called(session.deleteSession);176 });177 it('should finalize session on global exit event', async () => {178 await mkBrowser_().init();179 signalHandler.emitAndWait('exit');180 assert.called(session.deleteSession);181 });182 it('should set custom options before finalizing of a session', async () => {183 const browser = await mkBrowser_().init();184 await browser.quit();185 assert.callOrder(session.extendOptions, session.deleteSession);186 });187 it('should use session quit timeout for finalizing of a session', async () => {188 const browser = await mkBrowser_({sessionQuitTimeout: 100500, httpTimeout: 500100}).init();189 await browser.quit();190 assert.propertyVal(session.options, 'connectionRetryTimeout', 100500);191 });192 });193 describe('sessionId', () => {194 it('should return session id of initialized webdriver session', async () => {195 session.sessionId = 'foo';196 const browser = await mkBrowser_().init();197 assert.equal(browser.sessionId, 'foo');198 });199 it('should set session id', async () => {200 session.sessionId = 'foo';201 const browser = await mkBrowser_().init();202 browser.sessionId = 'bar';203 assert.equal(browser.sessionId, 'bar');204 });205 });206 describe('error handling', () => {207 it('should warn in case of failed end', async () => {208 session.deleteSession.rejects(new Error('failed end'));209 const browser = await mkBrowser_().init();210 await browser.quit();211 assert.called(logger.warn);212 });213 });...

Full Screen

Full Screen

test_navigation.js

Source:test_navigation.js Github

copy

Full Screen

1const webdriverio = require('webdriverio');2// const chrome = require('selenium-webdriver/chrome');3const assert = require('assert');4const chai = require('chai');5const expect = chai.expect;6// chai.use(chaiAsPromised);7// chai.should();8const base_site = "http://localhost:37832";9const options = {10 desiredCapabilities: {11 browserName: 'chrome'12 }13};14let browser;15describe('Individual Navigation', function () {16 this.timeout(500000);17 before(() => {18 }19 );20 after(() => {21 browser.end();22 });23 it('should allow navigating to data', function (done) {24 browser = webdriverio25 .remote(options)26 .init()27 .url(base_site + '/individual/home')28 .setValue("input[type=\"email\"]", "alex@gmail.com")29 .setValue("input[type=\"password\"]", "password")30 .submitForm("#login-form")31 .pause(100)32 .click("//*[@id=\"navbar-options-container\"]/ul/li[2]/a")33 .waitForVisible("//*[@id=\"data-title\"]/h2")34 .getUrl()35 .then(function (value) {36 expect(value).to.equal("http://localhost:37832/individual/data");37 done();38 })39 .end()40 .catch(done);41 });42 it('should allow navigating to goals', function (done) {43 browser = webdriverio44 .remote(options)45 .init()46 .url(base_site + '/individual/home')47 .setValue("input[type=\"email\"]", "alex@gmail.com")48 .setValue("input[type=\"password\"]", "password")49 .submitForm("#login-form")50 .pause(100)51 .click("//*[@id=\"navbar-options-container\"]/ul/li[3]/a")52 .waitForVisible("//*[@id=\"goals-title\"]/h2")53 .getUrl()54 .then(function (value) {55 expect(value).to.equal("http://localhost:37832/individual/goals");56 done();57 })58 .end()59 .catch(done);60 });61 it('should allow navigating to settings', function (done) {62 browser = webdriverio63 .remote(options)64 .init()65 .url(base_site + '/individual/home')66 .setValue("input[type=\"email\"]", "alex@gmail.com")67 .setValue("input[type=\"password\"]", "password")68 .submitForm("#login-form")69 .pause(100)70 .click("//*[@id=\"navbar-options-container\"]/ul/li[4]/a")71 .waitForVisible("//*[@id=\"settings-title\"]/h2")72 .getUrl()73 .then(function (value) {74 expect(value).to.equal("http://localhost:37832/individual/settings");75 done();76 })77 .end()78 .catch(done);79 });80 it('should allow logging out', function (done) {81 browser = webdriverio82 .remote(options)83 .init()84 .url(base_site + '/individual/home')85 .setValue("input[type=\"email\"]", "alex@gmail.com")86 .setValue("input[type=\"password\"]", "password")87 .submitForm("#login-form")88 .pause(100)89 .click("//*[@id=\"navbar-auth-button\"]")90 .waitForVisible("//*[@id=\"about-content\"]/div[1]/h2")91 .getUrl()92 .then(function (value) {93 expect(value).to.equal("http://localhost:37832/");94 done();95 })96 .end()97 .catch(done);98 });99});100describe('Corporate Navigation', function () {101 this.timeout(500000);102 before(() => {103 }104 );105 after(() => {106 browser.end();107 });108 it('should allow navigating to data', function (done) {109 browser = webdriverio110 .remote(options)111 .init()112 .url(base_site + '/corporate/home')113 .setValue("input[type=\"email\"]", "company@gmail.com")114 .setValue("input[type=\"password\"]", "password")115 .submitForm("#login-form")116 .pause(100)117 .click("//*[@id=\"navbar-options-container\"]/ul/li[2]/a")118 .waitForVisible("//*[@id=\"data-title\"]/h2")119 .getUrl()120 .then(function (value) {121 expect(value).to.equal("http://localhost:37832/corporate/data");122 done();123 })124 .end()125 .catch(done);126 });127 it('should allow navigating to settings', function (done) {128 browser = webdriverio129 .remote(options)130 .init()131 .url(base_site + '/corporate/home')132 .setValue("input[type=\"email\"]", "company@gmail.com")133 .setValue("input[type=\"password\"]", "password")134 .submitForm("#login-form")135 .pause(100)136 .click("//*[@id=\"navbar-options-container\"]/ul/li[3]/a")137 .waitForVisible("//*[@id=\"settings-title\"]/h2")138 .getUrl()139 .then(function (value) {140 expect(value).to.equal("http://localhost:37832/corporate/settings");141 done();142 })143 .end()144 .catch(done);145 });146 it('should allow logging out', function (done) {147 browser = webdriverio148 .remote(options)149 .init()150 .url(base_site + '/corporate/home')151 .setValue("input[type=\"email\"]", "company@gmail.com")152 .setValue("input[type=\"password\"]", "password")153 .submitForm("#login-form")154 .pause(100)155 .click("//*[@id=\"navbar-auth-button\"]")156 .waitForVisible("//*[@id=\"about-content\"]/div[1]/h2")157 .getUrl()158 .then(function (value) {159 expect(value).to.equal("http://localhost:37832/");160 done();161 })162 .end()163 .catch(done);164 });...

Full Screen

Full Screen

suite.js

Source:suite.js Github

copy

Full Screen

1var Promise = require('es6-promise').Promise2var webdriverio = require('webdriverio')3var helper = require('./helpers')4var seleniumHelper = require('../src/helpers/selenium')5var expect = helper.expect6var sinon = helper.sinon7var lib = require('../src')8var browser = { end: function () {} }9var childProcess = { kill: function () {} }10var childPromise = Promise.resolve(childProcess)11var sharedWebdriverIO = require('./shared/webdriverio')12describe('WebdriverIO Test Harness', function () {13 describe('#setup', function () {14 beforeEach(function () {15 this.sandbox = sinon.sandbox.create()16 this.initStub = this.sandbox.stub()17 this.sandbox.stub(webdriverio, 'remote')18 this.sandbox.stub(seleniumHelper, 'setup')19 this.sandbox.stub(childProcess, 'kill')20 this.initStub.returns(Promise.resolve())21 seleniumHelper.setup.returns(childPromise)22 webdriverio.remote.returns({ init: this.initStub })23 })24 afterEach(function () {25 this.sandbox.restore()26 })27 context('With Selenium options', function () {28 beforeEach(function () {29 this.options = { selenium: { seleniumArgs: [] } }30 })31 it('setups Selenium', function () {32 var options = this.options33 return lib.setup(options).then(function () {34 expect(seleniumHelper.setup).to.be.calledOnce35 expect(seleniumHelper.setup).to.be.calledWithMatch(options.selenium)36 })37 })38 })39 context('Without Selenium options', function () {40 it('setups Selenium with defaults', function () {41 return lib.setup().then(function () {42 expect(seleniumHelper.setup).to.be.calledOnce43 expect(seleniumHelper.setup).to.be.calledWithMatch({})44 })45 })46 })47 context('With Custom Options', function () {48 context('and remoteSelenium is true', function () {49 beforeEach(function () {50 this.options = { custom: { remoteSelenium: true } }51 })52 it('does not start selenium', function () {53 var options = this.options54 return lib.setup(options).then(function () {55 expect(seleniumHelper.setup).to.not.be.called56 })57 })58 sharedWebdriverIO({59 lib: lib,60 seleniumHelper: seleniumHelper,61 childProcess: childProcess62 })63 })64 context('and remoteSelenium is false', function () {65 it('setups Selenium', function () {66 var options = this.options67 return lib.setup(options).then(function () {68 expect(seleniumHelper.setup).to.be.calledOnce69 expect(seleniumHelper.setup).to.be.calledWithMatch({})70 })71 })72 sharedWebdriverIO({73 lib: lib,74 seleniumHelper: seleniumHelper,75 childProcess: childProcess76 })77 })78 })79 context('When Selenium succeeds', function () {80 context('and with Webdriver options', function () {81 sharedWebdriverIO({82 lib: lib,83 seleniumHelper: seleniumHelper,84 childProcess: childProcess85 })86 })87 context('and without Webdriver options', function () {88 it('calls WebdriverIO remote', function () {89 return lib.setup({}).then(function () {90 expect(webdriverio.remote).to.have.been.calledOnce91 expect(webdriverio.remote).to.have.been.calledWithMatch({})92 })93 })94 it('calls WebdriverIO init', function () {95 var initStub = this.initStub96 return lib.setup({}).then(function () {97 expect(initStub).to.have.been.calledOnce98 expect(initStub).to.have.been.calledAfter(webdriverio.remote)99 expect(initStub).to.have.been.calledWithMatch({})100 })101 })102 sharedWebdriverIO({103 lib: lib,104 seleniumHelper: seleniumHelper,105 childProcess: childProcess106 })107 })108 })109 context('When Selenium is pending', function () {110 it('doies not setup WebdriverIO', function () {111 lib.setup({})112 expect(webdriverio.remote).to.not.be.called113 expect(this.initStub).to.not.be.called114 })115 })116 context('When Selenium fails', function () {117 it('does not setup WebdriverIO', function () {118 lib.setup({})119 expect(webdriverio.remote).to.not.be.called120 expect(this.initStub).to.not.be.called121 })122 })123 })124 describe('#teardown', function () {125 context('Given a Webdriverio client and Selenium process', function () {126 beforeEach(function () {127 this.sandbox = sinon.sandbox.create()128 this.sandbox.stub(browser, 'end')129 this.sandbox.stub(childProcess, 'kill')130 this.sandbox.stub(seleniumHelper, 'teardown')131 seleniumHelper.teardown.returns(Promise.resolve())132 browser.end.returns(Promise.resolve())133 })134 afterEach(function () {135 this.sandbox.restore()136 })137 it('ends Webdriverio client', function () {138 var options = {139 browser: browser,140 selenium: childProcess141 }142 return lib.teardown(options)143 .then(function () {144 expect(browser.end).to.have.been.calledOnce145 })146 })147 it('kills Selenium process', function () {148 var options = {149 browser: browser,150 selenium: childProcess151 }152 return lib.teardown(options)153 .then(function () {154 expect(seleniumHelper.teardown).to.have.been.calledOnce155 expect(seleniumHelper.teardown).to.have.been.calledWithMatch(childProcess)156 expect(seleniumHelper.teardown).to.have.been.calledAfter(browser.end)157 })158 })159 })160 })...

Full Screen

Full Screen

test_login.js

Source:test_login.js Github

copy

Full Screen

1const webdriverio = require('webdriverio');2// const chrome = require('selenium-webdriver/chrome');3const assert = require('assert');4const chai = require('chai');5const expect = chai.expect;6// chai.use(chaiAsPromised);7// chai.should();8const base_site = "http://localhost:37832";9const options = {10 desiredCapabilities: {11 browserName: 'chrome'12 }13};14let browser;15describe('Individual Login', function () {16 this.timeout(500000);17 before(() => {18 }19 );20 after(() => {21 browser.end();22 });23 it('should have a correct title', function (done) {24 browser = webdriverio25 .remote(options)26 .init()27 .url(base_site + '/individual/home')28 .getTitle()29 .then(function (title) {30 console.log(title);31 expect(title).to.equal('FHiR Visualization');32 done();33 })34 .end()35 .catch(done);36 });37 it('should accept writing username and password', function (done) {38 browser = webdriverio39 .remote(options)40 .init()41 .url(base_site + '/individual/home')42 .setValue("//*[@id=\"login-form\"]/input[1]", "alex@gmail.com")43 .getValue("//*[@id=\"login-form\"]/input[1]")44 .then(function (value) {45 console.log(value);46 expect(value).to.equal("alex@gmail.com")47 })48 .setValue("//*[@id=\"login-form\"]/input[2]", "password")49 .getValue("//*[@id=\"login-form\"]/input[2]")50 .then(function (value) {51 console.log(value);52 expect(value).to.equal("password");53 done();54 })55 .end()56 .catch(done);57 });58 it('should specify which login page it is', function (done) {59 browser = webdriverio60 .remote(options)61 .init()62 .url(base_site + '/individual/home')63 .getText("//*[@id=\"text\"]/p")64 .then(function (title) {65 console.log(title);66 expect(title).to.equal('Individual Account');67 done();68 })69 .end()70 .catch(done);71 });72 it('should allow people to log in', function (done) {73 browser = webdriverio74 .remote(options)75 .init()76 .url(base_site + '/individual/home')77 .setValue("input[type=\"email\"]", "alex@gmail.com")78 .setValue("input[type=\"password\"]", "password")79 .submitForm("#login-form")80 .waitForVisible("//*[@id=\"home-content__header\"]/h2")81 .getUrl()82 .then(function (value) {83 expect(value).to.equal("http://localhost:37832/individual/home");84 done();85 })86 .end()87 .catch(done);88 });89});90describe('Corporate Login', function () {91 this.timeout(500000);92 before(() => {93 }94 );95 after(() => {96 browser.end();97 });98 it('should accept writing username and password', function (done) {99 browser = webdriverio100 .remote(options)101 .init()102 .url(base_site + '/corporate/home')103 .setValue("//*[@id=\"login-form\"]/input[1]", "company@gmail.com")104 .getValue("//*[@id=\"login-form\"]/input[1]")105 .then(function (value) {106 console.log(value);107 expect(value).to.equal("company@gmail.com")108 })109 .setValue("//*[@id=\"login-form\"]/input[2]", "password")110 .getValue("//*[@id=\"login-form\"]/input[2]")111 .then(function (value) {112 console.log(value);113 expect(value).to.equal("password");114 done();115 })116 .end()117 .catch(done);118 });119 it('should specify which login page it is', function (done) {120 browser = webdriverio121 .remote(options)122 .init()123 .url(base_site + '/corporate/home')124 .getText("//*[@id=\"text\"]/p")125 .then(function (title) {126 console.log(title);127 expect(title).to.equal('Corporate Account');128 done();129 })130 .end()131 .catch(done);132 });133 it('should allow people to log in', function (done) {134 browser = webdriverio135 .remote(options)136 .init()137 .url(base_site + '/corporate/home')138 .setValue("input[type=\"email\"]", "company@gmail.com")139 .setValue("input[type=\"password\"]", "password")140 .submitForm("#login-form")141 .waitForVisible("//*[@id=\"home-content\"]/h2")142 .getUrl()143 .then(function (value) {144 expect(value).to.equal("http://localhost:37832/corporate/home");145 done();146 })147 .end()148 .catch(done);149 });...

Full Screen

Full Screen

add-user.steps.js

Source:add-user.steps.js Github

copy

Full Screen

1'use strict';2module.exports = function() {3 this.Given(/^I have an empty list$/, function (callback) {4 var webdriverio = require('webdriverio');5 var options = {6 desiredCapabilities: {7 browserName: 'firefox'8 }9 };10 // WebElement downloadTab = driver.findElement(By.id("menu_download"));11 // WebElement downloadLink = downloadTab.findElement(By.tagName("a"));12 // downloadLink.click();13 webdriverio14 .remote(options)15 .init()16 .url('http://localhost:3000')17 .title(function(err, res) {18 console.log('Title was: ' + res.value);19 })20 .end();21 callback();22 });23 this.When(/^I add an Employee to the list$/, function (callback) {24 // Write code here that turns the phrase above into concrete actions25 var webdriverio = require('webdriverio');26 var options = {27 desiredCapabilities: {28 browserName: 'firefox'29 }30 };31 // WebElement downloadTab = driver.findElement(By.id("menu_download"));32 // WebElement downloadLink = downloadTab.findElement(By.tagName("a"));33 // downloadLink.click();34 var timestamp = process.hrtime()35 var screenshotPath = 'SnapShots/error-report-' + timestamp +'.jpg'36 webdriverio37 .remote(options)38 .init()39 .url('http://localhost:3000')40 .title(function(err, res) {41 console.log('Title was: ' + res.value);42 })43 .click('a')44 .setValue('#editEmployeeTitle', 'Manager')45 .setValue('#editEmployeeName', 'Kristopher William Thieler')46 .submitForm('#editEmployeeSubmit')47 .saveScreenshot(screenshotPath,function(err, result) {48 console.log("screenshot saved");49 })50 .end();51 callback();52 });53 this.Then(/^The Employee list contains the newly added Employee$/, function (callback) {54 // Write code here that turns the phrase above into concrete actions55 var webdriverio = require('webdriverio');56 var options = {57 desiredCapabilities: {58 browserName: 'firefox'59 }60 };61 webdriverio62 .remote(options)63 .init()64 .url('http://localhost:3000')65 .title(function(err, res) {66 console.log('Title was: ' + res.value);67 })68 .selectByVisibleText('#selectbox', 'Kristopher William Thieler')69 .saveScreenshot('./snapshot.png')70 //.saveScreenshot('./VerifyEmployeeList.png') // Save the screenshot to disk71 .end();72 callback();73 });74 this.Given(/^I have an existing Employee in the list$/, function (callback) {75 var webdriverio = require('webdriverio');76 var options = {77 desiredCapabilities: {78 browserName: 'firefox'79 }80 };81 webdriverio82 .remote(options)83 .init()84 .url('http://localhost:3000')85 .title(function(err, res) {86 console.log('Title was: ' + res.value);87 })88 .selectByVisibleText('#selectbox', 'Kristopher William Thieler')89 .saveScreenshot('./snapshot.png');90 //.saveScreenshot('./VerifyEmployeeList.png') // Save the screenshot to disk91 //.end();92 callback();93 });94 this.When(/^I add a duplicate Employee to the list$/, function (callback) {95 // Write code here that turns the phrase above into concrete actions96 callback.pending();97 });98 this.Then(/^the HR admin is presented with an error that the employee already exists$/, function (callback) {99 // Write code here that turns the phrase above into concrete actions100 callback.pending();101 });...

Full Screen

Full Screen

webdriverio.js

Source:webdriverio.js Github

copy

Full Screen

1var Promise = require('es6-promise').Promise2var webdriverio = require('webdriverio')3var assign = require('object-assign')4var helpers = require('../helpers')5var expect = helpers.expect6module.exports = function (state) {7 var lib = state.lib8 var childProcess = state.childProcess9 context('and WebdriverIO fails', function () {10 beforeEach(function () {11 this.options = this.options || {}12 this.error = { error: true }13 this.client = Promise.reject(this.error)14 this.initStub.returns(this.client)15 this.client.end = this.sandbox.stub().returns(Promise.resolve())16 })17 it('closes the browser client', function () {18 var client = this.client19 var options = this.options20 return lib.setup(options).catch(function () {21 expect(client.end).to.have.been.called22 })23 })24 it('propagates errors', function () {25 var error = this.error26 var options = this.options27 return lib.setup(options).catch(function (err) {28 expect(err).to.eql(error)29 })30 })31 context('When ', function () {32 it('kills the selenium process', function () {33 var client = this.client34 var options = this.options35 options.custom = options.custom || {}36 options.custom.remoteSelenium = options.custom.remoteSelenium || false37 return lib.setup(options)38 .catch(function () {})39 .then(function () {40 if (options.custom.remoteSelenium) {41 expect(childProcess.kill).to.not.have.been.called42 } else {43 expect(childProcess.kill).to.have.been.calledOnce44 expect(childProcess.kill).to.have.been.calledAfter(client.end)45 }46 })47 })48 })49 })50 context('and WebdriverIO succeeds', function () {51 it('calls WebdriverIO remote', function () {52 var opts = {53 webdriverio: {54 remote: { desiredCapabilities: { browserName: 'chrome' } }55 }56 }57 var options = assign({}, this.options, opts)58 return lib.setup(options).then(function () {59 expect(webdriverio.remote).to.have.been.calledOnce60 expect(webdriverio.remote)61 .to.have.been.calledWithMatch(options.webdriverio.remote)62 })63 })64 it('calls WebdriverIO init', function () {65 var opts = {66 webdriverio: {67 init: { desiredCapabilities: { browserName: 'chrome' } }68 }69 }70 var options = assign({}, this.options, opts)71 var initStub = this.initStub72 return lib.setup(options).then(function () {73 expect(initStub).to.have.been.calledOnce74 expect(initStub).to.have.been.calledAfter(webdriverio.remote)75 expect(initStub).to.have.been.calledWithMatch(options.webdriverio.init)76 })77 })78 it('returns WebdriverIO client and Selenium process', function () {79 var client = Promise.resolve()80 var options = this.options81 this.initStub.returns(client)82 return lib.setup(options).then(function (value) {83 expect(value.browser).to.eql(client)84 expect((typeof value.selenium.kill)).to.equal('function')85 })86 })87 })...

Full Screen

Full Screen

launch.test.js

Source:launch.test.js Github

copy

Full Screen

1const webdriverio = require('webdriverio');2const launch = require('../../../../src/core/actions/launch');3const logger = require('../../../../src/utils/logger');4const { MESSAGE_TYPE, BROWSER_LAUNCH_ERR } = require('../../../../src/constants');5describe('launch test suite', () => {6 test('launch action should open browser', async () => {7 const state = {8 browser: {},9 };10 webdriverio.remote = jest.fn();11 await launch(state, { args: { browserName: 'chrome' } });12 expect(webdriverio.remote).toHaveBeenCalled();13 });14 test('launch action should log an error if something goes wrong while initializing webdriverio', async () => {15 const state = {16 browser: {},17 };18 webdriverio.remote = () => { throw new Error('Something went wrong'); };19 logger.emitLogs = jest.fn();20 await launch(state, { args: { browserName: 'chrome' } });21 expect(logger.emitLogs).toHaveBeenCalledWith({ message: BROWSER_LAUNCH_ERR, type: MESSAGE_TYPE.ERROR });22 });23 test('launch action should open browser with extension', async () => {24 const state = {25 browser: {},26 };27 webdriverio.remote = jest.fn();28 await launch(state, { args: { browserName: 'chrome', extension: 'some_extension' } });29 expect(webdriverio.remote).toHaveBeenCalled();30 });31 test('launch action should open browser in headless mode', async () => {32 const state = {33 browser: {},34 };35 webdriverio.remote = jest.fn();36 await launch(state, { args: { browserName: 'chrome', isHeadless: true } });37 expect(webdriverio.remote).toHaveBeenCalled();38 });...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {desiredCapabilities: {browserName: 'firefox'}};3webdriverio4 .remote(options)5 .init()6 .url('https://internet.frontier.com/').then(function () {7 8 var isVisible = webdriverio9 .remote(options)10 .init()11 .url('https://internet.frontier.com/')12 .isVisible('hero');13 console.log('hero', isVisible); // outputs:true14 isVisible = webdriverio15 .remote(options).init().url('https://internet.frontier.com/').isVisible('.graphic');16 console.log('graphic', isVisible); // outputs:true17 isVisible = webdriverio18 .remote(options).init().url('https://internet.frontier.com/').isVisible('.section--bg');19 console.log('section', isVisible); // outputs:true20 })21 .end()22 .catch(function (err) {23 console.log(err);...

Full Screen

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 .init()19 .getTitle().then(function(title) {20 console.log('Title was: ' + title);21 })22 .end();23var webdriverio = require('webdriverio');24var options = {25 desiredCapabilities: {26 }27};28 .remote(options)29 .init()30 .getTitle().then(function(title) {31 console.log('Title was: ' + title);32 })33 .end();34var webdriverio = require('webdriverio');35var options = {36 desiredCapabilities: {37 }38};39 .remote(options)40 .init()41 .getTitle().then(function(title) {42 console.log('Title was: ' + title);43 })44 .end();45var webdriverio = require('webdriverio');46var options = {47 desiredCapabilities: {48 }49};50 .remote(options)51 .init()52 .getTitle().then(function(title) {53 console.log('Title was: ' + title);54 })55 .end();56var webdriverio = require('webdriverio');57var options = {58 desiredCapabilities: {59 }60};61 .remote(options)62 .init()63 .getTitle().then(function(title) {64 console.log('Title was

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 .click("~button1")9 .end();10desiredCapabilities: {11}12desiredCapabilities: {13}14desiredCapabilities: {15}

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 },5};6var client = webdriverio.remote(options);7 .init()8 .setValue('android=new UiSelector().resourceId("com.example.app:id/username")', 'test')9 .setValue('android=new UiSelector().resourceId("com.example.app:id/password")', 'test')10 .click('android=new UiSelector().resourceId("com.example.app:id/login")')11 .end();12var webdriverio = require('webdriverio');13var options = {14 desiredCapabilities: {15 },16};17var client = webdriverio.remote(options);18 .init()19 .setValue('android=new UiSelector().resourceId("com.example.app:id/username")', 'test')20 .setValue('android=new UiSelector().resourceId("com.example.app:id/password")', 'test')21 .click('android=new UiSelector().resourceId("com.example.app:id/login")')22 .end();23var webdriverio = require('webdriverio');24var options = {25 desiredCapabilities: {26 },

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 .click('~buttonTest')9 .setValue('~editTextTest', 'Hello World')10 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6var client = webdriverio.remote(options);7 .init()8 .click("~App")9 .click("~Action Bar")10 .click("~Custom title")11 .click("~Custom title")12 .end();13desiredCapabilities: {14}15[Appium] Welcome to Appium v1.3.7 (REV 0d1d9c8c4e4a4c7f4d0d4f8a4f2b2d7f4b1c4e9b)

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()12 .catch(function(err) {13 console.log(err);14 });15{16 "scripts": {17 },18 "devDependencies": {19 }20}

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 .init()19 .getTitle().then(function(title) {20 console.log('Title was: ' + title);21 })22 .end();23var webdriverio = require('webdriverio');24var options = {25 desiredCapabilities: {26 }27};28 .remote(options)29 .init()30 .getTitle().then(function(title) {31 console.log('Title was: ' + title);32 })33 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var chai = require('chai');3var chaiAsPromised = require('chai-as-promised');4var appium = require('appium');5var wdioAppiumService = require('wdio-appium-service');6var wdioSeleniumStandaloneService = require('wdio-selenium-standalone-service');7var wdioChromeDriverService = require('wdio-chromedriver-service');8var wdioJUnitReporter = require('wdio-junit-reporter');9var wdioMochaFramework = require('wdio-mocha-framework');10var wdioSpecReporter = require('wdio-spec-reporter');11chai.use(chaiAsPromised);12var expect = chai.expect;13var options = {14};

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 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