From 9233b1f9429c5a1199294b95e9ab5fc7dd39ffcb Mon Sep 17 00:00:00 2001 From: Saawan Garg Date: Thu, 10 Jan 2019 14:13:24 +0530 Subject: [PATCH 1/4] fetch config from environment --- index.js | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index b3427ec..1439a60 100644 --- a/index.js +++ b/index.js @@ -20,37 +20,28 @@ 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 + build: process.env.BUILD || 'NodeJS build' // name of the build } - // URL: https://{username}:{accessToken}@beta-hub.lambdatest.com/wd/hub - const gridUrl = 'https://' + USERNAME + ':' + KEY + '@' + GRID_HOST; - // setup and build selenium driver object const driver = new webdriver.Builder() - .usingServer(gridUrl) + .usingServer(GRID_URL) .withCapabilities(capabilities) .build(); From 8611fcaa21c3c9a55eeaeced22dde47a140868a5 Mon Sep 17 00:00:00 2001 From: Saawan Garg Date: Thu, 10 Jan 2019 14:20:12 +0530 Subject: [PATCH 2/4] package.json added --- package.json | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 package.json 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" + } +} From 83174fcd4e0d3fa1f41e8c2e7328a32d0837068e Mon Sep 17 00:00:00 2001 From: Saawan Garg Date: Thu, 10 Jan 2019 14:27:32 +0530 Subject: [PATCH 3/4] added plugin name --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 1439a60..3536324 100644 --- a/index.js +++ b/index.js @@ -35,8 +35,9 @@ function searchTextOnGoogle() { visual: true, console: true, video: true, - name: 'Test 1', // name of the test - build: process.env.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' } // setup and build selenium driver object From 407ca8aaf7a02757452715242eb0095c5b63c4cb Mon Sep 17 00:00:00 2001 From: Saawan Garg Date: Thu, 10 Jan 2019 14:37:08 +0530 Subject: [PATCH 4/4] added tunnel support --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 3536324..f396ad3 100644 --- a/index.js +++ b/index.js @@ -40,6 +40,10 @@ function searchTextOnGoogle() { plugin: process.env.PLUGIN || 'N/A' } + if (process.env.TUNNEL && process.env.TUNNEL !== '') { + capabilities.tunnelIdentifier = process.env.TUNNEL; + } + // setup and build selenium driver object const driver = new webdriver.Builder() .usingServer(GRID_URL)