How to use logDeprecationWarning method in Appium

Best JavaScript code snippet using appium

deprecated.js

Source:deprecated.js Github

copy

Full Screen

...6/* eslint-disable global-require */7/**8 * Generates a warning to tell developer that they are using deprecated methods!9 */10export function logDeprecationWarning(method, alternative) {11 console.warn(12 `${method ||13 "This method"} is deprecated and will be removed in a future otp-ui release. All language functionality should be handled using react-intl.14 ${15 alternative16 ? `17 Use ${alternative} instead, which provides a new interface that doesn't return English strings.`18 : ""19 }`20 );21}22// itinerary.js23export function getStepDirection(step) {24 logDeprecationWarning("getStepDirection");25 switch (step.relativeDirection) {26 case "DEPART":27 return `Head ${step.absoluteDirection.toLowerCase()}`;28 case "LEFT":29 return "Left";30 case "HARD_LEFT":31 return "Hard left";32 case "SLIGHTLY_LEFT":33 return "Slight left";34 case "CONTINUE":35 return "Continue";36 case "SLIGHTLY_RIGHT":37 return "Slight right";38 case "RIGHT":39 return "Right";40 case "HARD_RIGHT":41 return "Hard right";42 case "CIRCLE_CLOCKWISE":43 return "Follow circle clockwise";44 case "CIRCLE_COUNTERCLOCKWISE":45 return "Follow circle counterclockwise";46 case "ELEVATOR":47 return "Take elevator";48 case "UTURN_LEFT":49 return "Left U-turn";50 case "UTURN_RIGHT":51 return "Right U-turn";52 default:53 return step.relativeDirection;54 }55}56export function getStepInstructions(step) {57 logDeprecationWarning("getStepInstructions");58 const conjunction = step.relativeDirection === "ELEVATOR" ? "to" : "on";59 return `${getStepDirection(step)} ${conjunction} ${step.streetName}`;60}61export function getStepStreetName(step) {62 logDeprecationWarning("getStepStreetName");63 if (step.streetName === "road") return "Unnamed Road";64 if (step.streetName === "path") return "Unnamed Path";65 return step.streetName;66}67export function getLegModeLabel(leg) {68 logDeprecationWarning("getLegModeLabel");69 switch (leg.mode) {70 case "BICYCLE_RENT":71 return "Biketown";72 case "CAR":73 return leg.hailedCar ? "Ride" : "Drive";74 case "GONDOLA":75 return "Aerial Tram";76 case "TRAM":77 if (leg.routeLongName.toLowerCase().indexOf("streetcar") !== -1)78 return "Streetcar";79 return "Light Rail";80 case "MICROMOBILITY":81 case "SCOOTER":82 return "Ride";83 default:84 return require("./itinerary").toSentenceCase(leg.mode);85 }86}87/**88 * Returns mode name by checking the vertex type (VertexType class in OTP) for89 * the provided place. NOTE: this is currently only intended for vehicles at90 * the moment (not transit or walking).91 *92 * @param {string} place place from itinerary leg93 */94export function getModeForPlace(place) {95 logDeprecationWarning("getModeForPlace");96 switch (place.vertexType) {97 case "CARSHARE":98 return "car";99 case "VEHICLERENTAL":100 return "E-scooter";101 // TODO: Should the type change depending on bike vertex type?102 case "BIKESHARE":103 case "BIKEPARK":104 return "bike";105 // If company offers more than one mode, default to `vehicle` string.106 default:107 return "vehicle";108 }109}110export function getPlaceName(place, companies) {111 logDeprecationWarning("getPlaceName");112 // If address is provided (i.e. for carshare station, use it)113 if (place.address) return place.address.split(",")[0];114 if (place.networks && place.vertexType === "VEHICLERENTAL") {115 // For vehicle rental pick up, do not use the place name. Rather, use116 // company name + vehicle type (e.g., SPIN E-scooter). Place name is often just117 // a UUID that has no relevance to the actual vehicle. For bikeshare, however,118 // there are often hubs or bikes that have relevant names to the user.119 const company = require("./itinerary").getCompanyForNetwork(120 place.networks[0],121 companies122 );123 if (company) {124 return `${company.label} ${getModeForPlace(place)}`;125 }126 }127 // Default to place name128 return place.name;129}130/**131 * For a given fare component (either total fare or component parts), returns132 * an object with string formatters and the fare value (in cents).133 */134export function getTransitFare(fareComponent) {135 logDeprecationWarning("getTransitFare", "the fare object and getTncFare");136 // Default values (if fare component is not valid).137 let digits = 2;138 let transitFare = 0;139 let symbol = "$";140 let currencyCode = "USD";141 if (fareComponent) {142 // Assign values without declaration. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#assignment_without_declaration143 ({144 currencyCode,145 defaultFractionDigits: digits,146 symbol147 } = fareComponent.currency);148 transitFare = fareComponent.cents;149 }150 // For cents to string conversion, use digits from fare component.151 const centsToString = cents => {152 const dollars = (cents / 10 ** digits).toFixed(digits);153 return `${symbol}${dollars}`;154 };155 // For dollars to string conversion, assume we're rounding to two digits.156 const dollarsToString = dollars => `${symbol}${dollars.toFixed(2)}`;157 return {158 centsToString,159 currencyCode,160 dollarsToString,161 transitFare162 };163}164/**165 * For an itinerary, calculates the transit/TNC fares and returns an object with166 * these values, currency info, as well as string formatters.167 * It is assumed that the same currency is used for transit and TNC legs.168 *169 * multiple being set to true will change the output behavior:170 * - dollarsToString and centsToString will be returned as part of each fare171 * - currencyCode will be returned separately for each fare172 * - tnc currency code will be returned separately173 * - each fare type will be returned separately within a new transitFares property174 *175 * FIXME: a new approach to fare calculation must be found:176 * the current approach is not sustainable, as centsToString and DollarsToString177 * must be replaced by i18n anyway.178 *179 * However, the current behavior should ideally be kept to avoid a breaking change.180 * The "multiple" mode is helpful, but only prevents tnc fare calculation from being duplicated.181 * This method could be split out into a new one, along with tnc fare calculation.182 * If this is done, the individual fare calculation should also be modified to support183 * a default fare not being called "regular". However, this again would be a breaking change.184 * This breaking change is avoided by adding the "multiple" parameter.185 *186 * When centsToString and dollarsToString are removed, this method should be split into187 * individual fare calculation on a variable fare key, fare calculation of an entire leg,188 * which will get fares for every fare key in the leg, and a method to calculate the fare of189 * a tnc ride within the leg. This will make typescripting easier, as the types will be cleaner.190 */191export function calculateFares(itinerary, multiple = false) {192 logDeprecationWarning("calculateFares", "the fare object and getTncFare");193 // Process any TNC fares194 let minTNCFare = 0;195 let maxTNCFare = 0;196 let tncCurrencyCode;197 itinerary.legs.forEach(leg => {198 if (leg.mode === "CAR" && leg.hailedCar && leg.tncData) {199 const { currency, maxCost, minCost } = leg.tncData;200 // TODO: Support non-USD201 minTNCFare += minCost;202 maxTNCFare += maxCost;203 tncCurrencyCode = currency;204 }205 });206 if (multiple) {207 // Return object of fares208 const transitFares = {};209 if (itinerary && itinerary.fare && itinerary.fare.fare) {210 Object.keys(itinerary.fare.fare).forEach(fareKey => {211 const fareComponent = itinerary.fare.fare[fareKey];212 transitFares[fareKey] = getTransitFare(fareComponent);213 });214 }215 return {216 maxTNCFare,217 minTNCFare,218 tncCurrencyCode,219 transitFares220 };221 }222 // Extract fare total from itinerary fares.223 const fareComponent =224 itinerary.fare && itinerary.fare.fare && itinerary.fare.fare.regular;225 // Get string formatters and itinerary fare.226 const {227 centsToString,228 currencyCode: transitCurrencyCode,229 dollarsToString,230 transitFare231 } = getTransitFare(fareComponent);232 return {233 centsToString,234 currencyCode: transitCurrencyCode || tncCurrencyCode,235 dollarsToString,236 maxTNCFare,237 minTNCFare,238 transitFare239 };240}241// map.js242export function latlngToString(latlng) {243 logDeprecationWarning("latlngToString", "the latlng object");244 return (245 latlng &&246 `${latlng.lat.toFixed(5)}, ${(latlng.lng || latlng.lon).toFixed(5)}`247 );248}249export function coordsToString(coords) {250 logDeprecationWarning("coordsToString", "the coords object");251 return coords.length && coords.map(c => (+c).toFixed(5)).join(", ");252}253export function getDetailText(location) {254 let detailText;255 if (location.type === "home" || location.type === "work") {256 detailText = location.name;257 }258 if (location.type === "stop") {259 detailText = location.id;260 } else if (location.type === "recent" && location.timestamp) {261 detailText = moment(location.timestamp).fromNow();262 }263 return detailText;264}265// query.js266export function summarizeQuery(query, locations = []) {267 logDeprecationWarning("summarizeQuery");268 function findLocationType(269 location,270 ls = [],271 types = ["home", "work", "suggested"]272 ) {273 const match = ls.find(l => require("./map").matchLatLon(l, location));274 return match && types.indexOf(match.type) !== -1 ? match.type : null;275 }276 const from =277 findLocationType(query.from, locations) || query.from.name.split(",")[0];278 const to =279 findLocationType(query.to, locations) || query.to.name.split(",")[0];280 const mode = require("./itinerary").hasTransit(query.mode)281 ? "Transit"...

Full Screen

Full Screen

helper-specs.js

Source:helper-specs.js Github

copy

Full Screen

...48 afterEach(function () {49 logger.warn.restore();50 });51 it('sends a message to warn', function () {52 helpers.logDeprecationWarning('function', 'old', 'new');53 logger.warn.called.should.equal(true);54 });55 it('is only called once per run', function () {56 helpers.logDeprecationWarning('function', 'old', 'new');57 helpers.logDeprecationWarning('function', 'old', 'new');58 logger.warn.calledOnce.should.equal(true);59 });60 it('logs each message', function () {61 helpers.logDeprecationWarning('function', 'old', 'new');62 helpers.logDeprecationWarning('function', 'YeOlde', 'Moderne');63 logger.warn.calledTwice.should.equal(true);64 });65 });66 describe("#logFinalDeprecationWarning", function () {67 beforeEach(function () {68 helpers.clearWarnings();69 sinon.spy(logger, 'warn');70 });71 afterEach(function () {72 logger.warn.restore();73 });74 var warning = "[DEPRECATED] You used 1 deprecated capabilities during" +75 " this session. Please check the logs as they will be" +76 " removed in a future version of Appium.";77 it('logs a message when dep warnings happened', function () {78 helpers.logDeprecationWarning('function', 'old', 'new');79 helpers.logFinalDeprecationWarning();80 logger.warn.args[1][0].should.equal(warning);81 });82 it('does nothing if no dep warnings happened', function () {83 helpers.logFinalDeprecationWarning();84 logger.warn.called.should.equal(false);85 });86 });87 describe('xcode version', function () {88 it('parses xcode version with space', function () {89 var actual = "/Applications/ Xcode 6.1.1.app/Contents/Developer";90 var expected = "/Applications/\\ Xcode\\ 6.1.1.app/Contents/Developer";91 helpers.escapeSpace(actual).should.equal(expected);92 });...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

...64 logNonDefaultArgsWarning(showArgs);65 }66 let deprecatedArgs = getDeprecatedArgs(parser, args);67 if (_.size(deprecatedArgs)) {68 logDeprecationWarning(deprecatedArgs);69 }70 if (!_.isEmpty(args.defaultCapabilities)) {71 logDefaultCapabilitiesWarning(args.defaultCapabilities);72 }73 // TODO: bring back loglevel reporting below once logger is flushed out74 //logger.info('Console LogLevel: ' + logger.transports.console.level);75 //if (logger.transports.file) {76 //logger.info('File LogLevel: ' + logger.transports.file.level);77 //}78}79function logServerPort (address, port) {80 let logMessage = `Appium REST http interface listener started on ` +81 `${address}:${port}`;82 logger.info(logMessage);...

Full Screen

Full Screen

messages.js

Source:messages.js Github

copy

Full Screen

...8 * messages.header.description).9 */10/* eslint-disable import/prefer-default-export */11export function mergeMessages(defaultPropsMessages, propsMessages) {12 logDeprecationWarning("mergeMessages");13 const defaultMessages = defaultPropsMessages || {};14 const instanceMessages = propsMessages || {};15 return {16 ...defaultMessages,17 ...instanceMessages18 };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const log = require('appium-support').logger.getLogger('Appium');2log.logDeprecationWarning('test');3const log = require('appium-base-driver').logger.getLogger('Appium');4log.logDeprecationWarning('test');5const log = require('appium-base-plugin').logger.getLogger('Appium');6log.logDeprecationWarning('test');7const log = require('appium-support').getLogger('Appium');8log.logDeprecationWarning('test');9const log = require('appium-logger').getLogger('Appium');10log.logDeprecationWarning('test');11const log = require('appium-support').getLogger('Appium');12log.logDeprecationWarning('test');13const log = require('appium-support').getLogger('Appium');14log.logDeprecationWarning('test');15const log = require('appium-support').getLogger('Appium');16log.logDeprecationWarning('test');17const log = require('appium-support').getLogger('Appium');18log.logDeprecationWarning('test');19const log = require('appium-support').getLogger('Appium');20log.logDeprecationWarning('test');21const log = require('appium-support').getLogger('Appium');22log.logDeprecationWarning('test');23const log = require('appium-support').getLogger('Appium');24log.logDeprecationWarning('test');25const log = require('appium-support').getLogger('Appium');26log.logDeprecationWarning('test');

Full Screen

Using AI Code Generation

copy

Full Screen

1import { logger } from 'appium-support';2logger.logDeprecationWarning('test', 'test');3logger.logInfo('test', 'test');4logger.logWarn('test', 'test');5logger.logError('test', 'test');6import { logger } from 'appium-support';7logger.logDeprecationWarning('test', 'test');8logger.logInfo('test', 'test');9logger.logWarn('test', 'test');10logger.logError('test', 'test');11import { logger } from 'appium-support';12logger.logDeprecationWarning('test', 'test');13logger.logInfo('test', 'test');14logger.logWarn('test', 'test');15logger.logError('test', 'test');16import { logger } from 'appium-support';17logger.logDeprecationWarning('test', 'test');18logger.logInfo('test', 'test');19logger.logWarn('test', 'test');20logger.logError('test', 'test');21import { logger } from 'appium-support';22logger.logDeprecationWarning('test', 'test');23logger.logInfo('test', 'test');24logger.logWarn('test', 'test');25logger.logError('test', 'test');26import { logger } from 'appium-support';27logger.logDeprecationWarning('test', 'test');28logger.logInfo('test', 'test');29logger.logWarn('test', 'test');30logger.logError('test', 'test');31import { logger } from 'appium-support';32logger.logDeprecationWarning('test', 'test');33logger.logInfo('test', 'test');34logger.logWarn('test', 'test');35logger.logError('test', 'test');36import { logger } from 'appium-support';37logger.logDeprecationWarning('test', 'test');38logger.logInfo('test', 'test');39logger.logWarn('test', 'test');40logger.logError('test', 'test');

Full Screen

Using AI Code Generation

copy

Full Screen

1const AppiumLogger = require('appium-support').logger;2const logger = new AppiumLogger();3logger.logDeprecationWarning('This is a deprecation warning');4const AppiumLogger = require('appium-support').logger;5const logger = new AppiumLogger();6logger.logWarning('This is a warning');7const AppiumLogger = require('appium-support').logger;8const logger = new AppiumLogger();9logger.logInfo('This is an info');10const AppiumLogger = require('appium-support').logger;11const logger = new AppiumLogger();12logger.logDebug('This is a debug');13const AppiumLogger = require('appium-support').logger;14const logger = new AppiumLogger();15logger.logError('This is an error');16const AppiumLogger = require('appium-support').logger;17const logger = new AppiumLogger();18logger.log('This is a log');19const AppiumLogger = require('appium-support').logger;20const logger = new AppiumLogger();21logger.log('This is a log');22const AppiumLogger = require('appium-support').logger;23const logger = new AppiumLogger();24logger.log('This is a log');25const AppiumLogger = require('appium-support').logger;26const logger = new AppiumLogger();27logger.log('This is a log');28const AppiumLogger = require('appium-support').logger;29const logger = new AppiumLogger();

Full Screen

Using AI Code Generation

copy

Full Screen

1var logger = require('appium-support').logger;2logger.logDeprecationWarning('test', '1.0.0');3var logger = require('appium-support').deprecate;4logger.deprecateWarning('test', '1.0.0');5var logger = require('appium-support').deprecate;6logger.deprecate('test', '1.0.0', '2.0.0');7var logger = require('appium-support').logger;8var log = logger.getLogger('CustomLogger');9logger.logDeprecationWarning('test', '1.0.0', log);10var logger = require('appium-support').deprecate;11var log = logger.getLogger('CustomLogger');12logger.deprecateWarning('test', '1.0.0', log);13var logger = require('appium-support').deprecate;14var log = logger.getLogger('CustomLogger');15logger.deprecate('test', '1.0.0', '2.0.0', log);16var logger = require('appium-support').logger;17var log = logger.getLogger('CustomLogger');18logger.logDeprecationWarning('test', '1.0.0', log, 'Custom message');19var logger = require('appium-support').deprecate;20var log = logger.getLogger('CustomLogger');21logger.deprecateWarning('test', '1.0.0', log, 'Custom message');22var logger = require('appium-support').deprecate;23var log = logger.getLogger('CustomLogger');24logger.deprecate('test', '1.0.0', '2.0.0', log, 'Custom message');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { logger } = require('appium-support');2logger.logDeprecationWarning('test', 'test', 'test');3const { logger } = require('appium-support');4logger.logDeprecationWarning('test', 'test', 'test');5const { logger } = require('appium-support');6logger.logDeprecationWarning('test', 'test', 'test');7const { logger } = require('appium-support');8logger.logDeprecationWarning('test', 'test', 'test');9const { logger } = require('appium-support');10logger.logDeprecationWarning('test', 'test', 'test');11const { logger } = require('appium-support');12logger.logDeprecationWarning('test', 'test', 'test');13const { logger } = require('appium-support');14logger.logDeprecationWarning('test', 'test', 'test');15const { logger } = require('appium-support');16logger.logDeprecationWarning('test', 'test', 'test');17const { logger } = require('appium-support');18logger.logDeprecationWarning('test', 'test', 'test');19const { logger } = require('appium-support');20logger.logDeprecationWarning('test', 'test', 'test');21const { logger } = require('appium-support');22logger.logDeprecationWarning('test', 'test', 'test');23const { logger } = require('appium-support');24logger.logDeprecationWarning('test', 'test', 'test');25const { logger } = require

Full Screen

Using AI Code Generation

copy

Full Screen

1const log = new AppiumLogger();2log.logDeprecationWarning('testDeprecationWarning');3log.logWarning('testWarning');4const log = new AppiumLogger();5log.logInfo('testInfo');6log.logDebug('testDebug');7log.logTrace('testTrace');8const log = new AppiumLogger();9log.logError(new Error('testError'));10log.logErrorAndThrow(new Error('testErrorAndThrow'));11const log = new AppiumLogger();12log.logEvent('testEvent', {foo: 'bar'});13const log = new AppiumLogger();14log.log('testLog', 'testMessage', {foo: 'bar'});15const log = new AppiumLogger();16log.log('testLog', 'testMessage', {foo: 'bar'});17const log = new AppiumLogger();18log.log('testLog', 'testMessage', {foo: 'bar'});19const log = new AppiumLogger();20log.log('testLog', 'testMessage', {foo: 'bar'});21const log = new AppiumLogger();22log.log('testLog', 'testMessage', {foo: 'bar'});23const log = new AppiumLogger();24log.log('testLog', 'testMessage', {foo: 'bar'});25const log = new AppiumLogger();26log.log('testLog', 'test

Full Screen

Using AI Code Generation

copy

Full Screen

1class AppiumLogger {2 logDeprecationWarning (message) {3 log.warn('DEPRECATION', message);4 }5}6module.exports = AppiumLogger;7log.error('ERROR', message);8log.info('INFO', message);9log.verbose('VERBOSE', message);10log.silly('SILLY', message);11log.debug('DEBUG', message);12log.warn('WARN', message);13log.http('HTTP', message);14log.pause('PAUSE', message);15log.resume('RESUME', message);16log.silly('SILLY', message);17log.timing('TIMING', message);18log.addLevel('ADDLEVEL', 3000, { fg: 'blue', bg: 'white' }, message);19log.enableProgress();20log.disableProgress();21log.progress(message);22log.disableColor();23log.enableColor();24log.disableUnicode();25log.enableUnicode();26log.disablePrefix();27log.enablePrefix();

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