How to use driver.refresh method in Appium

Best JavaScript code snippet using appium

services.js

Source:services.js Github

copy

Full Screen

1//@exclude2'use strict';3//@endexclude4(function () {5 /**6 * A base object to inherit from for make corbel-js requests with custom behavior.7 * @exports Services8 * @namespace9 * @extends corbel.Object10 * @memberof corbel11 */12 var Services = corbel.Services = corbel.Object.inherit({ //instance props13 /**14 * Creates a new Services15 * @memberof corbel.Services.prototype16 * @param {string} id String with the asset id or `all` key17 * @return {corbel.Services}18 */19 constructor: function (driver) {20 this.driver = driver;21 },22 /**23 * Execute the actual ajax request.24 * Retries request with refresh token when credentials are needed.25 * Refreshes the client when a force update is detected.26 * Returns a server error (corbel.Services._FORCE_UPDATE_STATUS_CODE - unsupported_version) when force update max retries are reached27 *28 * @memberof corbel.Services.prototype29 * @param {Promise} dfd The deferred object to resolve when the ajax request is completed.30 * @param {object} args The request arguments.31 */32 request: function (args) {33 this.driver.trigger('service:request:before', args);34 var that = this;35 return this._requestWithRetries(args).then(function (response) {36 that.driver.trigger('service:request:after', response);37 that.driver.config.set(corbel.Services._UNAUTHORIZED_NUM_RETRIES, 0);38 return response;39 }).catch(function (error) {40 that.driver.trigger('service:request:after', error);41 that.driver.config.set(corbel.Services._UNAUTHORIZED_NUM_RETRIES, 0);42 throw error;43 });44 },45 _requestWithRetries: function (args) {46 var that = this;47 var maxRetries = corbel.Services._UNAUTHORIZED_MAX_RETRIES;48 var requestParameters = that._buildParams(args);49 return that._doRequest(requestParameters)50 .catch(function (response) {51 var retries = that.driver.config.get(corbel.Services._UNAUTHORIZED_NUM_RETRIES, 0);52 if (retries < maxRetries && response.status === corbel.Services._UNAUTHORIZED_STATUS_CODE) {53 //A 401 request within, refresh the token and retry the request.54 return that._refreshToken()55 .then(function () {56 that.driver.config.set(corbel.Services._UNAUTHORIZED_NUM_RETRIES, retries + 1);57 //@TODO: see if we need to upgrade the token to access assets.58 return that._requestWithRetries(args).catch(function (retryResponse) {59 // rejects whole promise with the retry response60 response = retryResponse;61 throw response;62 });63 }).catch(function () {64 //Has failed refreshing, reject request65 console.log('corbeljs:services:token:refresh:fail');66 throw response;67 });68 } else {69 console.log('corbeljs:services:token:no_refresh', response.status);70 throw response;71 }72 });73 },74 /**75 * Internal request method.76 * Has force update behavior77 * @param {object} params78 * @return {Promise}79 */80 _doRequest: function (params) {81 var that = this;82 return corbel.request.send(params, that.driver).then(function (response) {83 that.driver.config.set(corbel.Services._FORCE_UPDATE_STATUS, 0);84 that.driver.config.set(corbel.Services._UNAUTHORIZED_NUM_RETRIES, 0);85 return response;86 }).catch(function (response) {87 // Force update88 if (response.status === corbel.Services._FORCE_UPDATE_STATUS_CODE &&89 response.textStatus === corbel.Services._FORCE_UPDATE_TEXT) {90 var retries = that.driver.config.get(corbel.Services._FORCE_UPDATE_STATUS, 0);91 if (retries < corbel.Services._FORCE_UPDATE_MAX_RETRIES) {92 retries++;93 that.driver.config.set(corbel.Services._FORCE_UPDATE_STATUS, retries);94 that.driver.trigger('force:update', response);95 throw response;96 } else {97 throw response;98 }99 } else {100 throw response;101 }102 });103 },104 _refreshToken: function () {105 var tokenObject = this.driver.config.get(corbel.Iam.IAM_TOKEN, {});106 return this._refreshHandler(tokenObject);107 },108 /**109 * Default token refresh handler110 * Only requested once at the same time111 * @return {Promise}112 */113 _refreshHandler: function (tokenObject) {114 var that = this;115 if (this.driver._refreshHandlerPromise) {116 return this.driver._refreshHandlerPromise;117 }118 if (tokenObject.refreshToken) {119 console.log('corbeljs:services:token:refresh');120 this.driver._refreshHandlerPromise = this.driver.iam.token().refresh(121 tokenObject.refreshToken,122 this.driver.config.get(corbel.Iam.IAM_TOKEN_SCOPES, '')123 );124 } else {125 console.log('corbeljs:services:token:create');126 this.driver._refreshHandlerPromise = this.driver.iam.token().create();127 }128 return this.driver._refreshHandlerPromise129 .then(function (response) {130 that.driver.trigger('token:refresh', response.data);131 that.driver._refreshHandlerPromise = null;132 return response;133 }).catch(function (err) {134 that.driver._refreshHandlerPromise = null;135 throw err;136 });137 },138 /**139 * Add Authorization header with default tokenObject140 * @param {object} params request builded params141 */142 _addAuthorization: function (params) {143 var accessToken = params.accessToken ? params.accessToken : this.driver.config144 .get(corbel.Iam.IAM_TOKEN, {}).accessToken;145 if (accessToken && !params.headers.Authorization) {146 params.headers.Authorization = 'Bearer ' + accessToken;147 params.withCredentials = true;148 } else if (params.headers.Authorization) {149 params.withCredentials = true;150 }151 return params;152 },153 /**154 * Returns a valid corbel.request parameters with default values155 * and authorization params if needed.156 * By default, all request are json (dataType/contentType)157 * with object serialization support158 *159 * @memberof corbel.Services.prototype160 * @param {object} args161 * @return {object}162 */163 _buildParams: function (args) {164 // Default values165 var defaults = {166 dataType: 'json',167 contentType: 'application/json; charset=utf-8',168 dataFilter: corbel.Services.addEmptyJson,169 headers: {170 Accept: 'application/json'171 },172 method: corbel.request.method.GET173 };174 // do not modify args object175 var params = corbel.utils.defaults({}, args);176 params = corbel.utils.defaults(params, defaults);177 if (!params.url) {178 throw new Error('You must define an url');179 }180 if (params.query) {181 params.url += '?' + params.query;182 }183 if (params.noRedirect) {184 params.headers['No-Redirect'] = true;185 }186 if (params.Accept) {187 params.headers.Accept = params.Accept;188 params.dataType = undefined; // Accept & dataType are incompatibles189 }190 // set correct accept & contentType in case of blob191 // @todo: remove contentType+accept same-type constraint192 if (params.dataType === 'blob') {193 if (corbel.Config.isBrowser) {194 params.headers.Accept = params.data.type;195 params.contentType = params.data.type;196 params.dataType = undefined; // Accept & dataType are incompatibles197 }198 }199 params = this._addAuthorization(params);200 return corbel.utils.pick(params, ['url', 'dataType', 'contentType', 'method', 'headers', 'data', 'dataFilter', 'responseType', 'withCredentials', 'success', 'error']);201 },202 /**203 * @memberof corbel.Services.prototype204 * @return {string}205 */206 _buildUri: function () {207 var uri = '';208 if (this.urlBase.slice(-1) !== '/') {209 uri += '/';210 }211 Array.prototype.slice.call(arguments).forEach(function (argument) {212 if (argument) {213 uri += argument + '/';214 }215 });216 // remove last '/'217 uri = uri.slice(0, -1);218 return this.urlBase + uri;219 }220 }, {221 /**222 * _FORCE_UPDATE_TEXT constant223 * @constant224 * @memberof corbel.Services225 * @type {string}226 * @default227 */228 _FORCE_UPDATE_TEXT: 'unsupported_version',229 /**230 * _FORCE_UPDATE_MAX_RETRIES constant231 * @constant232 * @memberof corbel.Services233 * @type {number}234 * @default235 */236 _FORCE_UPDATE_MAX_RETRIES: 3,237 /**238 * _FORCE_UPDATE_STATUS constant239 * @constant240 * @memberof corbel.Services241 * @type {string}242 * @default243 */244 _FORCE_UPDATE_STATUS: 'fu_r',245 /**246 * _FORCE_UPDATE_STATUS_CODE constant247 * @constant248 * @memberof corbel.Services249 * @type {number}250 * @default251 */252 _FORCE_UPDATE_STATUS_CODE: 403,253 /**254 * _UNAUTHORIZED_MAX_RETRIES constant255 * @constant256 * @memberof corbel.Services257 * @type {number}258 * @default259 */260 _UNAUTHORIZED_MAX_RETRIES: 1,261 /**262 * _UNAUTHORIZED_NUM_RETRIES constant263 * @constant264 * @memberof corbel.Services265 * @type {string}266 * @default267 */268 _UNAUTHORIZED_NUM_RETRIES: 'un_r',269 /**270 * _UNAUTHORIZED_STATUS_CODE constant271 * @constant272 * @memberof corbel.Services273 * @type {number}274 * @default275 */276 _UNAUTHORIZED_STATUS_CODE: 401,277 /**278 * Extract a id from the location header of a requestXHR279 * @memberof corbel.Services280 * @param {Promise} responseObject response from a requestXHR281 * @return {String} id from the Location282 */283 getLocationId: function (responseObject) {284 var location = this._getLocationHeader(responseObject);285 return location ? location.substr(location.lastIndexOf('/') + 1) : undefined;286 },287 /**288 * Extracts the entire location header289 * @param {Promise} responseObject response from a requestXHR290 * @returns {String} location header content291 */292 getLocation: function (responseObject) {293 return this._getLocationHeader(responseObject);294 },295 /**296 * Extracts the location header297 * @param {Promise} responseObject response from a requestXHR298 * @returns {String} location header content299 * @private300 */301 _getLocationHeader: function (responseObject) {302 responseObject = responseObject || {};303 if (responseObject.xhr) {304 return responseObject.xhr.getResponseHeader('Location');305 } else if (responseObject.response && responseObject.response.headers.location) {306 return responseObject.response.headers.location;307 }308 },309 /**310 * @memberof corbel.Services311 * @param {mixed} response312 * @param {string} type313 * @return {midex}314 */315 addEmptyJson: function (response, type) {316 if (!response && type === 'json') {317 response = '{}';318 }319 return response;320 }321 });322 return Services;...

Full Screen

Full Screen

rides.js

Source:rides.js Github

copy

Full Screen

1import {2 RIDES_FETCH_REQUEST,3 RIDES_FETCH_SUCCESS,4 RIDES_FETCH_FAILURE,5 RIDES_REFRESH_REQUEST,6 RIDES_REFRESH_SUCCESS,7 RIDES_REFRESH_FAILURE,8 RIDES_AS_PASSENGER_FETCH_REQUEST,9 RIDES_AS_PASSENGER_FETCH_SUCCESS,10 RIDES_AS_PASSENGER_FETCH_FAILURE,11 RIDES_AS_PASSENGER_REFRESH_REQUEST,12 RIDES_AS_PASSENGER_REFRESH_SUCCESS,13 RIDES_AS_PASSENGER_REFRESH_FAILURE,14 RIDES_AS_DRIVER_FETCH_REQUEST,15 RIDES_AS_DRIVER_FETCH_SUCCESS,16 RIDES_AS_DRIVER_FETCH_FAILURE,17 RIDES_AS_DRIVER_REFRESH_REQUEST,18 RIDES_AS_DRIVER_REFRESH_SUCCESS,19 RIDES_AS_DRIVER_REFRESH_FAILURE,20 RIDE_FILTER_UPDATE,21 RIDE_SEARCH_UPDATE,22 RIDE_AS_DRIVER_FILTER_UPDATE,23 RIDE_AS_PASSENGER_FILTER_UPDATE,24 RIDE_INITIALIZE,25 RIDE_FETCH_REQUEST,26 RIDE_FETCH_SUCCESS,27 RIDE_FETCH_FAILURE,28 RIDE_OPTIONS_FETCH_REQUEST,29 RIDE_OPTIONS_FETCH_SUCCESS,30 RIDE_OPTIONS_FETCH_FAILURE,31 RIDE_CREATE_REQUEST,32 RIDE_CREATE_SUCCESS,33 RIDE_CREATE_FAILURE,34 RIDE_UPDATE_REQUEST,35 RIDE_UPDATE_SUCCESS,36 RIDE_UPDATE_FAILURE,37 RIDE_SEARCH_CLEAR,38 RIDE_FILTER_CLEAR,39 RIDE_AS_DRIVER_FILTER_CLEAR,40 RIDE_AS_PASSENGER_FILTER_CLEAR,41 RIDES_SET_DEFAULT_PER,42 RIDES_AS_PASSENGER_SET_DEFAULT_PER,43 RIDES_AS_DRIVER_SET_DEFAULT_PER,44} from '../constants/action-types';45import { APIEndpoints } from '../constants/constants';46export function refreshRides(per = 20) {47 return (dispatch, getState) => {48 const { ridesFilters } = getState()49 const filters = ridesFilters.filters50 const search = ridesFilters.search51 return dispatch({52 types: [53 RIDES_REFRESH_REQUEST,54 RIDES_REFRESH_SUCCESS,55 RIDES_REFRESH_FAILURE56 ],57 payload: {58 request: {59 url: APIEndpoints.RIDES,60 params: {61 page: 1,62 per,63 filters,64 search,65 }66 }67 },68 })69 }70}71export function fetchRides(page = 1, per = 20) {72 return (dispatch, getState) => {73 const { ridesFilters } = getState()74 const filters = ridesFilters.filters75 const search = ridesFilters.search76 return dispatch({77 types: [78 RIDES_FETCH_REQUEST,79 RIDES_FETCH_SUCCESS,80 RIDES_FETCH_FAILURE81 ],82 payload: {83 request: {84 url: APIEndpoints.RIDES,85 params: {86 page,87 per,88 filters,89 search,90 }91 }92 }93 })94 }95}96export function refreshRidesAsPassenger(user_id, per = 20) {97 return (dispatch, getState) => {98 const { ridesAsPassengerFilters } = getState()99 const filters = ridesAsPassengerFilters.filters100 return dispatch({101 types: [102 RIDES_AS_PASSENGER_REFRESH_REQUEST,103 RIDES_AS_PASSENGER_REFRESH_SUCCESS,104 RIDES_AS_PASSENGER_REFRESH_FAILURE105 ],106 payload: {107 request: {108 url: `${APIEndpoints.RIDES}/as_passenger`,109 params: {110 page: 1,111 per,112 user_id,113 filters,114 }115 }116 }117 })118 }119}120export function fetchRidesAsPassenger(user_id, page = 1, per = 20) {121 return (dispatch, getState) => {122 const { ridesAsPassengerFilters } = getState()123 const filters = ridesAsPassengerFilters.filters124 return dispatch({125 types: [126 RIDES_AS_PASSENGER_FETCH_REQUEST,127 RIDES_AS_PASSENGER_FETCH_SUCCESS,128 RIDES_AS_PASSENGER_FETCH_FAILURE129 ],130 payload: {131 request: {132 url: `${APIEndpoints.RIDES}/as_passenger`,133 params: {134 page,135 per,136 user_id,137 filters,138 }139 }140 }141 })142 }143}144export function refreshRidesAsDriver(user_id, per = 20) {145 return (dispatch, getState) => {146 const { ridesAsDriverFilters } = getState()147 const filters = ridesAsDriverFilters.filters148 return dispatch({149 types: [150 RIDES_AS_DRIVER_REFRESH_REQUEST,151 RIDES_AS_DRIVER_REFRESH_SUCCESS,152 RIDES_AS_DRIVER_REFRESH_FAILURE153 ],154 payload: {155 request: {156 url: `${APIEndpoints.RIDES}/as_driver`,157 params: {158 page: 1,159 per,160 user_id,161 filters,162 }163 }164 }165 })166 }167}168export function fetchRidesAsDriver(user_id, page = 1, per = 20) {169 return (dispatch, getState) => {170 const { ridesAsDriverFilters } = getState()171 const filters = ridesAsDriverFilters.filters172 return dispatch({173 types: [174 RIDES_AS_DRIVER_FETCH_REQUEST,175 RIDES_AS_DRIVER_FETCH_SUCCESS,176 RIDES_AS_DRIVER_FETCH_FAILURE177 ],178 payload: {179 request: {180 url: `${APIEndpoints.RIDES}/as_driver`,181 params: {182 page,183 per,184 user_id,185 filters,186 }187 }188 }189 })190 }191}192export function fetchRide(rideId) {193 return {194 types: [195 RIDE_FETCH_REQUEST,196 RIDE_FETCH_SUCCESS,197 RIDE_FETCH_FAILURE198 ],199 payload: {200 request: {201 url: `${APIEndpoints.RIDES}/${rideId}`,202 }203 }204 }205}206export function createRide(body) {207 return {208 types: [209 RIDE_CREATE_REQUEST,210 RIDE_CREATE_SUCCESS,211 RIDE_CREATE_FAILURE212 ],213 payload: {214 request: {215 method: 'post',216 url: APIEndpoints.RIDES,217 data: body218 }219 }220 }221}222export function fetchRideOptions() {223 return {224 types: [225 RIDE_OPTIONS_FETCH_REQUEST,226 RIDE_OPTIONS_FETCH_SUCCESS,227 RIDE_OPTIONS_FETCH_FAILURE228 ],229 payload: {230 request: {231 url: `${APIEndpoints.RIDES}/options`,232 }233 }234 }235}236export function updateRide(body, rideId) {237 return {238 types: [239 RIDE_UPDATE_REQUEST,240 RIDE_UPDATE_SUCCESS,241 RIDE_UPDATE_FAILURE242 ],243 payload: {244 request: {245 method: 'put',246 url: `${APIEndpoints.RIDES}/${rideId}`,247 data: body248 }249 }250 }251}252export function updateRidesSearch(search = {}) {253 return {254 type: RIDE_SEARCH_UPDATE,255 search: search256 }257}258export function updateRidesFilters(filters = {}) {259 return {260 type: RIDE_FILTER_UPDATE,261 filters: filters262 }263}264export function clearRidesSearch() {265 return {266 type: RIDE_SEARCH_CLEAR,267 }268}269export function clearRidesFilters() {270 return {271 type: RIDE_FILTER_CLEAR,272 }273}274export function updateRidesAsDriverFilters(filters = {}) {275 return {276 type: RIDE_AS_DRIVER_FILTER_UPDATE,277 filters: filters278 }279}280export function clearRidesAsDriverFilters() {281 return {282 type: RIDE_AS_DRIVER_FILTER_CLEAR,283 }284}285export function updateRidesAsPassengerFilters(filters = {}) {286 return {287 type: RIDE_AS_PASSENGER_FILTER_UPDATE,288 filters: filters289 }290}291export function clearRidesAsPassengerFilters() {292 return {293 type: RIDE_AS_PASSENGER_FILTER_CLEAR,294 }295}296export function setDefaultRidesPer(per) {297 return {298 type: RIDES_SET_DEFAULT_PER,299 per: per,300 }301}302export function setDefaultRidesAsPassengerPer(per) {303 return {304 type: RIDES_AS_PASSENGER_SET_DEFAULT_PER,305 per: per,306 }307}308export function setDefaultRidesAsDriverPer(per) {309 return {310 type: RIDES_AS_DRIVER_SET_DEFAULT_PER,311 per: per,312 }313}314export function initializeRide(ride) {315 return {316 type: RIDE_INITIALIZE,317 item: ride,318 }...

Full Screen

Full Screen

watcher.js

Source:watcher.js Github

copy

Full Screen

...7 };8 it('can get basic page activity', function() {9 this.timeout(20000);10 var driver = this.extensionDriver;11 return driver.get('https://google.com/').then(function() {return driver.refresh();12 }).then(function() {13 return new Promise(function(resolve, reject) {14 setTimeout(function() {15 driver.navigate('html/index.html#log')16 .then(function() {17 return driver.refresh();18 })19 .then(function() {20 return driver.click('.show.author');21 })22 .then(function() {23 return driver.execute(function() {24 return document.querySelectorAll('table tr.no-author').length;25 });26 }).then(function(length) {27 assert.equal(length, 1);28 }).then(resolve, reject);29 }, 3000);30 });31 })32 });33 it('can detect author information', function() {34 this.timeout(20000);35 var driver = this.extensionDriver;36 return driver.get('http://tbranyen.com/').then(function() {37 return new Promise(function(resolve, reject) {38 setTimeout(function() {39 driver.navigate('html/index.html#log')40 .then(function() {41 return driver.refresh();42 })43 .then(function() {44 return driver.wait(function() {45 return document.querySelectorAll('.show.author').length;46 })47 })48 .then(function() {49 return driver.click('.show.author');50 })51 .then(function() {52 return driver.execute(function() {53 return document.querySelectorAll('table tr.has-author').length;54 });55 }).then(function(length) {56 assert.equal(length, 1);57 }).then(resolve, reject);58 }, 1000);59 });60 });61 });62 it('will report correct time when page is visited for five seconds', function() {63 this.timeout(40000);64 var driver = this.extensionDriver;65 var delay = Date.now() + 5000;66 return driver.get('http://reddit.com/').then(function() {return driver.refresh();67 }).then(function() {68 return new Promise(function(resolve) {69 setTimeout(resolve, 5000);70 });71 })72 .then(function() {73 return driver.navigate('html/index.html#log')74 })75 .then(function() {76 return driver.refresh();77 })78 .then(function() {79 return driver.click('.show.author');80 })81 .then(function() {82 return driver.wait(function() {83 var tr = document.querySelector('[data-host="reddit.com"]');84 if (!tr) { return; }85 return tr.querySelector('.timeSpent').innerHTML;86 });87 })88 .then(function() {89 return driver.execute(function() {90 var tr = document.querySelector('[data-host="reddit.com"]');...

Full Screen

Full Screen

rides-as-driver.js

Source:rides-as-driver.js Github

copy

Full Screen

1import {2 RIDES_AS_DRIVER_FETCH_REQUEST,3 RIDES_AS_DRIVER_FETCH_SUCCESS,4 RIDES_AS_DRIVER_REFRESH_REQUEST,5 RIDES_AS_DRIVER_REFRESH_SUCCESS,6 RIDES_AS_DRIVER_SET_DEFAULT_PER,7 LOGOUT_SUCCESS,8} from '../constants/action-types';9import { unionWith, sortWith, ascend, prop } from 'ramda';10const comparator = function(a1, a2) { return a1.id === a2.id; };11const startDateSort = sortWith([12 ascend(prop('start_date')),13]);14export const initialState = {15 isStarted: false,16 isFetching: false,17 items: [],18 pagination: {},19};20export function ridesAsDriver(state = initialState, action) {21 let items, pagination22 switch (action.type) {23 case LOGOUT_SUCCESS:24 return {25 ...initialState26 };27 case RIDES_AS_DRIVER_FETCH_REQUEST:28 console.log('RIDES_AS_DRIVER_FETCH_REQUEST');29 return {30 ...state,31 isStarted: true,32 isFetching: true,33 };34 case RIDES_AS_DRIVER_FETCH_SUCCESS:35 console.log('RIDES_AS_DRIVER_FETCH_SUCCESS');36 items = action.payload.data.items37 pagination = action.payload.data.meta38 return {39 ...state,40 isFetching: false,41 items: unionWith(42 comparator,43 items,44 state.items,45 ),46 pagination: pagination,47 };48 case RIDES_AS_DRIVER_REFRESH_REQUEST:49 console.log('RIDES_AS_DRIVER_REFRESH_REQUEST');50 return {51 ...state,52 isStarted: true,53 isFetching: true,54 items: [],55 };56 case RIDES_AS_DRIVER_REFRESH_SUCCESS:57 console.log('RIDES_AS_DRIVER_REFRESH_SUCCESS');58 items = action.payload.data.items59 pagination = action.payload.data.meta60 const currentPage = pagination.per / state.defaultPer61 const totalPages = Math.ceil(pagination.total_count / state.defaultPer)62 return {63 ...state,64 isFetching: false,65 items: items,66 pagination: {67 ...pagination,68 current_page: currentPage,69 next_page: currentPage + 1,70 prev_page: currentPage - 1,71 total_pages: totalPages,72 }73 };74 case RIDES_AS_DRIVER_SET_DEFAULT_PER:75 console.log('RIDES_AS_DRIVER_SET_DEFAULT_PER');76 return {77 ...state,78 defaultPer: action.per,79 };80 default:81 return state;82 }...

Full Screen

Full Screen

CabDriverController.js

Source:CabDriverController.js Github

copy

Full Screen

1angular.module('myApp').controller('CabDriverController', function($scope, $http) {2 //driver part starts3 var DriverRefresh = function () {4 $http.get('/driv/getDriv').success(function (response) {5 console.log('READ IS SUCCESSFUL');6 $scope.DriverData = response;7 $scope.driv = "";8 });9 };10 DriverRefresh();11 $scope.addDriv = function () {12 13 $http.post('/driv/addDriv', $scope.driv).success(function (response) {14 console.log(response);15 console.log("CREATE IS SUCCESSFUL");16 17 });18 DriverRefresh(); 19 20 21 22 };23 $scope.removeDriv = function (driv) {24 //console.log(id);25 $http.delete('/driv/deleteDriv/' + driv._id).success(function (response) {26 console.log(response);27 console.log('DELETED SUCCESSFULLY');28 29 });30 DriverRefresh();31 };32 $scope.editDriv = function (driv) {33 $http.get('/driv/getDriv/' + driv._id).success(function (response) {34 $scope.driv = response[0];35 });36 }; 37 ...

Full Screen

Full Screen

secret.js

Source:secret.js Github

copy

Full Screen

1const {2 ADMIN_ACCESS_SECRET,3 MANAGER_ACCESS_SECRET,4 SUPERVISOR_ACCESS_SECRET,5 DRIVER_ACCESS_SECRET,6 ADMIN_REFRESH_SECRET,7 MANAGER_REFRESH_SECRET,8 SUPERVISOR_REFRESH_SECRET,9 DRIVER_REFRESH_SECRET,10} = process.env;11// Set access token secret key depending on role provided12const setAccessSecret = (role) => {13 let secret;14 switch (role) {15 case 'Admin':16 secret = ADMIN_ACCESS_SECRET;17 break;18 case 'Manager':19 secret = MANAGER_ACCESS_SECRET;20 break;21 case 'Supervisor':22 secret = SUPERVISOR_ACCESS_SECRET;23 break;24 case 'Driver':25 secret = DRIVER_ACCESS_SECRET;26 break;27 default:28 secret = DRIVER_ACCESS_SECRET;29 break;30 }31 return secret;32};33// Set refresh token secret key depending on role provided34const setRefreshSecret = (role) => {35 let secret;36 switch (role) {37 case 'Admin':38 secret = ADMIN_REFRESH_SECRET;39 break;40 case 'Manager':41 secret = MANAGER_REFRESH_SECRET;42 break;43 case 'Supervisor':44 secret = SUPERVISOR_REFRESH_SECRET;45 break;46 case 'Driver':47 secret = DRIVER_REFRESH_SECRET;48 break;49 default:50 secret = DRIVER_REFRESH_SECRET;51 break;52 }53 return secret;54};55module.exports = {56 setAccessSecret,57 setRefreshSecret,...

Full Screen

Full Screen

driver.socket.js

Source:driver.socket.js Github

copy

Full Screen

1'use strict';2const events = require('events');3const eventEmitter = new events.EventEmitter();4const sockets = [];5eventEmitter.on('drivers:refresh', function (drivers) {6 sockets.every(function (socket) {7 socket.emit('drivers:refresh', drivers);8 });9});10eventEmitter.on('driver:refresh', function (driver) {11 sockets.every(function (socket) {12 socket.emit('driver:refresh', driver);13 });14});15function unRegister(socket) {16 let idx = sockets.indexOf(socket);17 if (idx > -1) {18 sockets.splice(idx, 1);19 }20}21exports.register = function (socket) {22 sockets.push(socket);23 socket.on('disconnect', function () {24 unRegister(socket);25 });26};27exports.driversRefresh = function (drivers) {28 eventEmitter.emit('drivers:refresh', drivers);29};30exports.driverRefresh = function (driver) {31 eventEmitter.emit('driver:refresh', driver);...

Full Screen

Full Screen

driver.controller.js

Source:driver.controller.js Github

copy

Full Screen

1'use strict';2const socket = require('./driver.socket');3exports.driversRefresh = function (req, res) {4 socket.driversRefresh(req.body);5 return res.json(200, {message: 'Socket has been synced'});6};7exports.driverRefresh = function (req, res) {8 socket.driverRefresh(req.body);9 return res.json(200, {message: 'Socket has been synced'});...

Full Screen

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('#addContactButton')9 .setValue('#contactNameEditText', 'John')10 .setValue('#contactPhoneEditText', '1234567890')11 .setValue('#contactEmailEditText', '

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("~Alert Dialogs")10 .click("~Text Entry Dialog")11 .click("~OK")12 .setValue("~textEntry", "Hello World")13 .click("~OK")14 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder().forBrowser('chrome').build();3driver.sleep(10000);4driver.refresh();5driver.sleep(10000);6driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var asserters = wd.asserters;3var desired = {4};5var browser = wd.promiseChainRemote("localhost", 4723);6 .init(desired)7 .waitForElementByAccessibilityId('Animation', asserters.isDisplayed, 60000)8 .click()9 .waitForElementByAccessibilityId('Bouncing Balls', asserters.isDisplayed, 60000)10 .click()11 .waitForElementByAccessibilityId('WebView', asserters.isDisplayed, 60000)12 .click()13 .waitForElementByAccessibilityId('Content', asserters.isDisplayed, 60000)14 .click()15 .waitForElementByAccessibilityId('Add', asserters.isDisplayed, 60000)16 .click()17 .waitForElementByAccessibilityId('Remove', asserters.isDisplayed, 60000)18 .click()19 .waitForElementByAccessibilityId('Add', asserters.isDisplayed, 60000)20 .click()21 .waitForElementByAccessibilityId('Remove', asserters.isDisplayed, 60000)22 .click()23 .waitForElementByAccessibilityId('Add', asserters.isDisplayed, 60000)24 .click()25 .waitForElementByAccessibilityId('Remove', asserters.isDisplayed, 60000)26 .click()27 .waitForElementByAccessibilityId('Add', asserters.isDisplayed, 60000)28 .click()29 .waitForElementByAccessibilityId('Remove', asserters.isDisplayed, 60000)30 .click()31 .waitForElementByAccessibilityId('Add', asserters.isDisplayed, 60000)32 .click()33 .waitForElementByAccessibilityId('Remove', asserters.isDisplayed, 60000)34 .click()35 .waitForElementByAccessibilityId('Add', asserters.isDisplayed, 60000)36 .click()37 .waitForElementByAccessibilityId('Remove', asserters.isDisplayed, 60000)38 .click()39 .waitForElementByAccessibilityId('Add

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var desired = {4 chromeOptions: {5 }6};7var browser = wd.promiseChainRemote('localhost', 4723);8 .init(desired)9 .title()10 .then(function(title) {11 console.log(title);12 assert.ok(~title.indexOf('Google'));13 })14 .sleep(5000)15 .refresh()16 .sleep(5000)17 .quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var config = require('./config.js');4var capabilities = config.capabilities;5var driver = wd.promiseChainRemote(config.hub);6var username = config.username;7var accessKey = config.accessKey;8driver.init(capabilities).then(function() {9}).then(function() {10 return driver.refresh();11}).then(function() {12 return driver.quit();13}).done();

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.refresh();2driver.setPageLoadTimeout(5000, function () {3 console.log('Page load timeout set to 5 seconds');4});5driver.setScriptTimeout(5000, function () {6 console.log('Script timeout set to 5 seconds');7});8driver.timeouts('implicit', 5000, function () {9 console.log('Implicit timeout set to 5 seconds');10});

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.getPageSource()2driver.getPageSource()3const source = driver.getPageSource();4driver.refresh()5driver.refresh()6driver.refresh();7driver.navigate().refresh();8driver.getPageSource();

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