How to use refresh method in Appium Base Driver

Best JavaScript code snippet using appium-base-driver

token.js

Source: token.js Github

copy

Full Screen

...94 * Refresh token method. Useful in a method form as it can be override in tests.95 * @returns {Promise.<String>}96 */​97 refreshToken() {98 return this._refresh()99 .then( value => {100 this._validateTokenValue( value );101 this.set( 'value', value );102 if ( this._options.autoRefresh ) {103 this._registerRefreshTokenTimeout();104 }105 } )106 .then( () => this );107 }108 /​**109 * Destroys token instance. Stops refreshing.110 */​111 destroy() {112 clearTimeout( this._tokenRefreshTimeout );...

Full Screen

Full Screen

server_status_processes.js

Source: server_status_processes.js Github

copy

Full Screen

...119 var label = PMA_messages.strStartRefresh;120 if (processList.autoRefresh) {121 img = 'pause.png';122 label = PMA_messages.strStopRefresh;123 processList.refresh();124 }125 $('a#toggleRefresh').html(PMA_getImage(img) + escapeHtml(label));126 },127 /​**128 * Return the Url Parameters129 * for autorefresh request,130 * includes showExecuting if the filter is checked131 *132 * @return urlParams - url parameters with autoRefresh request133 */​134 getUrlParams: function() {135 var urlParams = { 'ajax_request': true, 'refresh': true };136 if ($('#showExecuting').is(":checked")) {137 urlParams.showExecuting = true;138 return urlParams;139 }140 return urlParams;141 }142};143AJAX.registerOnload('server_status_processes.js', function() {144 processList.init();145 /​/​ Bind event handler for kill_process146 $('#tableprocesslist').on(147 'click',148 'a.kill_process',149 processList.killProcessHandler150 );151 /​/​ Bind event handler for toggling refresh of process list152 $('a#toggleRefresh').on('click', function(event) {153 event.preventDefault();154 processList.autoRefresh = !processList.autoRefresh;155 processList.setRefreshLabel();156 });157 /​/​ Bind event handler for change in refresh rate158 $('#id_refreshRate').on('change', function(event) {159 processList.refreshInterval = $(this).val();160 processList.refresh();161 });162 /​/​ Bind event handler for table header links163 $('#tableprocesslist').on('click', 'thead a', function() {164 processList.refreshUrl = $(this).attr('href');165 });166});167/​**168 * Unbind all event handlers before tearing down a page169 */​170AJAX.registerTeardown('server_status_processes.js', function() {171 $('#tableprocesslist').off('click', 'a.kill_process');172 $('a#toggleRefresh').off('click');173 $('#id_refreshRate').off('change');174 $('#tableprocesslist').off('click', 'thead a');...

Full Screen

Full Screen

processes.js

Source: processes.js Github

copy

Full Screen

...73 * @param object the event object74 *75 * @return void76 */​77 refresh: function refresh() {78 /​/​ abort any previous pending requests79 /​/​ this is necessary, it may go into80 /​/​ multiple loops causing unnecessary81 /​/​ requests even after leaving the page.82 processList.abortRefresh(); /​/​ if auto refresh is enabled83 if (processList.autoRefresh) {84 var interval = parseInt(processList.refreshInterval, 10) * 1000;85 var urlParams = processList.getUrlParams();86 processList.refreshRequest = $.post(processList.refreshUrl, urlParams, function (data) {87 if (data.hasOwnProperty('success') && data.success) {88 var $newTable = $(data.message);89 $('#tableprocesslist').html($newTable.html());90 Functions.highlightSql($('#tableprocesslist'));91 }92 processList.refreshTimeout = setTimeout(processList.refresh, interval);93 });94 }95 },96 /​**97 * Stop current request and clears timeout98 *99 * @return void100 */​101 abortRefresh: function abortRefresh() {102 if (processList.refreshRequest !== null) {103 processList.refreshRequest.abort();104 processList.refreshRequest = null;105 }106 clearTimeout(processList.refreshTimeout);107 },108 /​**109 * Set label of refresh button110 * change between play & pause111 *112 * @return void113 */​114 setRefreshLabel: function setRefreshLabel() {115 var img = 'play';116 var label = Messages.strStartRefresh;117 if (processList.autoRefresh) {118 img = 'pause';119 label = Messages.strStopRefresh;120 processList.refresh();121 }122 $('a#toggleRefresh').html(Functions.getImage(img) + Functions.escapeHtml(label));123 },124 /​**125 * Return the Url Parameters126 * for autorefresh request,127 * includes showExecuting if the filter is checked128 *129 * @return urlParams - url parameters with autoRefresh request130 */​131 getUrlParams: function getUrlParams() {132 var urlParams = {133 'server': CommonParams.get('server'),134 'ajax_request': true,135 'refresh': true,136 'full': $('input[name="full"]').val(),137 'order_by_field': $('input[name="order_by_field"]').val(),138 'column_name': $('input[name="column_name"]').val(),139 'sort_order': $('input[name="sort_order"]').val()140 };141 if ($('#showExecuting').is(':checked')) {142 urlParams.showExecuting = true;143 return urlParams;144 }145 return urlParams;146 }147};148AJAX.registerOnload('server/​status/​processes.js', function () {149 processList.init(); /​/​ Bind event handler for kill_process150 $('#tableprocesslist').on('click', 'a.kill_process', processList.killProcessHandler); /​/​ Bind event handler for toggling refresh of process list151 $('a#toggleRefresh').on('click', function (event) {152 event.preventDefault();153 processList.autoRefresh = !processList.autoRefresh;154 processList.setRefreshLabel();155 }); /​/​ Bind event handler for change in refresh rate156 $('#id_refreshRate').on('change', function () {157 processList.refreshInterval = $(this).val();158 processList.refresh();159 }); /​/​ Bind event handler for table header links160 $('#tableprocesslist').on('click', 'thead a', function () {161 processList.refreshUrl = $(this).attr('href');162 });163});164/​**165 * Unbind all event handlers before tearing down a page166 */​167AJAX.registerTeardown('server/​status/​processes.js', function () {168 $('#tableprocesslist').off('click', 'a.kill_process');169 $('a#toggleRefresh').off('click');170 $('#id_refreshRate').off('change');171 $('#tableprocesslist').off('click', 'thead a'); /​/​ stop refreshing further172 processList.abortRefresh();...

Full Screen

Full Screen

jwt.js

Source: jwt.js Github

copy

Full Screen

1const jwt = require('jsonwebtoken');2const { v1: uuidv1 } = require('uuid');3const mockDB = require('./​data.mock');4const jwtSecretString = 'everybody loves ice cream';5function getAccessToken(payload) {6 return jwt.sign({user: payload}, jwtSecretString, { expiresIn: '15min' });7}8function getRefreshToken(payload) {9 /​/​ get all user's refresh tokens from DB10 const userRefreshTokens = mockDB.tokens.filter(token => token.userId === payload.id);11 /​/​ check if there are 5 or more refresh tokens,12 /​/​ which have already been generated. In this case we should13 /​/​ remove all this refresh tokens and leave only new one for security reason14 if (userRefreshTokens.length >= 5) {15 mockDB.tokens = mockDB.tokens.filter(token => token.userId !== payload.id);16 }17 const refreshToken = jwt.sign({user: payload}, jwtSecretString, { expiresIn: '30d' });18 mockDB.tokens.push({19 id: uuidv1(),20 userId: payload.id,21 refreshToken22 });23 return refreshToken;24}25function verifyJWTToken(token) {26 return new Promise((resolve, reject) => {27 if (!token.startsWith('Bearer')) {28 /​/​ Reject if there is no Bearer in the token29 return reject('Token is invalid');30 }31 /​/​ Remove Bearer from string32 token = token.slice(7, token.length);33 jwt.verify(token, jwtSecretString, (err, decodedToken) => {34 if (err) {35 return reject(err.message);36 }37 /​/​ Check the decoded user38 if (!decodedToken || !decodedToken.user) {39 return reject('Token is invalid');40 }41 resolve(decodedToken.user);42 })43 });44}45function refreshToken(token) {46 /​/​ get decoded data47 const decodedToken = jwt.verify(token, jwtSecretString);48 /​/​ find the user in the user table49 const user = mockDB.users.find(user => user.id = decodedToken.user.id);50 if (!user) {51 throw new Error(`Access is forbidden`);52 }53 /​/​ get all user's refresh tokens from DB54 const allRefreshTokens = mockDB.tokens.filter(refreshToken => refreshToken.userId === user.id);55 if (!allRefreshTokens || !allRefreshTokens.length) {56 throw new Error(`There is no refresh token for the user with`);57 }58 const currentRefreshToken = allRefreshTokens.find(refreshToken => refreshToken.refreshToken === token);59 if (!currentRefreshToken) {60 throw new Error(`Refresh token is wrong`);61 }62 /​/​ user's data for new tokens63 const payload = {64 id : user.id,65 email: user.email,66 username: user.username67 };68 /​/​ get new refresh and access token69 const newRefreshToken = getUpdatedRefreshToken(token, payload);70 const newAccessToken = getAccessToken(payload);71 return {72 accessToken: newAccessToken,73 refreshToken: newRefreshToken74 };75}76function getUpdatedRefreshToken(oldRefreshToken, payload) {77 /​/​ create new refresh token78 const newRefreshToken = jwt.sign({user: payload}, jwtSecretString, { expiresIn: '30d' });79 /​/​ replace current refresh token with new one80 mockDB.tokens = mockDB.tokens.map(token => {81 if (token.refreshToken === oldRefreshToken) {82 return {83 ...token,84 refreshToken: newRefreshToken85 };86 }87 return token;88 });89 return newRefreshToken;90}91module.exports = {92 getAccessToken,93 getRefreshToken,94 verifyJWTToken,95 refreshToken...

Full Screen

Full Screen

bootstrap-table-auto-refresh.js

Source: bootstrap-table-auto-refresh.js Github

copy

Full Screen

...29 _init.apply(this, Array.prototype.slice.apply(arguments));30 if (this.options.autoRefresh && this.options.autoRefreshStatus) {31 var that = this;32 this.options.autoRefreshFunction = setInterval(function () {33 that.refresh({silent: that.options.autoRefreshSilent});34 }, this.options.autoRefreshInterval*1000);35 }36 };37 BootstrapTable.prototype.initToolbar = function() {38 _initToolbar.apply(this, Array.prototype.slice.apply(arguments));39 if (this.options.autoRefresh) {40 var $btnGroup = this.$toolbar.find('>.btn-group');41 var $btnAutoRefresh = $btnGroup.find('.auto-refresh');42 if (!$btnAutoRefresh.length) {43 $btnAutoRefresh = $([44 sprintf('<button class="btn btn-default auto-refresh %s" ', this.options.autoRefreshStatus ? 'enabled' : ''),45 'type="button" ',46 sprintf('title="%s">', this.options.formatAutoRefresh()),47 sprintf('<i class="%s %s"></​i>', this.options.iconsPrefix, this.options.icons.autoRefresh),48 '</​button>'49 ].join('')).appendTo($btnGroup);50 $btnAutoRefresh.on('click', $.proxy(this.toggleAutoRefresh, this));51 }52 }53 };54 BootstrapTable.prototype.toggleAutoRefresh = function() {55 if (this.options.autoRefresh) {56 if (this.options.autoRefreshStatus) {57 clearInterval(this.options.autoRefreshFunction);58 this.$toolbar.find('>.btn-group').find('.auto-refresh').removeClass('enabled');59 } else {60 var that = this;61 this.options.autoRefreshFunction = setInterval(function () {62 that.refresh({silent: that.options.autoRefreshSilent});63 }, this.options.autoRefreshInterval*1000);64 this.$toolbar.find('>.btn-group').find('.auto-refresh').addClass('enabled');65 }66 this.options.autoRefreshStatus = !this.options.autoRefreshStatus;67 }68 };...

Full Screen

Full Screen

widget.js

Source: widget.js Github

copy

Full Screen

...35 refreshControl.addEventListener('refreshing', onRefreshstart);36 $.addTopLevelView(refreshControl);37 }38})(arguments[0] || {});39function refresh() {40 if (!list) {41 return;42 }43 show();44 onRefreshstart();45}46function hide() {47 if (!refreshControl) {48 return;49 }50 if (OS_IOS) {51 refreshControl.endRefreshing();52 } else if (OS_ANDROID) {53 refreshControl.setRefreshing(false);...

Full Screen

Full Screen

authorization.controller.js

Source: authorization.controller.js Github

copy

Full Screen

1const jwtSecret = require('../​../​../​common/​config/​env.config.js').jwt_secret;2const jwtExpiresIn = require('../​../​../​common/​config/​env.config.js').jwt_expires_in;3const jwt = require('jsonwebtoken');4const crypto = require('crypto');5const RefreshTokenModel = require('../​../​users/​models/​refresh-token.model');6exports.login = async (req, res) => {7 try {8 const user = req.body;9 const ipAddress = req.ip;10 const jwtToken = generateJwtToken(user);11 const refreshToken = await generateRefreshToken(user, ipAddress);12 res.status(201).send({13 user,14 accessToken: jwtToken,15 refreshToken: refreshToken.token,16 });17 } catch (err) {18 console.log("Login error: ", err);19 res.status(500).send({ errors: err });20 }21};22exports.refreshToken = async (req, res) => {23 try {24 const token = req.body.refresh_token;25 const ipAddress = req.ip;26 const refreshToken = await RefreshTokenModel.getRefreshToken(token);27 const user = refreshToken.user.toJSON();28 const jwtToken = generateJwtToken(user);29 const newRefreshToken = await generateRefreshToken(user, ipAddress);30 refreshToken.revoked = Date.now();31 refreshToken.revokedByIp = ipAddress;32 refreshToken.replacedByToken = newRefreshToken.token;33 await refreshToken.save();34 res.status(201).send({35 user,36 accessToken: jwtToken,37 refreshToken: newRefreshToken.token38 });39 } catch (err) {40 console.log("Refresh token error: ", err);41 res.status(500).send({ errors: err });42 }43}44/​/​ Helpers45function generateJwtToken (user) {46 /​/​ create a jwt token containing the user47 return jwt.sign(user, jwtSecret, { expiresIn: jwtExpiresIn });48}49function generateRefreshToken (user, ipAddress) {50 /​/​ create a refresh token that expires in 7 days51 return RefreshTokenModel.createRefreshToken({52 user: user.id,53 token: randomTokenString(),54 expires: new Date(Date.now() + 7*24*60*60*1000),55 createdByIp: ipAddress56 });57}58function randomTokenString() {59 return crypto.randomBytes(40).toString('hex');...

Full Screen

Full Screen

OAuthRefreshTokens.js

Source: OAuthRefreshTokens.js Github

copy

Full Screen

1var mongoose = require('mongoose');2var Schema = mongoose.Schema;3const OAuthRefreshToken = new Schema({4 refreshToken: String,5 refreshTokenExpiresAt: Date,6 scope: String,7 client: String,8 user: { type: Schema.Types.ObjectId, ref: 'OAuthUser' },9});10const OAuthRefreshTokens = mongoose.model('OAuthRefreshTokens', OAuthRefreshToken);11OAuthRefreshTokens.getRefreshToken = async (refreshToken) => {12 return await OAuthRefreshTokens.findOne({ refreshToken: refreshToken });13};14OAuthRefreshTokens.revokeToken = async (token) => {15 const refreshToken = await OAuthRefreshToken.findOne({refreshToken: token.refreshToken})16 if(refreshToken){17 await refreshToken.destroy()18 return true19 } else {20 return false21 }22}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1var AppiumBaseDriver = require('appium-base-driver');2var driver = new AppiumBaseDriver();3driver.refresh();4var AppiumDriver = require('appium');5var driver = new AppiumDriver();6driver.refresh();

Full Screen

Using AI Code Generation

copy

Full Screen

1appiumBaseDriver.refresh();2androidDriver.refresh();3iosDriver.refresh();4windowsDriver.refresh();5macDriver.refresh();6selendroidDriver.refresh();7firefoxDriver.refresh();8chromeDriver.refresh();9ieDriver.refresh();10operaDriver.refresh();11safariDriver.refresh();12phantomJSDriver.refresh();13remoteDriver.refresh();14eventFiringDriver.refresh();15takesScreenshotDriver.refresh();16hasInputDevicesDriver.refresh();17hasTouchScreenDriver.refresh();18rotatableDriver.refresh();19hasSessionDetailsDriver.refresh();20hasCapabilitiesDriver.refresh();21javascriptExecutorDriver.refresh();22findsByClassNameDriver.refresh();23findsByIdDriver.refresh();24findsByLinkTextDriver.refresh();25findsByNameDriver.refresh();26findsByTagNameDriver.refresh();27findsByXPathDriver.refresh();28androidElement.refresh();29iosElement.refresh();30remoteWebElement.refresh();31mobileElement.refresh();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var desired = {4};5var driver = wd.promiseChainRemote('localhost', 4723);6driver.init(desired).then(function () {7}).then(function () {8 return driver.refresh();9}).then(function () {10 return driver.title();11}).then(function (title) {12 console.log(title);13}).fin(function () {14 return driver.quit();15}).done();16[HTTP] {}17[MJSONWP] Calling AppiumDriver.refresh() with args: ["1a3a7d4e-4b9b-4a1d-8e6d-2c2d7b4c8f4a"]18 at AndroidDriver.execute (/​Applications/​Appium.app/​Contents/​Resources/​app/​node_modules/​appium/​node_modules/​appium-android-driver/​lib/​commands/​general.js:26:11)19 at AndroidDriver.callee$0$0$ (/​Applications/​Appium.app/​Contents/​Resources/​app/​node_modules/​appium/​node_modules/​appium-android-driver/​lib/​commands/​general.js:61:20)20 at tryCatch (/​Applications/​Appium.app/​Contents/​Resources/​app/​node_modules/​appium/​node_modules/​babel-runtime/​regenerator/​runtime.js:67:40)21 at GeneratorFunctionPrototype.invoke [as _invoke] (/​Applications/​Appium.app/​Contents/​Resources/​app/​node_modules/​appium/​node_modules/​babel-runtime/​regenerator/​runtime.js:315:22)22 at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/​Applications/​Appium.app/​Contents/​Resources/​app/​node_modules/​appium/​node_modules/​babel-runtime/​regenerator/​runtime.js:100:21)23 at GeneratorFunctionPrototype.invoke (/​Applications/​Appium.app/​Contents/​Resources/​app

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

How To Choose The Right Mobile App Testing Tools

Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools

13 Best Test Automation Frameworks: The 2021 List

Automation frameworks enable automation testers by simplifying the test development and execution activities. A typical automation framework provides an environment for executing test plans and generating repeatable output. They are specialized tools that assist you in your everyday test automation tasks. Whether it is a test runner, an action recording tool, or a web testing tool, it is there to remove all the hard work from building test scripts and leave you with more time to do quality checks. Test Automation is a proven, cost-effective approach to improving software development. Therefore, choosing the best test automation framework can prove crucial to your test results and QA timeframes.

Appium Testing Tutorial For Mobile Applications

The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.

27 Best Website Testing Tools In 2022

Testing is a critical step in any web application development process. However, it can be an overwhelming task if you don’t have the right tools and expertise. A large percentage of websites still launch with errors that frustrate users and negatively affect the overall success of the site. When a website faces failure after launch, it costs time and money to fix.

Top 12 Mobile App Testing Tools For 2022: A Beginner&#8217;s List

This article is a part of our Content Hub. For more in-depth resources, check out our content hub on Mobile App Testing Tutorial.

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