Best JavaScript code snippet using appium
parser.js
Source:parser.js
1import fs from 'fs';2import path from 'path';3import _ from 'lodash';4import { ArgumentParser } from 'argparse';5import pkgObj from '../../package.json'; // eslint-disable-line import/no-unresolved6const args = [7 [['--shell'], {8 required: false,9 defaultValue: null,10 help: 'Enter REPL mode',11 nargs: 0,12 dest: 'shell',13 }],14 [['--reboot'], {15 defaultValue: false,16 dest: 'reboot',17 action: 'storeTrue',18 required: false,19 help: '(Android-only) reboot emulator after each session and kill it at the end',20 nargs: 0,21 }],22 [['--ipa'], {23 required: false,24 defaultValue: null,25 help: '(IOS-only) abs path to compiled .ipa file',26 example: '/abs/path/to/my.ipa',27 dest: 'ipa',28 }],29 [['-a', '--address'], {30 defaultValue: '0.0.0.0',31 required: false,32 example: '0.0.0.0',33 help: 'IP Address to listen on',34 dest: 'address',35 }],36 [['-p', '--port'], {37 defaultValue: 4723,38 required: false,39 type: 'int',40 example: '4723',41 help: 'port to listen on',42 dest: 'port',43 }],44 [['-ca', '--callback-address'], {45 required: false,46 dest: 'callbackAddress',47 defaultValue: null,48 example: '127.0.0.1',49 help: 'callback IP Address (default: same as --address)',50 }],51 [['-cp', '--callback-port'], {52 required: false,53 dest: 'callbackPort',54 defaultValue: null,55 type: 'int',56 example: '4723',57 help: 'callback port (default: same as port)',58 }],59 [['-bp', '--bootstrap-port'], {60 defaultValue: 4724,61 dest: 'bootstrapPort',62 required: false,63 type: 'int',64 example: '4724',65 help: '(Android-only) port to use on device to talk to Appium',66 }],67 [['-r', '--backend-retries'], {68 defaultValue: 3,69 dest: 'backendRetries',70 required: false,71 type: 'int',72 example: '3',73 help: '(iOS-only) How many times to retry launching Instruments ' +74 'before saying it crashed or timed out',75 }],76 [['--session-override'], {77 defaultValue: false,78 dest: 'sessionOverride',79 action: 'storeTrue',80 required: false,81 help: 'Enables session override (clobbering)',82 nargs: 0,83 }],84 [['-l', '--pre-launch'], {85 defaultValue: false,86 dest: 'launch',87 action: 'storeTrue',88 required: false,89 help: 'Pre-launch the application before allowing the first session ' +90 '(Requires --app and, for Android, --app-pkg and --app-activity)',91 nargs: 0,92 }],93 [['-g', '--log'], {94 defaultValue: null,95 dest: 'log',96 required: false,97 example: '/path/to/appium.log',98 help: 'Also send log output to this file',99 }],100 [['--log-level'], {101 choices: ['info', 'info:debug', 'info:info', 'info:warn', 'info:error',102 'warn', 'warn:debug', 'warn:info', 'warn:warn', 'warn:error',103 'error', 'error:debug', 'error:info', 'error:warn', 'error:error',104 'debug', 'debug:debug', 'debug:info', 'debug:warn', 'debug:error'],105 defaultValue: 'debug',106 dest: 'loglevel',107 required: false,108 example: 'debug',109 help: 'log level; default (console[:file]): debug[:debug]',110 }],111 [['--log-timestamp'], {112 defaultValue: false,113 required: false,114 help: 'Show timestamps in console output',115 nargs: 0,116 action: 'storeTrue',117 dest: 'logTimestamp',118 }],119 [['--local-timezone'], {120 defaultValue: false,121 required: false,122 help: 'Use local timezone for timestamps',123 nargs: 0,124 action: 'storeTrue',125 dest: 'localTimezone',126 }],127 [['--log-no-colors'], {128 defaultValue: false,129 required: false,130 help: 'Do not use colors in console output',131 nargs: 0,132 action: 'storeTrue',133 dest: 'logNoColors',134 }],135 [['-G', '--webhook'], {136 defaultValue: null,137 required: false,138 example: 'localhost:9876',139 dest: 'webhook',140 help: 'Also send log output to this HTTP listener',141 }],142 [['--safari'], {143 defaultValue: false,144 action: 'storeTrue',145 dest: 'safari',146 required: false,147 help: '(IOS-Only) Use the safari app',148 nargs: 0,149 }],150 [['--default-device', '-dd'], {151 dest: 'defaultDevice',152 defaultValue: false,153 action: 'storeTrue',154 required: false,155 help: '(IOS-Simulator-only) use the default simulator that instruments ' +156 'launches on its own',157 }],158 [['--force-iphone'], {159 defaultValue: false,160 dest: 'forceIphone',161 action: 'storeTrue',162 required: false,163 help: '(IOS-only) Use the iPhone Simulator no matter what the app wants',164 nargs: 0,165 }],166 [['--force-ipad'], {167 defaultValue: false,168 dest: 'forceIpad',169 action: 'storeTrue',170 required: false,171 help: '(IOS-only) Use the iPad Simulator no matter what the app wants',172 nargs: 0,173 }],174 [['--tracetemplate'], {175 defaultValue: null,176 dest: 'automationTraceTemplatePath',177 required: false,178 example: '/Users/me/Automation.tracetemplate',179 help: '(IOS-only) .tracetemplate file to use with Instruments',180 }],181 [['--instruments'], {182 defaultValue: null,183 dest: 'instrumentsPath',184 require: false,185 example: '/path/to/instruments',186 help: '(IOS-only) path to instruments binary',187 }],188 [['--nodeconfig'], {189 required: false,190 defaultValue: null,191 dest: 'nodeconfig',192 help: 'Configuration JSON file to register appium with selenium grid',193 example: '/abs/path/to/nodeconfig.json',194 }],195 [['-ra', '--robot-address'], {196 defaultValue: '0.0.0.0',197 dest: 'robotAddress',198 required: false,199 example: '0.0.0.0',200 help: 'IP Address of robot',201 }],202 [['-rp', '--robot-port'], {203 defaultValue: -1,204 dest: 'robotPort',205 required: false,206 type: 'int',207 example: '4242',208 help: 'port for robot',209 }],210 [['--selendroid-port'], {211 defaultValue: 8080,212 dest: 'selendroidPort',213 required: false,214 type: 'int',215 example: '8080',216 help: 'Local port used for communication with Selendroid',217 }],218 [['--chromedriver-port'], {219 defaultValue: null,220 dest: 'chromeDriverPort',221 required: false,222 type: 'int',223 example: '9515',224 help: 'Port upon which ChromeDriver will run. If not given, Android driver will pick a random available port.',225 }],226 [['--chromedriver-executable'], {227 defaultValue: null,228 dest: 'chromedriverExecutable',229 required: false,230 help: 'ChromeDriver executable full path',231 }],232 [['--show-config'], {233 defaultValue: false,234 dest: 'showConfig',235 action: 'storeTrue',236 required: false,237 help: 'Show info about the appium server configuration and exit',238 }],239 [['--no-perms-check'], {240 defaultValue: false,241 dest: 'noPermsCheck',242 action: 'storeTrue',243 required: false,244 help: 'Bypass Appium\'s checks to ensure we can read/write necessary files',245 }],246 [['--strict-caps'], {247 defaultValue: false,248 dest: 'enforceStrictCaps',249 action: 'storeTrue',250 required: false,251 help: 'Cause sessions to fail if desired caps are sent in that Appium ' +252 'does not recognize as valid for the selected device',253 nargs: 0,254 }],255 [['--isolate-sim-device'], {256 defaultValue: false,257 dest: 'isolateSimDevice',258 action: 'storeTrue',259 required: false,260 help: 'Xcode 6 has a bug on some platforms where a certain simulator ' +261 'can only be launched without error if all other simulator devices ' +262 'are first deleted. This option causes Appium to delete all ' +263 'devices other than the one being used by Appium. Note that this ' +264 'is a permanent deletion, and you are responsible for using simctl ' +265 'or xcode to manage the categories of devices used with Appium.',266 nargs: 0,267 }],268 [['--tmp'], {269 defaultValue: null,270 dest: 'tmpDir',271 required: false,272 help: 'Absolute path to directory Appium can use to manage temporary ' +273 'files, like built-in iOS apps it needs to move around. On *nix/Mac ' +274 'defaults to /tmp, on Windows defaults to C:\\Windows\\Temp',275 }],276 [['--trace-dir'], {277 defaultValue: null,278 dest: 'traceDir',279 required: false,280 help: 'Absolute path to directory Appium use to save ios instruments ' +281 'traces, defaults to <tmp dir>/appium-instruments',282 }],283 [['--debug-log-spacing'], {284 dest: 'debugLogSpacing',285 defaultValue: false,286 action: 'storeTrue',287 required: false,288 help: 'Add exaggerated spacing in logs to help with visual inspection',289 }],290 [['--suppress-adb-kill-server'], {291 dest: 'suppressKillServer',292 defaultValue: false,293 action: 'storeTrue',294 required: false,295 help: '(Android-only) If set, prevents Appium from killing the adb server instance',296 nargs: 0,297 }],298 [['--async-trace'], {299 dest: 'asyncTrace',300 defaultValue: false,301 required: false,302 action: 'storeTrue',303 help: 'Add long stack traces to log entries. Recommended for debugging only.',304 }],305 [['--webkit-debug-proxy-port'], {306 defaultValue: 27753,307 dest: 'webkitDebugProxyPort',308 required: false,309 type: 'int',310 example: "27753",311 help: '(IOS-only) Local port used for communication with ios-webkit-debug-proxy'312 }],313 [['--webdriveragent-port'], {314 defaultValue: 8100,315 dest: 'wdaLocalPort',316 required: false,317 type: 'int',318 example: "8100",319 help: '(IOS-only, XCUITest-only) Local port used for communication with WebDriverAgent'320 }],321 [['-dc', '--default-capabilities'], {322 dest: 'defaultCapabilities',323 defaultValue: {},324 type: parseDefaultCaps,325 required: false,326 example: '[ \'{"app": "myapp.app", "deviceName": "iPhone Simulator"}\' ' +327 '| /path/to/caps.json ]',328 help: 'Set the default desired capabilities, which will be set on each ' +329 'session unless overridden by received capabilities.'330 }],331];332const deprecatedArgs = [333 [['--command-timeout'], {334 defaultValue: 60,335 dest: 'defaultCommandTimeout',336 type: 'int',337 required: false,338 help: '[DEPRECATED] No effect. This used to be the default command ' +339 'timeout for the server to use for all sessions (in seconds and ' +340 'should be less than 2147483). Use newCommandTimeout cap instead'341 }],342 [['-k', '--keep-artifacts'], {343 defaultValue: false,344 dest: 'keepArtifacts',345 action: 'storeTrue',346 required: false,347 help: '[DEPRECATED] - no effect, trace is now in tmp dir by default and is ' +348 'cleared before each run. Please also refer to the --trace-dir flag.',349 nargs: 0,350 }],351 [['--platform-name'], {352 dest: 'platformName',353 defaultValue: null,354 required: false,355 deprecatedFor: '--default-capabilities',356 example: 'iOS',357 help: '[DEPRECATED] - Name of the mobile platform: iOS, Android, or FirefoxOS',358 }],359 [['--platform-version'], {360 dest: 'platformVersion',361 defaultValue: null,362 required: false,363 deprecatedFor: '--default-capabilities',364 example: '7.1',365 help: '[DEPRECATED] - Version of the mobile platform',366 }],367 [['--automation-name'], {368 dest: 'automationName',369 defaultValue: null,370 required: false,371 deprecatedFor: '--default-capabilities',372 example: 'Appium',373 help: '[DEPRECATED] - Name of the automation tool: Appium or Selendroid',374 }],375 [['--device-name'], {376 dest: 'deviceName',377 defaultValue: null,378 required: false,379 deprecatedFor: '--default-capabilities',380 example: 'iPhone Retina (4-inch), Android Emulator',381 help: '[DEPRECATED] - Name of the mobile device to use',382 }],383 [['--browser-name'], {384 dest: 'browserName',385 defaultValue: null,386 required: false,387 deprecatedFor: '--default-capabilities',388 example: 'Safari',389 help: '[DEPRECATED] - Name of the mobile browser: Safari or Chrome',390 }],391 [['--app'], {392 dest: 'app',393 required: false,394 defaultValue: null,395 deprecatedFor: '--default-capabilities',396 help: '[DEPRECATED] - IOS: abs path to simulator-compiled .app file or the bundle_id of the desired target on device; Android: abs path to .apk file',397 example: '/abs/path/to/my.app',398 }],399 [['-lt', '--launch-timeout'], {400 defaultValue: 90000,401 dest: 'launchTimeout',402 type: 'int',403 required: false,404 deprecatedFor: '--default-capabilities',405 help: '[DEPRECATED] - (iOS-only) how long in ms to wait for Instruments to launch',406 }],407 [['--language'], {408 defaultValue: null,409 dest: 'language',410 required: false,411 example: 'en',412 deprecatedFor: '--default-capabilities',413 help: '[DEPRECATED] - Language for the iOS simulator / Android Emulator',414 }],415 [['--locale'], {416 defaultValue: null,417 dest: 'locale',418 required: false,419 example: 'en_US',420 deprecatedFor: '--default-capabilities',421 help: '[DEPRECATED] - Locale for the iOS simulator / Android Emulator',422 }],423 [['-U', '--udid'], {424 dest: 'udid',425 required: false,426 defaultValue: null,427 example: '1adsf-sdfas-asdf-123sdf',428 deprecatedFor: '--default-capabilities',429 help: '[DEPRECATED] - Unique device identifier of the connected physical device',430 }],431 [['--orientation'], {432 dest: 'orientation',433 defaultValue: null,434 required: false,435 example: 'LANDSCAPE',436 deprecatedFor: '--default-capabilities',437 help: '[DEPRECATED] - (IOS-only) use LANDSCAPE or PORTRAIT to initialize all requests ' +438 'to this orientation',439 }],440 [['--no-reset'], {441 defaultValue: false,442 dest: 'noReset',443 action: 'storeTrue',444 required: false,445 deprecatedFor: '--default-capabilities',446 help: '[DEPRECATED] - Do not reset app state between sessions (IOS: do not delete app ' +447 'plist files; Android: do not uninstall app before new session)',448 nargs: 0,449 }],450 [['--full-reset'], {451 defaultValue: false,452 dest: 'fullReset',453 action: 'storeTrue',454 required: false,455 deprecatedFor: '--default-capabilities',456 help: '[DEPRECATED] - (iOS) Delete the entire simulator folder. (Android) Reset app ' +457 'state by uninstalling app instead of clearing app data. On ' +458 'Android, this will also remove the app after the session is complete.',459 nargs: 0,460 }],461 [['--app-pkg'], {462 dest: 'appPackage',463 defaultValue: null,464 required: false,465 deprecatedFor: '--default-capabilities',466 example: 'com.example.android.myApp',467 help: '[DEPRECATED] - (Android-only) Java package of the Android app you want to run ' +468 '(e.g., com.example.android.myApp)',469 }],470 [['--app-activity'], {471 dest: 'appActivity',472 defaultValue: null,473 required: false,474 example: 'MainActivity',475 deprecatedFor: '--default-capabilities',476 help: '[DEPRECATED] - (Android-only) Activity name for the Android activity you want ' +477 'to launch from your package (e.g., MainActivity)',478 }],479 [['--app-wait-package'], {480 dest: 'appWaitPackage',481 defaultValue: false,482 required: false,483 example: 'com.example.android.myApp',484 deprecatedFor: '--default-capabilities',485 help: '[DEPRECATED] - (Android-only) Package name for the Android activity you want ' +486 'to wait for (e.g., com.example.android.myApp)',487 }],488 [['--app-wait-activity'], {489 dest: 'appWaitActivity',490 defaultValue: false,491 required: false,492 example: 'SplashActivity',493 deprecatedFor: '--default-capabilities',494 help: '[DEPRECATED] - (Android-only) Activity name for the Android activity you want ' +495 'to wait for (e.g., SplashActivity)',496 }],497 [['--device-ready-timeout'], {498 dest: 'deviceReadyTimeout',499 defaultValue: 5,500 required: false,501 type: 'int',502 example: '5',503 deprecatedFor: '--default-capabilities',504 help: '[DEPRECATED] - (Android-only) Timeout in seconds while waiting for device to become ready',505 }],506 [['--android-coverage'], {507 dest: 'androidCoverage',508 defaultValue: false,509 required: false,510 example: 'com.my.Pkg/com.my.Pkg.instrumentation.MyInstrumentation',511 deprecatedFor: '--default-capabilities',512 help: '[DEPRECATED] - (Android-only) Fully qualified instrumentation class. Passed to -w in ' +513 'adb shell am instrument -e coverage true -w ',514 }],515 [['--avd'], {516 dest: 'avd',517 defaultValue: null,518 required: false,519 example: '@default',520 deprecatedFor: '--default-capabilities',521 help: '[DEPRECATED] - (Android-only) Name of the avd to launch',522 }],523 [['--avd-args'], {524 dest: 'avdArgs',525 defaultValue: null,526 required: false,527 example: '-no-snapshot-load',528 deprecatedFor: '--default-capabilities',529 help: '[DEPRECATED] - (Android-only) Additional emulator arguments to launch the avd',530 }],531 [['--use-keystore'], {532 defaultValue: false,533 dest: 'useKeystore',534 action: 'storeTrue',535 required: false,536 deprecatedFor: '--default-capabilities',537 help: '[DEPRECATED] - (Android-only) When set the keystore will be used to sign apks.',538 }],539 [['--keystore-path'], {540 defaultValue: path.resolve(process.env.HOME || process.env.USERPROFILE || '', '.android', 'debug.keystore'),541 dest: 'keystorePath',542 required: false,543 deprecatedFor: '--default-capabilities',544 help: '[DEPRECATED] - (Android-only) Path to keystore',545 }],546 [['--keystore-password'], {547 defaultValue: 'android',548 dest: 'keystorePassword',549 required: false,550 deprecatedFor: '--default-capabilities',551 help: '[DEPRECATED] - (Android-only) Password to keystore',552 }],553 [['--key-alias'], {554 defaultValue: 'androiddebugkey',555 dest: 'keyAlias',556 required: false,557 deprecatedFor: '--default-capabilities',558 help: '[DEPRECATED] - (Android-only) Key alias',559 }],560 [['--key-password'], {561 defaultValue: 'android',562 dest: 'keyPassword',563 required: false,564 deprecatedFor: '--default-capabilities',565 help: '[DEPRECATED] - (Android-only) Key password',566 }],567 [['--intent-action'], {568 dest: 'intentAction',569 defaultValue: 'android.intent.action.MAIN',570 required: false,571 example: 'android.intent.action.MAIN',572 deprecatedFor: '--default-capabilities',573 help: '[DEPRECATED] - (Android-only) Intent action which will be used to start activity',574 }],575 [['--intent-category'], {576 dest: 'intentCategory',577 defaultValue: 'android.intent.category.LAUNCHER',578 required: false,579 example: 'android.intent.category.APP_CONTACTS',580 deprecatedFor: '--default-capabilities',581 help: '[DEPRECATED] - (Android-only) Intent category which will be used to start activity',582 }],583 [['--intent-flags'], {584 dest: 'intentFlags',585 defaultValue: '0x10200000',586 required: false,587 example: '0x10200000',588 deprecatedFor: '--default-capabilities',589 help: '[DEPRECATED] - (Android-only) Flags that will be used to start activity',590 }],591 [['--intent-args'], {592 dest: 'optionalIntentArguments',593 defaultValue: null,594 required: false,595 example: '0x10200000',596 deprecatedFor: '--default-capabilities',597 help: '[DEPRECATED] - (Android-only) Additional intent arguments that will be used to ' +598 'start activity',599 }],600 [['--dont-stop-app-on-reset'], {601 dest: 'dontStopAppOnReset',602 defaultValue: false,603 action: 'storeTrue',604 required: false,605 deprecatedFor: '--default-capabilities',606 help: '[DEPRECATED] - (Android-only) When included, refrains from stopping the app before restart',607 }],608 [['--calendar-format'], {609 defaultValue: null,610 dest: 'calendarFormat',611 required: false,612 example: 'gregorian',613 deprecatedFor: '--default-capabilities',614 help: '[DEPRECATED] - (IOS-only) calendar format for the iOS simulator',615 }],616 [['--native-instruments-lib'], {617 defaultValue: false,618 dest: 'nativeInstrumentsLib',619 action: 'storeTrue',620 required: false,621 deprecatedFor: '--default-capabilities',622 help: '[DEPRECATED] - (IOS-only) IOS has a weird built-in unavoidable ' +623 'delay. We patch this in appium. If you do not want it patched, ' +624 'pass in this flag.',625 nargs: 0,626 }],627 [['--keep-keychains'], {628 defaultValue: false,629 dest: 'keepKeyChains',630 action: 'storeTrue',631 required: false,632 deprecatedFor: '--default-capabilities',633 help: '[DEPRECATED] - (iOS-only) Whether to keep keychains (Library/Keychains) when reset app between sessions',634 nargs: 0,635 }],636 [['--localizable-strings-dir'], {637 required: false,638 dest: 'localizableStringsDir',639 defaultValue: 'en.lproj',640 deprecatedFor: '--default-capabilities',641 help: '[DEPRECATED] - (IOS-only) the relative path of the dir where Localizable.strings file resides ',642 example: 'en.lproj',643 }],644 [['--show-ios-log'], {645 defaultValue: false,646 dest: 'showIOSLog',647 action: 'storeTrue',648 required: false,649 deprecatedFor: '--default-capabilities',650 help: '[DEPRECATED] - (IOS-only) if set, the iOS system log will be written to the console',651 nargs: 0,652 }],653 [['--enable-heapdump'], {654 defaultValue: false,655 dest: 'heapdumpEnabled',656 action: 'storeTrue',657 required: false,658 help: 'Enable collection of NodeJS memory heap dumps. This is useful for memory leaks lookup',659 nargs: 0660 }]661];662function updateParseArgsForDefaultCapabilities (parser) {663 // here we want to update the parser.parseArgs() function664 // in order to bring together all the args that are actually665 // default caps.666 // once those deprecated args are actually removed, this667 // can also be removed668 parser._parseArgs = parser.parseArgs;669 parser.parseArgs = function (args) {670 let parsedArgs = parser._parseArgs(args);671 parsedArgs.defaultCapabilities = parsedArgs.defaultCapabilities || {};672 for (let argEntry of deprecatedArgs) {673 let arg = argEntry[1].dest;674 if (argEntry[1].deprecatedFor === '--default-capabilities') {675 if (arg in parsedArgs && parsedArgs[arg] !== argEntry[1].defaultValue) {676 parsedArgs.defaultCapabilities[arg] = parsedArgs[arg];677 // j s h i n t can't handle complex interpolated strings678 let capDict = {[arg]: parsedArgs[arg]};679 argEntry[1].deprecatedFor = `--default-capabilities ` +680 `'${JSON.stringify(capDict)}'`;681 }682 }683 }684 return parsedArgs;685 };686}687function parseDefaultCaps (caps) {688 try {689 // use synchronous file access, as `argparse` provides no way of either690 // awaiting or using callbacks. This step happens in startup, in what is691 // effectively command-line code, so nothing is blocked in terms of692 // sessions, so holding up the event loop does not incur the usual693 // drawbacks.694 if (fs.statSync(caps).isFile()) {695 caps = fs.readFileSync(caps, 'utf8');696 }697 } catch (err) {698 // not a file, or not readable699 }700 caps = JSON.parse(caps);701 if (!_.isPlainObject(caps)) {702 throw 'Invalid format for default capabilities';703 }704 return caps;705}706function getParser () {707 let parser = new ArgumentParser({708 version: pkgObj.version,709 addHelp: true,710 description: 'A webdriver-compatible server for use with native and hybrid iOS and Android applications.',711 prog: process.argv[1] || 'Appium'712 });713 let allArgs = _.union(args, deprecatedArgs);714 parser.rawArgs = allArgs;715 for (let arg of allArgs) {716 parser.addArgument(arg[0], arg[1]);717 }718 updateParseArgsForDefaultCapabilities(parser);719 return parser;720}721function getDefaultArgs () {722 let defaults = {};723 for (let [, arg] of args) {724 defaults[arg.dest] = arg.defaultValue;725 }726 return defaults;727}728export default getParser;...
Using AI Code Generation
1'use strict';2const wd = require('wd');3const chai = require('chai');4const chaiAsPromised = require('chai-as-promised');5chai.use(chaiAsPromised);6chai.should();7const caps = wd.parseDefaultCaps({8});9const driver = wd.promiseChainRemote('localhost', 4723);10driver.init(caps).then(function () {11 return driver.quit();12});13### `wd.parseCapsForServer(caps)`14'use strict';15const wd = require('wd');16const chai = require('chai');17const chaiAsPromised = require('chai-as-promised');18chai.use(chaiAsPromised);19chai.should();20const caps = wd.parseCapsForServer({21});22const driver = wd.promiseChainRemote('localhost', 4723);23driver.init(caps).then(function () {24 return driver.quit();25});26### `wd.promiseChainRemote(host, port, user, key, isJsonWP)`27### `wd.remote(host, port, user, key, isJsonWP)`
Using AI Code Generation
1}, "android", true);2### `parseDesiredCaps(caps)`3### `parseDefaultCaps(caps)`4### `startSession()`5### `deleteSession()`6### `getStatus()`7### `setCommandTimeout(timeout)`8### `setImplicitWaitTimeout(timeout)`9### `setAsyncScriptTimeout(timeout)`10### `getSessions()`
Using AI Code Generation
1var wd = require('wd');2var caps = wd.parseDefaultCaps({3});4var driver = wd.remote('localhost', 4723);5driver.init(caps, function() {6 driver.quit();7});8var wd = require('wd');9var caps = wd.parseDefaultCaps({10});11var driver = wd.remote('localhost', 4723);12driver.init(caps, function() {13 driver.quit();14});15var wd = require('wd');16var caps = wd.parseDefaultCaps({17});18var driver = wd.remote('localhost', 4723);19driver.init(caps,
Using AI Code Generation
1var AppiumDriver = require('appium-base-driver');2var desiredCaps = {3};4var defaultCaps = AppiumDriver.parseDefaultCaps(desiredCaps);5console.log(defaultCaps);6parseDesiredCaps(desiredCaps)7var AppiumDriver = require('appium-base-driver');8var desiredCaps = {9};10var parsedDesiredCaps = AppiumDriver.parseDesiredCaps(desiredCaps);11console.log(parsedDesiredCaps);12getDriverClass(automationName)13var AppiumDriver = require('appium-base-driver');14var driverClass = AppiumDriver.getDriverClass('uiautomator2');15console.log(driverClass);
Using AI Code Generation
1var wd = require('wd');2var driver = wd.remote();3driver.parseDefaultCaps(function(err, caps) {4 console.log(caps);5});6var wd = require('wd');7var driver = wd.remote();8driver.parseDefaultCaps(function(err, caps) {9 console.log(caps);10});11#### <a name="parseDefaultCaps"></a>parseDefaultCaps(callback)12var wd = require('wd');13var driver = wd.remote();14driver.parseDefaultCaps(function(err, caps) {15 console.log(caps);16});17var wd = require('wd');18var driver = wd.remote();19driver.parseDefaultCaps(function(err, caps) {20 console.log(caps);21});22#### <a name="parseDesiredCaps"></a>parseDesiredCaps(callback)23var wd = require('wd');24var driver = wd.remote();25driver.parseDesiredCaps(function(err, caps) {26 console.log(caps);27});28var wd = require('wd');29var driver = wd.remote();30driver.parseDesiredCaps(function(err, caps) {31 console.log(caps);32});33#### <a name="parseElement"></a>parseElement(element)34var wd = require('wd');35var driver = wd.remote();36driver.parseElement(function(err, element) {37 console.log(element);38});39var wd = require('wd');40var driver = wd.remote();41driver.parseElement(function(err, element) {42 console.log(element);43});44#### <a name="parseElements"></a>parseElements(elements)45var wd = require('
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!