Skip to content

Commit

Permalink
Updated Cypress 6.1.0 & cypress-cucumber-preprocessor 4.0.0 version (#4)
Browse files Browse the repository at this point in the history
* Updated Cypress and cucumber preprocessor version

* Updated Cyprss version

* Added cucumber report

Co-authored-by: Poovaraj Thangamariappan <poovaraj.thangamariappan@astrazeneca.com>
  • Loading branch information
poovaraj and Poovaraj Thangamariappan authored Dec 16, 2020
1 parent 6342b36 commit 8c1d9d1
Show file tree
Hide file tree
Showing 13 changed files with 6,643 additions and 5,814 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ allure-results/
mochawesome-report/
cypress/videos
cypress/screenshots
cucumber-report/

13 changes: 6 additions & 7 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"projectId": "j5qpgn",
"projectId": "j8cs4d",
"baseUrl": "https://opensource-demo.orangehrmlive.com",
"waitForAnimations": true,
"animationDistanceThreshold": 50,
Expand All @@ -9,9 +9,8 @@
"chromeWebSecurity": false,
"watchForFileChanges": false,
"trashAssetsBeforeRuns": true,
"reporter": "mochawesome",
"reporterOptions": {
"overwrite": false
}

}
"reporter": "mochawesome",
"reporterOptions": {
"overwrite": true
}
}
126 changes: 54 additions & 72 deletions cypress/pageobjects/HomeOrangehrm_PageObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const admin_resultTableRow1Column2 = '//*[@id=\'resultTable\']/tbody/tr[1]/td[2]
const admin_resultTableRow2Column2 = '//*[@id=\'resultTable\']/tbody/tr[2]/td[2]'
const graph_dashboard = '//*[@id=\'div_graph_display_emp_distribution\']'
const sectionBelowGraph = '//*[@id=\'hover_div_graph_display_emp_distribution\']'
const pieChartLabel1 = '//*[@id=\'pieLabel1\']/div'
const pieChartLabel2 = '//*[@id=\'pieLabel2\']/div'
const pieChartLabel3 = '//*[@id=\'pieLabel3\']/div'
const pieChartLabel4 = '//*[@id=\'pieLabel4\']/div'
// const pieChartLabel1 = '//*[@id=\'pieLabel1\']/div'
// const pieChartLabel2 = '//*[@id=\'pieLabel2\']/div'
// const pieChartLabel3 = '//*[@id=\'pieLabel3\']/div'
// const pieChartLabel4 = '//*[@id=\'pieLabel4\']/div'
const admin_tabxPath_Homepage = '//*[@id=\'menu_admin_viewAdminModule\']'
const salesMgr_PIM = '//*[@id=\'ohrmList_chkSelectRecord_6\']'
const jobTitleDropdown_pim = '//*[@id=\'empsearch_job_title\']'
Expand All @@ -19,133 +19,121 @@ const supervisorPIMtab = '//*[@id=\'empsearch_supervisor_name\']'

export const homeOrangehrmPage = {
checkAdminTab () {
cy.xpath(admin_tabxPath_Homepage)
.invoke('show').should('be.visible')
cy.xpath(admin_tabxPath_Homepage).invoke('show').should('be.visible')
},

checkAdminTabCssMethod () {
cy.get(admin_tabselector_Homepage)
.invoke('show').should('be.visible')
cy.get(admin_tabselector_Homepage).invoke('show').should('be.visible')
},
checkAdminTabTextMethod () {
cy.contains('Admin')
.invoke('show').should('be.visible')
cy.contains('Admin').invoke('show').should('be.visible')
},
clickAdminTab () {
cy.xpath(admin_tabxPath_Homepage)
.invoke('show').should('be.visible')
.click()
.invoke('show')
.should('be.visible')
.click()
},
clickAdminResultTableR1C2 () {
cy.xpath(admin_resultTableRow1Column2)
.invoke('show').should('be.visible')
.click()
.invoke('show')
.should('be.visible')
.click()
},
dblclickAdminTab () {
cy.xpath(admin_tabxPath_Homepage)
.invoke('show').should('be.visible')
.dblclick()
.invoke('show')
.should('be.visible')
.dblclick()
},
checkAdminTabSubsection () {
cy.xpath(userDetail_Adminpage)
.invoke('show').should('be.visible')
cy.xpath(userDetail_Adminpage).invoke('show').should('be.visible')
},
rhtclickAdminTab () {
cy.xpath(admin_tabxPath_Homepage)
.rightclick()
cy.xpath(admin_tabxPath_Homepage).rightclick()
},
clickPIMTab () {
cy.xpath(pimTab_Homepage)
.invoke('show').should('be.visible')
.click()
cy.xpath(pimTab_Homepage).invoke('show').should('be.visible').click()
},
checkEmployees () {
cy.xpath(selectAll_pimTab)
.not('[disabled]')
.check()
cy.xpath(selectAll_pimTab).not('[disabled]').check()
},
allEmployeesSelected () {
cy.xpath(selectAll_pimTab)
.not('[disabled]')
.should('be.checked')
cy.xpath(selectAll_pimTab).not('[disabled]').should('be.checked')
},
uncheckEmployees () {
cy.xpath(selectAll_pimTab)
.not('[disabled]')
.should('be.checked')
.uncheck()
cy.xpath(selectAll_pimTab).not('[disabled]').should('be.checked').uncheck()
},
selectSalesmgrEmployee () {
cy.xpath(salesMgr_PIM)
.not('[disabled]')
.check()
cy.xpath(salesMgr_PIM).not('[disabled]').check()
},
SalesmgrEmployeeAssertion () {
cy.xpath(salesMgr_PIM)
.not('[disabled]')
.should('be.checked')
cy.xpath(salesMgr_PIM).not('[disabled]').should('be.checked')
},
noEmployeesSelected () {
cy.xpath(selectAll_pimTab)
.not('[disabled]')
.should('not.be.checked')
cy.xpath(selectAll_pimTab).not('[disabled]').should('not.be.checked')
},
jobTitleDropdown () {
cy.get('select').xpath(jobTitleDropdown_pim)
.select('Sales Manager').should('have.value', '1')
cy.get('select')
.xpath(jobTitleDropdown_pim)
.select('Sales Manager')
.should('have.value', '1')
},
clickSearchbtn () {
cy.xpath(searchBtn_pim)
.click()
cy.xpath(searchBtn_pim).click()
},
resultTableDisplay () {
cy.xpath(searchResults)
.invoke('show').should('be.visible')
cy.xpath(searchResults).invoke('show').should('be.visible')
},
mousedownAdminTab () {
cy.xpath(admin_tabxPath_Homepage)
.invoke('show').should('be.visible')
.invoke('show')
.should('be.visible')
.trigger('mousedown')
},
touchAdminTab () {
cy.xpath(admin_tabxPath_Homepage)
.invoke('show').should('be.visible')
.invoke('show')
.should('be.visible')
.trigger('touchstart')
},
mouseoverAdminTab () {
cy.xpath(admin_tabxPath_Homepage)
.invoke('show').should('be.visible')
.invoke('show')
.should('be.visible')
.trigger('mouseover')
},
mouseOverAdminResultTableR1C2 () {
cy.xpath(admin_resultTableRow1Column2)
.invoke('show').should('be.visible')
.invoke('show')
.should('be.visible')
.trigger('mouseover')
},
mouseleaveAdminResultTableR1C2 () {
cy.xpath(admin_resultTableRow1Column2)
.invoke('show').should('be.visible')
.invoke('show')
.should('be.visible')
.trigger('mouseleave')
},
mouseOverAdminResultTableR2C2 () {
cy.xpath(admin_resultTableRow2Column2)
.invoke('show').should('be.visible')
.invoke('show')
.should('be.visible')
.trigger('mouseover')
},
mousActionsonDashboardGraph () {
cy.xpath(graph_dashboard)
.as('graph')
.trigger('mousedown')
.trigger('mousemove')
.trigger('mouseup')
.trigger('mouseleft', { which: 1, pageX: 600, pageY: 100 })
.trigger('mouseright', { which: 1, pageX: 600, pageY: 600 })
.trigger('mouseleave')
.as('graph')
.trigger('mousedown')
.trigger('mousemove')
.trigger('mouseup')
.trigger('mouseleft', { which: 1, pageX: 600, pageY: 100 })
.trigger('mouseright', { which: 1, pageX: 600, pageY: 600 })
.trigger('mouseleave')
},

textInsightsBelowGraph () {
cy.xpath(sectionBelowGraph)
.invoke('show').should('be.visible')
cy.xpath(sectionBelowGraph).invoke('show').should('be.visible')
},
viewPortIphone6 () {
cy.viewport('iphone-6')
Expand All @@ -162,19 +150,13 @@ export const homeOrangehrmPage = {

//accessibility related methods:
navJobtitleusingKeyboard () {
cy.xpath(supervisorPIMtab)
.click()
.tab()
.focused(jobTitleDropdown_pim)
cy.xpath(supervisorPIMtab).click().tab().focused(jobTitleDropdown_pim)
},

selectjobTitleusingKeyboard () {
cy.focused(jobTitleDropdown_pim)
.type('{downarrow}sales{downarrow}{enter}')
cy.focused(jobTitleDropdown_pim).type('{downarrow}sales{downarrow}{enter}')
},
pressSearchusingKeyboard () {
cy.xpath(searchBtn_pim)
.type('{enter}')
cy.xpath(searchBtn_pim).type('{enter}')
},
}

24 changes: 11 additions & 13 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,23 @@

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
const cucumber = require('cypress-cucumber-preprocessor').default
const getCompareSnapshotsPlugin = require('cypress-visual-regression/dist/plugin')
const cucumber = require("cypress-cucumber-preprocessor").default;
const getCompareSnapshotsPlugin = require("cypress-visual-regression/dist/plugin");
const {
addMatchImageSnapshotPlugin,
} = require('cypress-image-snapshot/plugin')
const path = require('path')
} = require("cypress-image-snapshot/plugin");
const path = require("path");


function getCongByFile (file) {
const pathToCongFile = path.resolve('cypress/', 'config', `${file}.json`)

return fs.readJson(pathToCongFile)
function getCongByFile(file) {
const pathToCongFile = path.resolve("cypress/", "config", `${file}.json`);
return fs.readJson(pathToCongFile);
}

module.exports = (on, config) => {
on('file:preprocessor', cucumber())
getCompareSnapshotsPlugin(on)
addMatchImageSnapshotPlugin(on, config)
on("file:preprocessor", cucumber());
getCompareSnapshotsPlugin(on);
addMatchImageSnapshotPlugin(on, config);

//const file = config.env.configFile;
//return getCongByFile(file);
}
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 28 additions & 30 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
const compareSnapshotCommand = require('cypress-visual-regression/dist/command')
import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command'
import 'cypress-file-upload'
const compareSnapshotCommand = require("cypress-visual-regression/dist/command");
import { addMatchImageSnapshotCommand } from "cypress-image-snapshot/command";
import "cypress-file-upload";

Cypress.Commands.add('check_URL_ResponseStatus', (args) => {
cy.get(args)
.each(($a) => {
const href = $a.prop('href')
Cypress.Commands.add("check_URL_ResponseStatus", (args) => {
cy.get(args).each(($a) => {
const href = $a.prop("href");

cy.request(href)
.its('body')
.should('include', '<title>')
.should('include', '<html>')
cy.request(href)
.then(function (resp) {
expect(resp.status).to.eq(200)
})
})
})
cy.request(href)
.its("body")
.should("include", "<title>")
.should("include", "<html>");
cy.request(href).then(function (resp) {
expect(resp.status).to.eq(200);
});
});
});

compareSnapshotCommand()
compareSnapshotCommand();
addMatchImageSnapshotCommand({
failureThreshold: 0.00,
failureThresholdType: 'percent',
failureThreshold: 0.0,
failureThresholdType: "percent",
customDiffConfig: { threshold: 0.0 },
capture: 'fullPage',
timeout: '60000',
})
capture: "fullPage",
timeout: "60000",
});

function terminalLog (violations) {
function terminalLog(violations) {
cy.task(
'log',
"log",
`${violations.length} accessibility violation${
violations.length === 1 ? '' : 's'
} ${violations.length === 1 ? 'was' : 'were'} detected`
)
violations.length === 1 ? "" : "s"
} ${violations.length === 1 ? "was" : "were"} detected`
);
// pluck specific keys to keep the table readable
const violationData = violations.map(
({ id, impact, description, nodes }) => ({
Expand All @@ -42,7 +40,7 @@ function terminalLog (violations) {
description,
nodes: nodes.length,
})
)
);

cy.task('table', violationData)
cy.task("table", violationData);
}
Loading

0 comments on commit 8c1d9d1

Please sign in to comment.