From 5d08eb69a3519a18435689cea020be4189a4b567 Mon Sep 17 00:00:00 2001 From: Sreenivas Karthikeyan <88871817+sreenivas-k@users.noreply.github.com> Date: Fri, 1 Apr 2022 19:14:13 +0530 Subject: [PATCH] Removing single test --- conf/single.conf.js | 9 ----- conf/{parallel.conf.js => test.conf.js} | 19 ++------- package.json | 4 +- specs/local_test.js | 2 +- specs/single_test.js | 53 ------------------------- specs/{parallel_test.js => test.js} | 2 +- 6 files changed, 6 insertions(+), 83 deletions(-) delete mode 100644 conf/single.conf.js rename conf/{parallel.conf.js => test.conf.js} (76%) delete mode 100644 specs/single_test.js rename specs/{parallel_test.js => test.js} (97%) diff --git a/conf/single.conf.js b/conf/single.conf.js deleted file mode 100644 index 9ed2ced..0000000 --- a/conf/single.conf.js +++ /dev/null @@ -1,9 +0,0 @@ -exports.capabilities = { - 'browserstack.user': process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME', - 'browserstack.key': process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY', - 'build': 'mocha-browserstack', - 'name': 'single_test', - 'browserstack.debug': 'true', - - 'browserName': 'chrome' -}; diff --git a/conf/parallel.conf.js b/conf/test.conf.js similarity index 76% rename from conf/parallel.conf.js rename to conf/test.conf.js index 6613157..73079c2 100644 --- a/conf/parallel.conf.js +++ b/conf/test.conf.js @@ -12,31 +12,18 @@ var config = { 'browser_version': 'latest', 'name': 'Parallel test 1' }, - { - 'os': 'OS X', - 'os_version': 'Monterey', - 'browserName': 'Chrome', - 'browser_version': 'latest', - 'name': 'Parallel test 2' - }, { 'os' : 'OS X', 'os_version' : 'Big Sur', 'browserName' : 'Safari', - 'name': 'Parallel test 3' + 'name': 'Parallel test 2' }, { 'browserName': 'Android', 'device': 'Samsung Galaxy S20', 'realMobile': 'true', - 'name': 'Parallel test 4' - }, - { - 'browserName': 'iPhone', - 'device': 'iPhone 12 Pro Max', - 'realMobile': 'true', - 'name': 'Parallel test 5' - }] + 'name': 'Parallel test 3' + }] }; exports.capabilities = []; diff --git a/package.json b/package.json index 668d250..6aaeb75 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,8 @@ "version": "0.0.1", "description": " Selenium examples for Mocha and BrowserStack Automate", "scripts": { - "test": "npm run single && npm run local && npm run parallel", - "single": "./node_modules/.bin/mocha specs/single_test.js conf/single.conf.js", "local": "./node_modules/.bin/mocha specs/local_test.js conf/local.conf.js", - "parallel": "./node_modules/.bin/mocha specs/parallel_test.js conf/parallel.conf.js --timeout=60000" + "test": "./node_modules/.bin/mocha specs/test.js conf/test.conf.js --timeout=60000" }, "repository": { "type": "git", diff --git a/specs/local_test.js b/specs/local_test.js index f8fc0ec..34efc84 100644 --- a/specs/local_test.js +++ b/specs/local_test.js @@ -7,7 +7,7 @@ var caps = require('../' + conf_file).capabilities; var buildDriver = function(caps) { return new webdriver.Builder(). - usingServer('https://hub-cloud.browserstack.com/wd/hub'). + usingServer('https://hub.browserstack.com/wd/hub'). withCapabilities(caps). build(); }; diff --git a/specs/single_test.js b/specs/single_test.js deleted file mode 100644 index ae85095..0000000 --- a/specs/single_test.js +++ /dev/null @@ -1,53 +0,0 @@ -var assert = require('assert'), - webdriver = require('selenium-webdriver'), - conf_file = process.argv[3] || 'conf/single.conf.js'; - -var caps = require('../' + conf_file).capabilities; - -var buildDriver = function(caps) { - return new webdriver.Builder(). - usingServer('https://hub-cloud.browserstack.com/wd/hub'). - withCapabilities(caps). - build(); -}; - -describe('BrowserStack\'s Cart Functionality for ' + caps.browserName, function() { - this.timeout(0); - var driver; - - beforeEach(function(done) { - driver = buildDriver(caps); - done(); - }); - - it('can add items to cart', async function (done) { - await driver.get('https://bstackdemo.com/'); - await driver.wait(webdriver.until.titleMatches(/StackDemo/i), 10000); - - try { - // locating product on webpage and getting name of the product - let productText = await driver.findElement(webdriver.By.xpath('//*[@id="1"]/p')).getText(); - // clicking the 'Add to cart' button - await driver.findElement(webdriver.By.xpath('//*[@id="1"]/div[4]')).click() - // waiting until the Cart pane has been displayed on the webpage - driver.findElement(webdriver.By.className('float-cart__content')) - // locating product in cart and getting name of the product in cart - let productCartText = await driver.findElement(webdriver.By.xpath('//*[@id="__next"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]')).getText() - // checking whether product has been added to cart by comparing product name - assert(productText === productCartText); - - //marking the test as Passed if product has been added to the cart - await driver.executeScript( - 'browserstack_executor: {"action": "setSessionStatus", "arguments": {"status":"passed","reason": "Product has been successfully added to the cart!"}}' - ); - } catch (e) { - //marking the test as Failed if product has not been added to the cart - console.log("Error:", e.message) - await driver.executeScript( - 'browserstack_executor: {"action": "setSessionStatus", "arguments": {"status":"failed","reason": "Some elements failed to load."}}' - ); - } finally { - await driver.quit(); - } - }); -}); diff --git a/specs/parallel_test.js b/specs/test.js similarity index 97% rename from specs/parallel_test.js rename to specs/test.js index 5c62b91..7bb7a92 100644 --- a/specs/parallel_test.js +++ b/specs/test.js @@ -9,7 +9,7 @@ var capabilities = require('../' + conf_file).capabilities; var buildDriver = function(caps) { return new Promise(function(resolve, reject) { var driver = new webdriver.Builder(). - usingServer('https://hub-cloud.browserstack.com/wd/hub'). + usingServer('https://hub.browserstack.com/wd/hub'). withCapabilities(caps). build(); resolve(driver);