From f7277cb79ba7f5667685a678b1fdaa8e8e2055d2 Mon Sep 17 00:00:00 2001 From: webcrawler1000 Date: Wed, 7 Jul 2021 21:04:24 +0300 Subject: [PATCH 1/3] =?UTF-8?q?Added=20new=20te=C5=9Bt=20case=20for=20News?= =?UTF-8?q?=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 0 README.md | 4 ++ buildinfo.txt | 3 - index.js | 0 test/javascript/pageobjects/Catalog.page.js | 70 +------------------ test/javascript/pageobjects/Home.page.js | 6 ++ test/javascript/pageobjects/NewsPage.page.js | 47 +++++++++++++ .../step-definition/NewsPage.spec.js | 17 +++++ test/resources/features/CatalogPage.feature | 1 - test/resources/features/Login.feature | 36 ---------- test/resources/features/NewsPage.feature | 6 ++ wdio.conf.js | 7 +- 12 files changed, 86 insertions(+), 111 deletions(-) delete mode 100755 .gitlab-ci.yml delete mode 100644 buildinfo.txt delete mode 100755 index.js create mode 100644 test/javascript/pageobjects/NewsPage.page.js create mode 100644 test/javascript/step-definition/NewsPage.spec.js delete mode 100755 test/resources/features/Login.feature create mode 100644 test/resources/features/NewsPage.feature diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100755 index e69de29..0000000 diff --git a/README.md b/README.md index bd80a38..6146176 100755 --- a/README.md +++ b/README.md @@ -3,6 +3,10 @@ Currently this framework has been developed to run scripts on Chrome Browser and windows Platform To run the suite on different browser and platform changes in "wdio.conf.js" file will be required. +## Important + +Please verify that package.json file with described dependencies presents in the project. + ### Tech Stack * [Selenium Service] - This is a node based CLI library for launching Selenium with WebDrivers support. diff --git a/buildinfo.txt b/buildinfo.txt deleted file mode 100644 index 5ed8a0a..0000000 --- a/buildinfo.txt +++ /dev/null @@ -1,3 +0,0 @@ -Backend version: 6.06.01 -DB schema version: 6.06.01 -Frontend build version: 6.06.01 (Mon, 05 Jul 2021 07:02:00 GMT) \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100755 index e69de29..0000000 diff --git a/test/javascript/pageobjects/Catalog.page.js b/test/javascript/pageobjects/Catalog.page.js index 6416252..3186886 100644 --- a/test/javascript/pageobjects/Catalog.page.js +++ b/test/javascript/pageobjects/Catalog.page.js @@ -6,65 +6,8 @@ const utilObj = require( '../helper/WaitActions') class CatalogPage extends Page { //get CatalogLink() { return $('#hp > div.main > div.header.box > div.slogan > ul > li:nth-child(3) > a""]'); } - get cart() { return $('#cart1')}; - /** - * Method to verify visible menu links - */ - verifyVisibleMenuList(allowedMenuItemList, dataTable) { - browser.pause(3000); - if (allowedMenuItemList == "Organization") { - //expect(super.organizationMenuLink.isDisplayed(), "Organization menu is not visible").to.be.true; - super.organizationMenuLink.click(); - utilObj.waitForDefaultTimeOut(); - var List = dataTable.raw(); - //console.log(List) - List.forEach(element => { - element.forEach(item => { - if (item == "Users and devices") { - //browser.saveScreenshot(); - //expect(super.userDeviceMenuLink.isDisplayed(), "Users and devices menu is not visible").to.be.true; - //allure.createStep("Admin has access of user and device page") - } - else if (item == "Hierarchies and groups") { - //browser.saveScreenshot(); - //expect(super.hieGroupMenuLink.isDisplayed(), "Hierarchies and groups menu is not visible").to.be.true; - //allure.createStep("Admin has access of user and device page") - } - else if (item == "User assignment") { - //browser.saveScreenshot(); - //expect(super.userAssignmentLink.isDisplayed(), "User assignment menu is not visible").to.be.true; - //allure.createStep("Admin has access of user and device page") - } - else if (item == "Device pool") { - //browser.saveScreenshot(); - //expect(super.devicePoolLink.isDisplayed(), "Device pool menu is not visible").to.be.true; - //allure.createStep("Admin has access of user and device page") - } else { - //browser.saveScreenshot(); - throw "Invalid menu item" - } - }); - }); - } - // else if (allowedMenuItemList == "Dashboard") { - - // } - } - - /** - * Method to verofy if current page is dashboard else navigate to dashboard - */ - verifyCurrentPage() { - let currentPage = browser.getTitle(); - if (currentPage.includes("Dashboard")) { - allure.createStep('User is on Dashboard'); - } - else { - // super.dashboardLink.scroll(); - super.dashboardLink.click(); - //allure.addDescription("open the server instance"); - } - } + get cart() { return $('#cart')}; + /** * Method to navigate to home page @@ -86,15 +29,6 @@ class CatalogPage extends Page { } } - /** - * Verify admin can changes its password - */ - verifyAdminCanChangeCredentials(){ - utilObj.waitForDefaultTimeOut(); - super.adminNameClass.click(); - super.adminDivModel.waitForExist(30000); - } - verifyCatalogPage() { //this.cart.isDisplayed() if (this.cart.isDisplayed()) { diff --git a/test/javascript/pageobjects/Home.page.js b/test/javascript/pageobjects/Home.page.js index b083f7c..dd97f8c 100755 --- a/test/javascript/pageobjects/Home.page.js +++ b/test/javascript/pageobjects/Home.page.js @@ -6,6 +6,7 @@ const utilObj = require( '../helper/WaitActions') class HomePage extends Page { get catalogLink() { return $('#hp > div.main > div.header.box > div.slogan > ul > li:nth-child(3) > a'); } + get newsLink() { return $('#hp > div.main > div.header.box > div.slogan > ul > li:nth-child(2) > a'); } /** @@ -56,6 +57,11 @@ class HomePage extends Page { this.catalogLink.click(); } + navigateToNewsPage() { + utilObj.waitForDefaultTimeOut(); + this.newsLink.click(); + } + } //module.exports = new HomePage(); module.exports = new HomePage(); \ No newline at end of file diff --git a/test/javascript/pageobjects/NewsPage.page.js b/test/javascript/pageobjects/NewsPage.page.js new file mode 100644 index 0000000..0d655a2 --- /dev/null +++ b/test/javascript/pageobjects/NewsPage.page.js @@ -0,0 +1,47 @@ +const Page = require('./Page'); +const allure = require('wdio-allure-reporter'); +const utilObj = require( '../helper/WaitActions') + + +class NewsPage extends Page { + + get newsTitle() { return $('#hp > div.main > div.content.box > h3:nth-child(1) > strong > i')}; + + + /** + * Method to navigate to home page + */ + navigateToHomepage() { + utilObj.waitForDefaultTimeOut() + if (super.homePageLink.isDisplayed()) { + super.homePageLink.click() + utilObj.waitForPageToLoad() + } + else { + utilObj.waitForDefaultTimeOut() + super.reportsLink.waitForExist(utilObj.defaultwait) + super.reportsLink.click() + utilObj.waitForDefaultTimeOut() + super.homePageLink.waitForExist(utilObj.defaultwait) + super.homePageLink.click() + browser.pause(5000); + } + } + + verifyNewsPage() { + //this.cart.isDisplayed() + if (this.newsTitle.isDisplayed()) { + allure.createStep('User is on catalog'); + } + else { + // super.dashboardLink.scroll(); + utilObj.waitForDefaultTimeOut(); + throw "Something went wrong, User is not in catalog" + //super.dashboardLink.click(); + //allure.addDescription("open the server instance"); + } + } + +} +//module.exports = new HomePage(); +module.exports = new NewsPage(); \ No newline at end of file diff --git a/test/javascript/step-definition/NewsPage.spec.js b/test/javascript/step-definition/NewsPage.spec.js new file mode 100644 index 0000000..70a9bac --- /dev/null +++ b/test/javascript/step-definition/NewsPage.spec.js @@ -0,0 +1,17 @@ +const { Given, When, Then } = require('@cucumber/cucumber'); +const homeobject = require('../pageobjects/Home.page'); +const newspageobject = require('../pageobjects/NewsPage.page'); + + +/*Given(/^User is on Home page$/,()=>{ + homeobject.open(); + homeobject.verifyCurrentPage(); +});*/ + +When(/^User clicks News link$/,()=>{ + homeobject.navigateToNewsPage(); +}); + +Then(/^User moves to News page$/,()=>{ + newspageobject.verifyNewsPage(); +}) \ No newline at end of file diff --git a/test/resources/features/CatalogPage.feature b/test/resources/features/CatalogPage.feature index e779220..76f9cb5 100644 --- a/test/resources/features/CatalogPage.feature +++ b/test/resources/features/CatalogPage.feature @@ -1,6 +1,5 @@ Feature: User navigates to Catalog page - @English Scenario: User navigates to Catalog page Given User is on Home page When User clicks Catalog link diff --git a/test/resources/features/Login.feature b/test/resources/features/Login.feature deleted file mode 100755 index 9b1d15c..0000000 --- a/test/resources/features/Login.feature +++ /dev/null @@ -1,36 +0,0 @@ -Feature: Login-Module. Admin should be able to login - - Background: Login Scenarios - Given Open the Login Page - - #JIRA Issue Id REVI-18 : https://mdm.atlassian.net/browse/REVI-18 - @English - Scenario Outline: Successful Login Scenario - Given Select the language English - When Enter and and click login button - Then user logged in successful and admin name is visible - And logout the user - Examples: - | Username | Password | - | admin | N3p1fwux | - - @English - #Jira Issue :https://mdm.atlassian.net/browse/REVI-19 - Scenario Outline: Unsuccessful Login Scenario - Given Select the language English - When Enter and and click login button - Then Incorrect credential message is visible - Examples: - | Username | Password | Langauge | ErrorMessage | - | admin | 123456 | English | Username or password is incorrect | - - @English - #Jira Issue :https://mdm.atlassian.net/browse/REVI-20 - Scenario Outline: Verify input field validation message - When Empty Username input - Then Validation message should be visible for Username - When Empty Password input - Then Validation message should be visible for Password - Examples: - | ErrorMessage | - | This field is required | diff --git a/test/resources/features/NewsPage.feature b/test/resources/features/NewsPage.feature new file mode 100644 index 0000000..95bc097 --- /dev/null +++ b/test/resources/features/NewsPage.feature @@ -0,0 +1,6 @@ +Feature: User navigates to News page + + Scenario: User navigates to News page + Given User is on Home page + When User clicks News link + Then User moves to News page \ No newline at end of file diff --git a/wdio.conf.js b/wdio.conf.js index 39f4e56..fa77aef 100644 --- a/wdio.conf.js +++ b/wdio.conf.js @@ -5,8 +5,8 @@ const del = require('del'); global.downloadDir = path.join(__dirname, 'tempDownload'); global.dataDir = path.join(__dirname, './test/resources/testdata'); -global.username = 'admin'; -global.password = 'N3p1fwux'; +global.username = 'admin123'; +global.password = 'admin'; var dt = new Date() global.postfix = dt.getMonth() + '-' + dt.getDate() + '_' + dt.getHours() + ':' + dt.getMinutes() + ':' + dt.getSeconds(); global.tenant = '1_automation'; @@ -37,6 +37,7 @@ exports.config = { //'./test/resources/features/**/*.feature', './test/resources/features/CatalogPage.feature', + './test/resources/features/NewsPage.feature', './test/resources/features/CatalogPageAdmin.feature', ], // Patterns to exclude. @@ -83,7 +84,7 @@ exports.config = { // maxInstances can get overwritten per capability. So if you have an in-house Selenium // grid with only 5 firefox instances available you can make sure that not more than // 5 instances get started at a time. - maxInstances: 5, + maxInstances: 1, // //browserName: 'chrome', browserName: 'chrome', From 317ec10612d48185391d267fd14c00edfa967957 Mon Sep 17 00:00:00 2001 From: webcrawler1000 Date: Thu, 8 Jul 2021 19:24:21 +0300 Subject: [PATCH 2/3] Added Solutions test case --- test/javascript/pageobjects/Home.page.js | 6 ++++++ test/javascript/pageobjects/solutions.page.js | 6 ++++-- test/javascript/step-definition/SolutionsPage.spec.js | 9 --------- test/resources/features/SolutionsPage.feature | 10 +++++----- wdio.conf.js | 4 ++-- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/test/javascript/pageobjects/Home.page.js b/test/javascript/pageobjects/Home.page.js index dd97f8c..aa83a2d 100755 --- a/test/javascript/pageobjects/Home.page.js +++ b/test/javascript/pageobjects/Home.page.js @@ -7,6 +7,7 @@ class HomePage extends Page { get catalogLink() { return $('#hp > div.main > div.header.box > div.slogan > ul > li:nth-child(3) > a'); } get newsLink() { return $('#hp > div.main > div.header.box > div.slogan > ul > li:nth-child(2) > a'); } + get solutionsLink() { return $('#hp > div.main > div.header.box > div.slogan > ul > li:nth-child(4) > a'); } /** @@ -62,6 +63,11 @@ class HomePage extends Page { this.newsLink.click(); } + navigateToSolutionsPage() { + utilObj.waitForDefaultTimeOut(); + this.solutionsLink.click(); + } + } //module.exports = new HomePage(); module.exports = new HomePage(); \ No newline at end of file diff --git a/test/javascript/pageobjects/solutions.page.js b/test/javascript/pageobjects/solutions.page.js index d598cf1..10a3a64 100644 --- a/test/javascript/pageobjects/solutions.page.js +++ b/test/javascript/pageobjects/solutions.page.js @@ -7,6 +7,7 @@ class SolutionsPage extends Page { //get SolutionsLink() { return $('#hp > div.main > div.content.box > ul:nth-child(1) > li:nth-child(1) > p.more > a); } get SolutionsTitle() { return $('#SolutionsTatle')}; + get galleryShowMoreButtonBlue() { return $('#hp > div.main > div.content.box > ul:nth-child(1) > li:nth-child(1) > p.more > a')}; /** * Method to verify visible menu links */ @@ -96,9 +97,10 @@ class SolutionsPage extends Page { } verifySolutionsPage() { + utilObj.waitForDefaultTimeOut(); //this.Solutions.isDisplayed() - if (this.SolutionPage.isDisplayed()) { - allure.createStep('User is on Solution'); + if (this.galleryShowMoreButtonBlue.isDisplayed()) { + allure.createStep('User is on Solution Page'); } else { // super.dashboardLink.scroll(); diff --git a/test/javascript/step-definition/SolutionsPage.spec.js b/test/javascript/step-definition/SolutionsPage.spec.js index b0d3732..9e95c57 100644 --- a/test/javascript/step-definition/SolutionsPage.spec.js +++ b/test/javascript/step-definition/SolutionsPage.spec.js @@ -3,15 +3,6 @@ const homeobject = require('../pageobjects/Home.page'); const Solutionsobject = require('../pageobjects/Solutions.page'); -Given(/^User is on Home page$/,()=>{ - homeobject.open(); - homeobject.verifyCurrentPage(); -}); - -Given(/^Admin is on Admin page$/,()=>{ - homeobject.openAdmin(); - //homeobject.verifyCurrentPage(); -}); When(/^User clicks Solutions link$/,()=>{ homeobject.navigateToSolutionsPage(); diff --git a/test/resources/features/SolutionsPage.feature b/test/resources/features/SolutionsPage.feature index 13f8f8d..ddd5826 100644 --- a/test/resources/features/SolutionsPage.feature +++ b/test/resources/features/SolutionsPage.feature @@ -1,7 +1,7 @@ -Feature: User navigates to solutions page +Feature: User navigates to Solutions page @English - Scenario: User navigates to solutions page - Given User is on solutions page - When User clicks solutions link - Then User moves to solutions page \ No newline at end of file + Scenario: User navigates to Solutions page + Given User is on Home page + When User clicks Solutions link + Then User moves to Solutions page \ No newline at end of file diff --git a/wdio.conf.js b/wdio.conf.js index 11b4538..0c40f3d 100644 --- a/wdio.conf.js +++ b/wdio.conf.js @@ -39,11 +39,11 @@ exports.config = { './test/resources/features/CatalogPage.feature', './test/resources/features/NewsPage.feature', './test/resources/features/CatalogPageAdmin.feature', - './test/resources/features/NewsPage.feature', './test/resources/features/SolutionsPage.feature' ], // Patterns to exclude. exclude: [ + // 'path/to/excluded/files' /*Important!!! always exclude this part*/ @@ -86,7 +86,7 @@ exports.config = { // maxInstances can get overwritten per capability. So if you have an in-house Selenium // grid with only 5 firefox instances available you can make sure that not more than // 5 instances get started at a time. - maxInstances: 1, + maxInstances: 2, // //browserName: 'chrome', browserName: 'chrome', From 4bba41e2f18d1d9f73e2efc09fd1b03bc4540af9 Mon Sep 17 00:00:00 2001 From: webcrawler1000 Date: Thu, 8 Jul 2021 21:12:20 +0300 Subject: [PATCH 3/3] Added new test case (buy item as guest) --- test/javascript/pageobjects/Catalog.page.js | 65 ++++++++++++++++++- .../step-definition/CatalogPage.spec.js | 33 ++++++++++ .../features/CatalogBuyItemAsGuest.feature | 15 +++++ wdio.conf.js | 8 +-- 4 files changed, 115 insertions(+), 6 deletions(-) create mode 100644 test/resources/features/CatalogBuyItemAsGuest.feature diff --git a/test/javascript/pageobjects/Catalog.page.js b/test/javascript/pageobjects/Catalog.page.js index 2d19a88..9a4d67f 100644 --- a/test/javascript/pageobjects/Catalog.page.js +++ b/test/javascript/pageobjects/Catalog.page.js @@ -7,8 +7,18 @@ class CatalogPage extends Page { //get CatalogLink() { return $('#hp > div.main > div.header.box > div.slogan > ul > li:nth-child(3) > a""]'); } get cart() { return $('#cart')}; - - + get firstItemSelect() { return $('#content > table > tbody > tr:nth-child(4) > td:nth-child(1) > a > b')}; + get addToCartButton() { return $('#content > div.product-list > div > div.right > div > input')}; + get totalCart() {return $('#cart-total')}; + get processOrderLink() {return $('#cart > div.content > div.checkout > a:nth-child(2)')}; + get processAsGuestButton() {return $('#button-account')}; + get firstName() {return $('#payment-address > div.checkout-content > div.left > input:nth-child(4)')}; + get lastName() {return $('#payment-address > div.checkout-content > div.left > input:nth-child(9)')}; + get email() {return $('#payment-address > div.checkout-content > div.left > input:nth-child(14)')}; + get phone() {return $('#payment-address > div.checkout-content > div.left > input:nth-child(19)')}; + get address() {return $('#payment-address > div.checkout-content > div.right > input:nth-child(11)')}; + get city() {return $('#payment-address > div.checkout-content > div.right > input:nth-child(20)')}; + get buttonGuest() {return $('#button-guest')}; /** * Method to navigate to home page */ @@ -43,6 +53,57 @@ class CatalogPage extends Page { } } + selectFirstItem() + { + //browser.pause(5000); + utilObj.waitForDefaultTimeOut(); + this.firstItemSelect.click(); + } + + addItemToCart() + + { + //browser.pause(5000); + utilObj.waitForDefaultTimeOut(); + this.addToCartButton.click(); + } + + clickTotalCart() + { + utilObj.waitForDefaultTimeOut(); + this.totalCart.click(); + } + + processWithOrder() + { + utilObj.waitForDefaultTimeOut(); + this.processOrderLink.click(); + } + + processAsGuest() { + utilObj.waitForDefaultTimeOut(); + this.processAsGuestButton.click(); + + } + + fillTheGuestPersonalInfo() { + this.firstName.click(); + this.firstName.setValue("Maksim") + this.lastName.click(); + this.lastName.setValue("KKK"); + this.email.click(); + this.email.setValue("someemail@someemail.com"); + this.phone.click(); + this.phone.setValue("123455"); + this.city.click(); + this.city.setValue("tallinn"); + this.address.setValue("tallinn 123434"); + this.address.click(); + //this.buttonGuest.click(); + //browser.pause(1000); + } + + } //module.exports = new HomePage(); module.exports = new CatalogPage(); \ No newline at end of file diff --git a/test/javascript/step-definition/CatalogPage.spec.js b/test/javascript/step-definition/CatalogPage.spec.js index 29a50f8..2edcc2c 100644 --- a/test/javascript/step-definition/CatalogPage.spec.js +++ b/test/javascript/step-definition/CatalogPage.spec.js @@ -17,6 +17,39 @@ When(/^User clicks Catalog link$/,()=>{ homeobject.navigateToCatalogPage(); }); +When(/^User selects first item$/,()=>{ + catalogobject.selectFirstItem(); +}); + +When(/^User adds item to cart$/,()=>{ + catalogobject.addItemToCart(); +}); + +When(/^User clicks cart$/,()=>{ + catalogobject.clickTotalCart(); +}); + +When(/^User processes with order$/,()=>{ + catalogobject.processWithOrder(); +}); + +When(/^User selects Guest option$/,()=>{ + catalogobject.processAsGuest(); +}); + + +When(/^User enters the personal details as Guest$/,()=>{ + catalogobject.fillTheGuestPersonalInfo(); +}); + +When(/^User does not select delivery mode$/,()=>{ + catalogobject.verifyCatalogPage(); +}); + +Then(/^User should see confirmation of order$/,()=>{ + catalogobject.verifyCatalogPage(); +}) + Then(/^User moves to Catalog page$/,()=>{ catalogobject.verifyCatalogPage(); }) \ No newline at end of file diff --git a/test/resources/features/CatalogBuyItemAsGuest.feature b/test/resources/features/CatalogBuyItemAsGuest.feature new file mode 100644 index 0000000..209e65a --- /dev/null +++ b/test/resources/features/CatalogBuyItemAsGuest.feature @@ -0,0 +1,15 @@ +Feature: User buys item as a guest + + Scenario: User buys item as a guest + Given User is on Home page + When User clicks Catalog link + And User selects first item + And User adds item to cart + And User clicks cart + And User processes with order + And User selects Guest option + And User enters the personal details as Guest + #And User does not select delivery mode + #Then User should see confirmation of order + + diff --git a/wdio.conf.js b/wdio.conf.js index 0c40f3d..e866719 100644 --- a/wdio.conf.js +++ b/wdio.conf.js @@ -36,14 +36,14 @@ exports.config = { specs: [ //'./test/resources/features/**/*.feature', + './test/resources/features/CatalogBuyItemAsGuest.feature', + ], + // Patterns to exclude. + exclude: [ './test/resources/features/CatalogPage.feature', './test/resources/features/NewsPage.feature', './test/resources/features/CatalogPageAdmin.feature', './test/resources/features/SolutionsPage.feature' - ], - // Patterns to exclude. - exclude: [ - // 'path/to/excluded/files' /*Important!!! always exclude this part*/