How to use refresh method in Webdriverio

Best JavaScript code snippet using webdriverio-monorepo

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 webdriverio = require('webdriverio');2var options = {3};4 .remote(options)5 .init()6 .refresh()7 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('webdriver.io page', function() {2 it('should have the right title - the fancy generator way', function () {3 var title = browser.getTitle();4 expect(title).to.be.equal('WebdriverIO - Selenium 2.0 javascript bindings for nodejs');5 browser.click('a=API');6 browser.click('a=click');7 browser.refresh();8});

Full Screen

Using AI Code Generation

copy

Full Screen

1v webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'dhrome' } };3var cesiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .refresh()9 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('webdriver.io page', function() {2 it('should have the right title - the fancy generator way', function () {3 var title = browser.getTitle();4 expect(title).to.be.equal('WebdriverIO - Selenium 2.0 javascript bindings for nodejs');5 browser.click('a=API');6 browser.click('a=click');7 browser.refresh();8 });9});

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3var client = webdriverio.remote(options);4.init()5.setValue('#lst-ib', 'WebdriverIO')6.click('#tsbb')7.pause(1000)8.refresh()9.pause(1000)10.end();

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('webdriver.io page', () => {2 it('should have the right title', () => {3 browser.refresh()4 const title = browser.getTitle()5 expect(title).toEqual('WebdriverIO · Next-gen browser and mobile automation test framework for Node.js')6 })7})8exports.config = {9 capabilities: [{10 }],11 mochaOpts: {12 }13}14{15 "scripts": {16 },17 "devDependencies": {18 }19}20{21 "dependencies": {22 "@wdio/cli": {

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('webdriver.io page', () => {2 it('should have the right title', () => {3 browser.refresh()4 const title = browser.getTitle()5 expect(title).toEqual('WebdriverIO · Next-gen browser and mobile automation test framework for Node.js')6 })7})8exports.config = {9 capabilities: [{10 }],11 mochaOpts: {12 }13}14{15 "scripts": {16 },17 "devDependencies": {18browser.refresh();19console.log(brows.getTtle());20console.log(browser.getUrl());21console.log(browser.getSourcec)h;22console.log(browser.getWindowHandle());23console.log(browser.getWindowHandles());24console.log(browser.getWindowSize());25console.log(browser.getWindowPosition());26console.log(browser.getOrientation());27console.log(browser.getAlertText());28console.log(browser.getCookies());29console.log(browser.getCookie('cookie_name'));

Full Screen

Using AI Code Generation

copy

Full Screen

1browser.refresh();2browser.refresh();3browser.refresh();4browser.refresh();5browser.refresh();6browser.refresh();7browser.refresh();8browser.refresh();9browser.refresh();10browser.refresh();11browser.refresh();12browser.refresh();13browser.refresh();14browser.refresh();15browser.refresh();16browser.refresh();17browser.refresh();18browser.refresh();19browser.refresh();20browser.refresh();21browser.refresh();22browser.refresh();23browser.refresh();24browser.refresh();25browser.refresh();26browser.refresh();27browser.refresh();28browser.refresh();

Full Screen

Using AI Code Generation

copy

Full Screen

1browser.refresh();2browser.refresh();3wser.refback();4browser.forward;5browser.back();6browser.forward();7browser.back();8browser.forward();9browser.back();10browser.back();11browser.forward();12browser.back();13browser.forward();14browser.back();15browser.forward();16browser.back();17browser.forward();18browser.back();19browser.back();20browser.forward();21browser.back();22browser.forward();23browser.back();24browser.forward();25browser.back();26browser.forward();27browser.back();28browser.forward();29browser.back();30browser.forward();31browser.back();32browser.back();33browser.forward();34browser.back();35browser.forward();36browser.back();37browser.forward();38browser.back();39browser.forward();40browser.back();41browser.forward();42browser.back();43browser.forward();44browser.back();45browser.forward();46browser.back();47browser.forward();48browser.back();49browser.refresh();50browser.refresh();51browser.refresh();

Full Screen

Using AI Code Generation

copy

Full Screen

1browser.refresh();2browser.refresh();3browser.back();4browser.forward();5browser.back();6browser.forward();7browser.back();8browser.forward();9browser.back();10browser.back();11browser.forward();12browser.back();13browser.forward();14browser.back();15browser.forward();16browser.back();17browser.forward();18browser.back();19browser.back();20browser.forward();21browser.back();22browser.forward();23browser.back();24browser.forward();25browser.back();26browser.forward();27browser.back();28browser.forward();29browser.back();30browser.forward();31browser.back();32browser.back();33browser.forward();34browser.back();35browser.forward();36browser.back();37browser.forward();38browser.back();39browser.forward();40browser.back();41browser.forward();42browser.back();43browser.forward();44browser.back();45browser.forward();46browser.back();47browser.forward();48browser.back();

Full Screen

WebdriverIO Tutorial

Wondering what could be a next-gen browser and mobile test automation framework that is also simple and concise? Yes, that’s right, it's WebdriverIO. Since the setup is very easy to follow compared to Selenium testing configuration, you can configure the features manually thereby being the center of attraction for automation testing. Therefore the testers adopt WedriverIO to fulfill their needs of browser testing.

Learn to run automation testing with WebdriverIO tutorial. Go from a beginner to a professional automation test expert with LambdaTest WebdriverIO tutorial.

Chapters

  1. Running Your First Automation Script - Learn the steps involved to execute your first Test Automation Script using WebdriverIO since the setup is very easy to follow and the features can be configured manually.

  2. Selenium Automation With WebdriverIO - Read more about automation testing with WebdriverIO and how it supports both browsers and mobile devices.

  3. Browser Commands For Selenium Testing - Understand more about the barriers faced while working on your Selenium Automation Scripts in WebdriverIO, the ‘browser’ object and how to use them?

  4. Handling Alerts & Overlay In Selenium - Learn different types of alerts faced during automation, how to handle these alerts and pops and also overlay modal in WebdriverIO.

  5. How To Use Selenium Locators? - Understand how Webdriver uses selenium locators in a most unique way since having to choose web elements very carefully for script execution is very important to get stable test results.

  6. Deep Selectors In Selenium WebdriverIO - The most popular automation testing framework that is extensively adopted by all the testers at a global level is WebdriverIO. Learn how you can use Deep Selectors in Selenium WebdriverIO.

  7. Handling Dropdown In Selenium - Learn more about handling dropdowns and how it's important while performing automated browser testing.

  8. Automated Monkey Testing with Selenium & WebdriverIO - Understand how you can leverage the amazing quality of WebdriverIO along with selenium framework to automate monkey testing of your website or web applications.

  9. JavaScript Testing with Selenium and WebdriverIO - Speed up your Javascript testing with Selenium and WebdriverIO.

  10. Cross Browser Testing With WebdriverIO - Learn more with this step-by-step tutorial about WebdriverIO framework and how cross-browser testing is done with WebdriverIO.

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