How to use d.getTimeouts method in Appium Base Driver

Best JavaScript code snippet using appium-base-driver

trait.running.spec.js

Source:trait.running.spec.js Github

copy

Full Screen

1import {2 gameDeployTraitRequest3 , gameEndTurnRequest4 , traitTakeFoodRequest5 , traitAnswerRequest6 , traitActivateRequest7 , makeTurnTimeoutId8} from '../actions';9import {PHASE} from '../../models/game/GameModel';10import * as tt from '../../models/game/evolution/traitTypes';11import {replaceGetRandom} from '../../utils/randomGenerator';12import {testShiftTime} from '../../utils/reduxTimeout'13import {makeGameSelectors} from '../../selectors';14describe('TraitRunning:', () => {15 it('carn > running', () => {16 const [{serverStore, ServerGame, ParseGame}, {clientStore0, User0}] = mockGame(1);17 const gameId = ParseGame(`18phase: feeding19food: 020players:21 - continent: $A carn waiter, $B carn, $C carn, $Runner running22`);23 const {selectPlayer, findAnimal, findTrait} = makeGameSelectors(serverStore.getState, gameId);24 expect(findTrait('$Runner', tt.TraitRunning)).ok;25 replaceGetRandom(() => 1, () => {26 clientStore0.dispatch(traitActivateRequest('$A', 'TraitCarnivorous', '$Runner'));27 expect(findAnimal('$Runner'), '$Runner ran away').ok;28 expect(ServerGame().getPlayer(User0).acted, 'User0 has acted').true;29 expect(ServerGame().status.phase).equal(PHASE.FEEDING);30 clientStore0.dispatch(gameEndTurnRequest());31 clientStore0.dispatch(traitActivateRequest('$B', 'TraitCarnivorous', '$Runner'));32 expect(findAnimal('$Runner'), '$Runner ran away').ok;33 clientStore0.dispatch(gameEndTurnRequest());34 });35 replaceGetRandom(() => 0, () => {36 expectUnchanged('Hunter has cooldown', () =>37 clientStore0.dispatch(traitActivateRequest('$A', 'TraitCarnivorous', '$Runner'))38 , serverStore, clientStore0);39 clientStore0.dispatch(traitActivateRequest('$C', 'TraitCarnivorous', '$Runner'));40 expect(findAnimal('$C').getFoodAndFat(), '$C gets food').equal(2);41 expect(findAnimal('$Runner')).null;42 });43 });44 it('B runs away manually', () => {45 const [{serverStore, ParseGame}, {clientStore0, User0}] = mockGame(1);46 const gameId = ParseGame(`47phase: feeding48players: 49 - continent: $A carn wait, $B run tail 50settings:51 timeTurn: 10052 timeTraitResponse: 10053`);54 const {selectGame, findAnimal, selectPlayer} = makeGameSelectors(serverStore.getState, gameId);55 serverStore.dispatch(testShiftTime(50));56 expect(serverStore.getTimeouts()[makeTurnTimeoutId(gameId)].remaining).equal(50);57 // C attacks A and A runs out manually58 replaceGetRandom(() => 1, () => {59 clientStore0.dispatch(traitActivateRequest('$A', tt.TraitCarnivorous, '$B'));60 expect(selectGame().question).ok;61 expect(serverStore.getTimeouts()[makeTurnTimeoutId(gameId)]).undefined;62 serverStore.dispatch(testShiftTime(50));63 clientStore0.dispatch(traitAnswerRequest(tt.TraitRunning));64 });65 expect(serverStore.getTimeouts()[makeTurnTimeoutId(gameId)].remaining).equal(50);66 expect(findAnimal('$A').getFood()).equal(0);67 expect(findAnimal('$B')).ok;68 });69 it('B runs away auto', () => {70 const [{serverStore, ParseGame}, {clientStore0, User0}] = mockGame(1);71 const gameId = ParseGame(`72phase: feeding73players: 74 - continent: $A carn wait, $B run tail 75settings:76 timeTurn: 10077 timeTraitResponse: 10078`);79 const {selectGame, findAnimal, selectPlayer} = makeGameSelectors(serverStore.getState, gameId);80 serverStore.dispatch(testShiftTime(50));81 expect(serverStore.getTimeouts()[makeTurnTimeoutId(gameId)].remaining).equal(50);82 // C attacks A and A runs out manually83 replaceGetRandom(() => 1, () => {84 clientStore0.dispatch(traitActivateRequest('$A', tt.TraitCarnivorous, '$B'));85 expect(selectGame().question).ok;86 expect(serverStore.getTimeouts()[makeTurnTimeoutId(gameId)]).undefined;87 serverStore.dispatch(testShiftTime(100));88 });89 expect(serverStore.getTimeouts()[makeTurnTimeoutId(gameId)].remaining).equal(50);90 expect(findAnimal('$A').getFood()).equal(0);91 expect(findAnimal('$B')).ok;92 });93 it('B fails running manual', () => {94 const [{serverStore, ParseGame}, {clientStore0, User0}] = mockGame(1);95 const gameId = ParseGame(`96phase: feeding97players: 98 - continent: $A carn wait, $B run tail 99settings:100 timeTurn: 100101 timeTraitResponse: 100102`);103 const {selectGame, findAnimal, selectPlayer} = makeGameSelectors(serverStore.getState, gameId);104 serverStore.dispatch(testShiftTime(50));105 expect(serverStore.getTimeouts()[makeTurnTimeoutId(gameId)].remaining).equal(50);106 // C attacks A and A runs out manually107 replaceGetRandom(() => 0, () => {108 clientStore0.dispatch(traitActivateRequest('$A', tt.TraitCarnivorous, '$B'));109 expect(selectGame().question).ok;110 clientStore0.dispatch(traitAnswerRequest(tt.TraitRunning));111 expect(selectGame().question).ok;112 });113 replaceGetRandom(() => 1, () => {114 expectUnchanged(`Running is in cooldown`, () => {115 clientStore0.dispatch(traitAnswerRequest(tt.TraitRunning));116 });117 clientStore0.dispatch(traitAnswerRequest(tt.TraitTailLoss, tt.TraitRunning));118 });119 expect(serverStore.getTimeouts()[makeTurnTimeoutId(gameId)].remaining).equal(50);120 expect(findAnimal('$A').getFood()).equal(1);121 expect(findAnimal('$B')).ok;122 });123 it('B fails running auto', () => {124 const [{serverStore, ParseGame}, {clientStore0, User0}] = mockGame(1);125 const gameId = ParseGame(`126phase: feeding127players: 128 - continent: $A carn wait, $B run tail 129settings:130 timeTurn: 100131 timeTraitResponse: 100132`);133 const {selectGame, findAnimal, selectPlayer} = makeGameSelectors(serverStore.getState, gameId);134 serverStore.dispatch(testShiftTime(50));135 expect(serverStore.getTimeouts()[makeTurnTimeoutId(gameId)].remaining).equal(50);136 // C attacks A and A runs out manually137 replaceGetRandom(() => 0, () => {138 clientStore0.dispatch(traitActivateRequest('$A', tt.TraitCarnivorous, '$B'));139 expect(selectGame().question).ok;140 serverStore.dispatch(testShiftTime(100));141 expect(selectGame().question).ok;142 });143 replaceGetRandom(() => 1, () => {144 serverStore.dispatch(testShiftTime(100));145 });146 expect(serverStore.getTimeouts()[makeTurnTimeoutId(gameId)].remaining).equal(50);147 expect(findAnimal('$A').getFood()).equal(1);148 expect(findAnimal('$B')).ok;149 });...

Full Screen

Full Screen

Timeline.js

Source:Timeline.js Github

copy

Full Screen

1define('util/Timeline', [ 'util/PubSub', 'util/CueList', 'util/Map' ], function (PubSub, CueList, Map) {2 function Timeline(coolAudio) {3 this.coolAudio = coolAudio;4 // key => CueList5 this.cueLists = { };6 // key => PubSub7 this.events = { };8 // key => Map(value => id)9 // FIXME Should be a multimap to allow multiple of the same value?10 this.timeouts = { };11 }12 function validateKey(key) {13 if (typeof key !== 'string') {14 throw new TypeError('key must be a string');15 }16 }17 function addTimeout(coolAudio, timeouts, events, value, time) {18 var timeoutId = coolAudio.setInterval(function () {19 events.publish(value);20 }, time);21 timeouts.set(value, timeoutId);22 }23 Timeline.prototype = {24 getCueList: function (key) {25 validateKey(key);26 if (!Object.prototype.hasOwnProperty.call(this.cueLists, key)) {27 this.cueLists[key] = new CueList();28 }29 return this.cueLists[key];30 },31 getEvents: function (key) {32 validateKey(key);33 if (!Object.prototype.hasOwnProperty.call(this.events, key)) {34 // We need to add timeouts for existing cues. They don't35 // have timeouts at this point due to a lack of a pubsub; see36 // Timeline#add.37 var events = new PubSub();38 var timeouts = this.getTimeouts(key);39 var cues = this.getCueList(key);40 var i;41 for (i = 0; i < cues.cueValues.length; ++i) {42 addTimeout(this.coolAudio, timeouts, events, cues.cueValues[i], cues.cueStarts[i]);43 }44 this.events[key] = events;45 }46 return this.events[key];47 },48 getTimeouts: function (key) {49 validateKey(key);50 if (!Object.prototype.hasOwnProperty.call(this.timeouts, key)) {51 this.timeouts[key] = new Map();52 }53 return this.timeouts[key];54 },55 subscribe: function (key, callback) {56 return this.getEvents(key).subscribe(callback);57 },58 add: function (key, value, startTime, endTime) {59 if (Object.prototype.hasOwnProperty.call(this.events, key)) {60 // Only bother doing timeout stuff if we potentially have61 // subscribers62 addTimeout(this.coolAudio, this.getTimeouts(key), this.events[key], value, startTime);63 }64 return this.getCueList(key).add(value, startTime, endTime);65 },66 remove: function (key, value) {67 if (Object.prototype.hasOwnProperty.call(this.timeouts, key)) {68 var timeoutId = this.timeouts[key].get(value, null);69 if (timeoutId !== null) {70 this.coolAudio.clearTimeout(timeoutId);71 }72 }73 return this.getCueList(key).remove(value);74 },75 removeMany: function (key, values) {76 if (Object.prototype.hasOwnProperty.call(this.timeouts, key)) {77 var timeouts = this.getTimeouts(key);78 values.forEach(function (value) {79 var timeoutId = timeouts.get(value, null);80 if (timeoutId !== null) {81 this.coolAudio.clearTimeout(timeoutId);82 }83 }, this);84 }85 return this.getCueList(key).removeMany(values);86 },87 getAllAtTime: function (time, key) {88 return this.getCueList(key).getAllAtTime(time);89 },90 getAllInTimeRange: function (startTime, endTime, key) {91 return this.getCueList(key).getAllInTimeRange(startTime, endTime);92 }93 };94 return Timeline;...

Full Screen

Full Screen

dpms.js

Source:dpms.js Github

copy

Full Screen

1var x11 = require('../lib');2var should = require('should');3var assert = require('assert');4var util = require('util');5describe('DPMS extension', function() {6 var display;7 var X;8 var dpms;9 before(function(done) {10 var client = x11.createClient(function(err, dpy) {11 if (!err) {12 display = dpy;13 X = display.client;14 X.require('dpms', function(err, ext) {15 should.not.exist(err);16 dpms = ext;17 done();18 });19 } else {20 done(err);21 }22 });23 client.on('error', done);24 });25 describe('Setting the DPMS timeouts to specific values', function() {26 var prev_timeouts;27 before(function(done) {28 dpms.GetTimeouts(function(err, timeouts) {29 prev_timeouts = timeouts;30 done(err);31 });32 });33 it('GetTimeouts should return those values', function(done) {34 dpms.SetTimeouts(110, 110, 110);35 dpms.GetTimeouts(function(err, timeouts) {36 if (!err) timeouts.should.eql([110, 110, 110]);37 done(err);38 });39 });40 after(function(done) {41 dpms.SetTimeouts(prev_timeouts[0], prev_timeouts[1], prev_timeouts[2]);42 dpms.GetTimeouts(function(err, timeouts) {43 if (!err) timeouts.should.eql(prev_timeouts);44 done(err);45 });46 });47 });48 describe('Changing status and level of DPMS', function() {49 var prev_status;50 var prev_level;51 before(function(done) {52 dpms.Info(function(err, info) {53 if (!err) {54 prev_level = info[0];55 prev_status = info[1];56 }57 done(err);58 });59 });60 it('Info should return the correct values', function(done) {61 if (prev_status === 0) dpms.Enable(); // for force level to work dpms must be enabled62 var new_level = prev_level === 0 ? 1 : 0;63 dpms.ForceLevel(new_level);64 dpms.Info(function(err, info) {65 if (!err) {66 info[0].should.equal(new_level);67 info[1].should.equal(1);68 }69 done(err);70 });71 });72 after(function(done) {73 dpms.ForceLevel(prev_level);74 if (prev_status) dpms.Enable();75 else dpms.Disable();76 dpms.Info(function(err, info) {77 if (!err) {78 info[0].should.equal(prev_level);79 info[1].should.equal(prev_status);80 }81 done(err);82 });83 });84 });85 after(function(done) {86 X.terminate();87 X.on('end', done);88 });...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1"use strict";2Object.defineProperty(exports, "__esModule", { value: true });3exports.Timeouts = void 0;4const tiny_typed_emitter_1 = require("tiny-typed-emitter");5class Timeouts extends tiny_typed_emitter_1.TypedEmitter {6 options;7 ready;8 client;9 constructor(client, options, init = true) {10 super();11 this.options = options;12 this.client = client;13 this.ready = false;14 if (init)15 this._init();16 }17 async getTimeouts() {18 return (await this.options.db.get('timeouts')) || [];19 }20 async create(id, time, data) {21 if (!this.ready)22 throw new Error('Manager is not ready yet');23 let timeouts = await this.getTimeouts();24 let expires = Date.now() + time;25 timeouts.push({ id, expires, time, data });26 this.options.db.set('timeouts', timeouts);27 this.emit('create', { id, expires, time, data });28 }29 async _resolve() {30 if (!this.client.readyAt)31 return;32 let timeouts = await this.getTimeouts();33 if (1 > timeouts.length)34 return;35 for (const timeout of timeouts) {36 if (Date.now() >= timeout.expires) {37 this.out(timeout.id, timeout.expires, timeout.time);38 }39 }40 }41 async out(id, expires, time) {42 let timeouts = await this.getTimeouts();43 let timeout = timeouts.find((t) => t.id === id && t.expires === expires && t.time === time);44 if (!timeout)45 return;46 this.emit('expires', timeout);47 this.deleteFromDB(id, expires, time);48 }49 async delete(func) {50 let timeouts = await this.getTimeouts();51 if (1 > timeouts.length)52 return;53 for (const timeout of timeouts) {54 if (func(timeout)) {55 this.deleteFromDB(timeout.id, timeout.expires, timeout.time);56 }57 }58 }59 async has(func) {60 let timeouts = await this.getTimeouts();61 if (1 > timeouts.length)62 return false;63 let so = false;64 for (const timeout of timeouts) {65 if (func(timeout)) {66 so = true;67 }68 }69 return so;70 }71 async deleteFromDB(id, expires, time) {72 let timeouts = await this.getTimeouts();73 for (let i = 0; i < timeouts.length; i++) {74 if (timeouts[i].id === id && timeouts[i].expires === expires && timeouts[i].time === time) {75 timeouts.splice(i, 1);76 this.options.db.set('timeouts', timeouts);77 this.emit('deleted', timeouts[i]);78 }79 }80 }81 _init() {82 setInterval(() => {83 if (this.client.readyAt)84 this._resolve.call(this);85 }, this.options.pulse);86 this.ready = true;87 this.emit('ready', this);88 }89}...

Full Screen

Full Screen

Timeouts.js

Source:Timeouts.js Github

copy

Full Screen

1/***2 public class Timeouts3 @author : Maroder4 @date : 17/01/20205 @licence : GNU/GPL6 @version : 1.07 */8const {WebDriverRestApi} = require("./restApi/WebDriverRestApi.js");9const {Logger} = require("../lib/Misc/Logger.js");10const {RunTimeException}= require("../lib/exception/RunTimeException.js");11class Timeouts{12 static #Logger;13 static #API = WebDriverRestApi.getInstance();14 #driver;15 constructor(driver) {16 Timeouts.#Logger = Logger.factory(this.constructor.name);17 this.#driver = driver;18 }19 async implicitlyWait(msTimeout){20 let response;21 if((response = await Timeouts.#API.setTimeouts(this.#driver.getSessionId(),"implicit",msTimeout)).getStatusCode() === 200 ){22 return void 0;23 }24 // Timeouts25 throw new RunTimeException(Timeouts.#Logger,response.getError());26 }27 async getImplicitTimeout( ){28 return this.getTimeouts().implicit || null;29 }30 async pageLoadTimeout(msTimeout){31 let response;32 if((response = await Timeouts.#API.setTimeouts(this.#driver.getSessionId(),"pageLoad",msTimeout)).getStatusCode() === 200 ){33 return void 0;34 }35 // Timeouts36 throw new RunTimeException(Timeouts.#Logger,response.getError());37 }38 async getPageLoadTimeout( ){39 return this.getTimeouts().pageLoad || null;40 }41 async setScriptTimeout(msTimeout){42 let response;43 if((response = await Timeouts.#API.setTimeouts(this.#driver.getSessionId(), "script",msTimeout)).getStatusCode() === 200 ){44 return void 0;45 }46 // Timeouts47 throw new RunTimeException(Timeouts.#Logger,response.getError());48 }49 async getScriptTimeout( ){50 return this.getTimeouts().script || null;51 }52 //53 async getTimeouts(){54 let response;55 if((response = await Timeouts.#API.getTimeouts(this.#driver.getSessionId())).getStatusCode() === 200 ){56 return response.getBodyAsObject();57 }58 // Timeouts59 throw new RunTimeException(Timeouts.#Logger,response.getError());60 }61}62/***63 @export64*/...

Full Screen

Full Screen

timeouts-test.js

Source:timeouts-test.js Github

copy

Full Screen

1const assert = require('assert');2describe('webdriver.io page', ()=>{3 it('should have the right title', ()=>{4 browser.url('https://webdriver.io');5 const title = browser.getTitle();6 var timeout = browser.getTimeouts();7 console.log("time out returned as : " + JSON.stringify(timeout));8 browser.setTimeouts(40000,50000,120000);9 timeout = browser.getTimeouts();10 console.log("time out returned as : " + JSON.stringify(timeout));11 assert.strictEqual(title,'WebdriverIO · Next-gen browser and mobile automation test framework for Node.js')12 })...

Full Screen

Full Screen

getTimeouts.js

Source:getTimeouts.js Github

copy

Full Screen

1"use strict";2Object.defineProperty(exports, "__esModule", { value: true });3/**4 * The Get Timeouts command gets timeout durations associated with the current session.5 *6 * @alias browser.getTimeouts7 * @see https://w3c.github.io/webdriver/#dfn-get-timeouts8 * @return {Object} Object containing timeout durations for `script`, `pageLoad` and `implicit` timeouts.9 */10function getTimeouts() {11 return {12 implicit: this.timeouts.get('implicit'),13 pageLoad: this.timeouts.get('pageLoad'),14 script: this.timeouts.get('script')15 };16}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require('webdriverio');2const opts = {3 capabilities: {4 }5};6const client = wdio.remote(opts);7client.init();8client.setTimeouts({9});10client.pause(10000);11client.end();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2driver.init({3}).then(function() {4 return driver.getTimeouts();5}).then(function(timeouts) {6 console.log(timeouts);7 return driver.quit();8}).done();9{ implicit: 0, pageLoad: 300000, script: 30000 }

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var caps = {4}5 .init(caps)6 .getTimeouts()7 .then(function (timeouts) {8 console.log(timeouts);9 })10 .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 Base 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