diff --git a/index.js b/index.js index b3427ec..f396ad3 100644 --- a/index.js +++ b/index.js @@ -20,37 +20,33 @@ const webdriver = require('selenium-webdriver'); version : Supported list of version can be found at https://www.lambdatest.com/capabilities-generator/ */ -// username: Username can be found at automation dashboard -const USERNAME = '{username}'; - -// AccessKey: AccessKey can be generated from automation dashboard or profile section -const KEY = '{accessKey}'; - // gridUrl: gridUrl can be found at automation dashboard -const GRID_HOST = 'beta-hub.lambdatest.com/wd/hub'; +const GRID_URL = process.env.GRID_URL; function searchTextOnGoogle() { // Setup Input capabilities const capabilities = { - platform: 'windows 10', - browserName: 'chrome', - version: '67.0', - resolution: '1280x800', + platform: process.env.PLATFORM || 'windows 10', + browserName: process.env.BROWSER || 'chrome', + version: process.env.VERSION || '67.0', + resolution: process.env.RESOLUTION || '1280x800', network: true, visual: true, console: true, video: true, - name: 'Test 1', // name of the test - build: 'NodeJS build' // name of the build + name: process.env.NAME || '', // name of the test + build: process.env.BUILD || 'Untitled', // name of the build + plugin: process.env.PLUGIN || 'N/A' } - // URL: https://{username}:{accessToken}@beta-hub.lambdatest.com/wd/hub - const gridUrl = 'https://' + USERNAME + ':' + KEY + '@' + GRID_HOST; + if (process.env.TUNNEL && process.env.TUNNEL !== '') { + capabilities.tunnelIdentifier = process.env.TUNNEL; + } // setup and build selenium driver object const driver = new webdriver.Builder() - .usingServer(gridUrl) + .usingServer(GRID_URL) .withCapabilities(capabilities) .build(); diff --git a/package.json b/package.json new file mode 100644 index 0000000..401d5cf --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "nodejs-selenium-sample", + "version": "1.0.0", + "description": "NodeJS selenium automation sample test for Lambdatest Cloud GRID.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/LambdaTest/nodejs-selenium-sample.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/LambdaTest/nodejs-selenium-sample/issues" + }, + "homepage": "https://github.com/LambdaTest/nodejs-selenium-sample#readme", + "dependencies": { + "selenium-webdriver": "^4.0.0-alpha.1" + } +}