diff --git a/customConfig.json b/customConfig.json new file mode 100644 index 00000000..58e19d8c --- /dev/null +++ b/customConfig.json @@ -0,0 +1,20 @@ +{ + "settings": { + "throttling": { + "rttMs": 0, + "throughputKbps": 20480, + "requestLatencyMs": 0, + "downloadThroughputKbps": 20480, + "uploadThroughputKbps": 20480, + "cpuSlowdownMultiplier": 1 + }, + "formFactor": "desktop", + "screenEmulation": { + "mobile": false, + "width": 1920, + "height": 1080, + "deviceScaleFactor": 1, + "disabled": false + } + } + } \ No newline at end of file diff --git a/docker/v12.7.1/package-lock.json b/docker/v12.7.1/package-lock.json index a2333995..10fccba6 100644 --- a/docker/v12.7.1/package-lock.json +++ b/docker/v12.7.1/package-lock.json @@ -9,15 +9,15 @@ "version": "12.7.1", "license": "Apache-2.0", "dependencies": { - "chai": "^5.2.0", + "chai": "^5.2.1", "csv-parser": "^3.2.0", "es-main": "^1.3.0", "express": "^5.1.0", - "lh-pptr-framework": "1.1.2", + "lh-pptr-framework": "1.2.0", "lighthouse": "^12.7.1", "logform": "^2.7.0", "mocha": "^11.7.1", - "puppeteer": "^24.12.0", + "puppeteer": "^24.12.1", "puppeteer-har": "^1.1.2", "request": "^2.88.2", "winston": "^3.17.0" @@ -1394,7 +1394,9 @@ "license": "Apache-2.0" }, "node_modules/chai": { - "version": "5.2.0", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.2.1.tgz", + "integrity": "sha512-5nFxhUrX0PqtyogoYOA8IPswy5sZFTOsBFl/9bNsmDLgsxYTzSZQJDPppDnZPTQbzSEm0hqGjWPzRemQCYbD6A==", "license": "MIT", "dependencies": { "assertion-error": "^2.0.1", @@ -1404,7 +1406,7 @@ "pathval": "^2.0.0" }, "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/chalk": { @@ -2764,9 +2766,9 @@ "license": "Apache-2.0" }, "node_modules/lh-pptr-framework": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/lh-pptr-framework/-/lh-pptr-framework-1.1.2.tgz", - "integrity": "sha512-ioX9glOjlRohUBKnx27GrjRBZ/26YsjmtXCaXyeFhEV0JQ97BfJPEcGhV7LrDUP2Pc1VsGYdNXtZpPV/EZjsfw==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/lh-pptr-framework/-/lh-pptr-framework-1.2.0.tgz", + "integrity": "sha512-wKertxOI3hrbeOTBCVd21iECUhLP5Z/0ZkIiUfm4cvA7Djh2dst1eLw11gJtvw3VmG3HmSnyy2VsREPPhTBzow==", "license": "ISC" }, "node_modules/lighthouse": { @@ -3437,9 +3439,9 @@ } }, "node_modules/puppeteer": { - "version": "24.12.0", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-24.12.0.tgz", - "integrity": "sha512-MJtM71qex8h03bDBZTyPfSC7tfvDLILnWWl4rNdo3+HODiFZX+3yj/qLVwVu/gXoxQ7U8dNDKyFz4e8VBHdcmw==", + "version": "24.12.1", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-24.12.1.tgz", + "integrity": "sha512-+vvwl+Xo4z5uXLLHG+XW8uXnUXQ62oY6KU6bEFZJvHWLutbmv5dw9A/jcMQ0fqpQdLydHmK0Uy7/9Ilj8ufwSQ==", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -3447,7 +3449,7 @@ "chromium-bidi": "5.1.0", "cosmiconfig": "^9.0.0", "devtools-protocol": "0.0.1464554", - "puppeteer-core": "24.12.0", + "puppeteer-core": "24.12.1", "typed-query-selector": "^2.12.0" }, "bin": { @@ -3458,9 +3460,9 @@ } }, "node_modules/puppeteer-core": { - "version": "24.12.0", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-24.12.0.tgz", - "integrity": "sha512-VrPXPho5Q90Ao86FwJVb+JeAF2Tf41wOTGg8k2SyQJePiJ6hJ5iujYpmP+bmhlb6o+J26bQYRDPOYXP7ALWcxQ==", + "version": "24.12.1", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-24.12.1.tgz", + "integrity": "sha512-8odp6d3ERKBa3BAVaYWXn95UxQv3sxvP1reD+xZamaX6ed8nCykhwlOiHSaHR9t/MtmIB+rJmNencI6Zy4Gxvg==", "license": "Apache-2.0", "dependencies": { "@puppeteer/browsers": "2.10.5", diff --git a/docker/v12.7.1/package.json b/docker/v12.7.1/package.json index 2bb2d7f0..84301649 100644 --- a/docker/v12.7.1/package.json +++ b/docker/v12.7.1/package.json @@ -10,10 +10,10 @@ "crawl": "node crawler/crawler.js" }, "dependencies": { - "lh-pptr-framework": "1.1.2", + "lh-pptr-framework": "1.2.0", "lighthouse": "^12.7.1", - "puppeteer": "^24.12.0", - "chai": "^5.2.0", + "puppeteer": "^24.12.1", + "chai": "^5.2.1", "es-main": "^1.3.0", "express": "^5.1.0", "logform": "^2.7.0", diff --git a/package-lock.json b/package-lock.json index a2333995..10fccba6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,15 +9,15 @@ "version": "12.7.1", "license": "Apache-2.0", "dependencies": { - "chai": "^5.2.0", + "chai": "^5.2.1", "csv-parser": "^3.2.0", "es-main": "^1.3.0", "express": "^5.1.0", - "lh-pptr-framework": "1.1.2", + "lh-pptr-framework": "1.2.0", "lighthouse": "^12.7.1", "logform": "^2.7.0", "mocha": "^11.7.1", - "puppeteer": "^24.12.0", + "puppeteer": "^24.12.1", "puppeteer-har": "^1.1.2", "request": "^2.88.2", "winston": "^3.17.0" @@ -1394,7 +1394,9 @@ "license": "Apache-2.0" }, "node_modules/chai": { - "version": "5.2.0", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.2.1.tgz", + "integrity": "sha512-5nFxhUrX0PqtyogoYOA8IPswy5sZFTOsBFl/9bNsmDLgsxYTzSZQJDPppDnZPTQbzSEm0hqGjWPzRemQCYbD6A==", "license": "MIT", "dependencies": { "assertion-error": "^2.0.1", @@ -1404,7 +1406,7 @@ "pathval": "^2.0.0" }, "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/chalk": { @@ -2764,9 +2766,9 @@ "license": "Apache-2.0" }, "node_modules/lh-pptr-framework": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/lh-pptr-framework/-/lh-pptr-framework-1.1.2.tgz", - "integrity": "sha512-ioX9glOjlRohUBKnx27GrjRBZ/26YsjmtXCaXyeFhEV0JQ97BfJPEcGhV7LrDUP2Pc1VsGYdNXtZpPV/EZjsfw==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/lh-pptr-framework/-/lh-pptr-framework-1.2.0.tgz", + "integrity": "sha512-wKertxOI3hrbeOTBCVd21iECUhLP5Z/0ZkIiUfm4cvA7Djh2dst1eLw11gJtvw3VmG3HmSnyy2VsREPPhTBzow==", "license": "ISC" }, "node_modules/lighthouse": { @@ -3437,9 +3439,9 @@ } }, "node_modules/puppeteer": { - "version": "24.12.0", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-24.12.0.tgz", - "integrity": "sha512-MJtM71qex8h03bDBZTyPfSC7tfvDLILnWWl4rNdo3+HODiFZX+3yj/qLVwVu/gXoxQ7U8dNDKyFz4e8VBHdcmw==", + "version": "24.12.1", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-24.12.1.tgz", + "integrity": "sha512-+vvwl+Xo4z5uXLLHG+XW8uXnUXQ62oY6KU6bEFZJvHWLutbmv5dw9A/jcMQ0fqpQdLydHmK0Uy7/9Ilj8ufwSQ==", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -3447,7 +3449,7 @@ "chromium-bidi": "5.1.0", "cosmiconfig": "^9.0.0", "devtools-protocol": "0.0.1464554", - "puppeteer-core": "24.12.0", + "puppeteer-core": "24.12.1", "typed-query-selector": "^2.12.0" }, "bin": { @@ -3458,9 +3460,9 @@ } }, "node_modules/puppeteer-core": { - "version": "24.12.0", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-24.12.0.tgz", - "integrity": "sha512-VrPXPho5Q90Ao86FwJVb+JeAF2Tf41wOTGg8k2SyQJePiJ6hJ5iujYpmP+bmhlb6o+J26bQYRDPOYXP7ALWcxQ==", + "version": "24.12.1", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-24.12.1.tgz", + "integrity": "sha512-8odp6d3ERKBa3BAVaYWXn95UxQv3sxvP1reD+xZamaX6ed8nCykhwlOiHSaHR9t/MtmIB+rJmNencI6Zy4Gxvg==", "license": "Apache-2.0", "dependencies": { "@puppeteer/browsers": "2.10.5", diff --git a/package.json b/package.json index 2bb2d7f0..84301649 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,10 @@ "crawl": "node crawler/crawler.js" }, "dependencies": { - "lh-pptr-framework": "1.1.2", + "lh-pptr-framework": "1.2.0", "lighthouse": "^12.7.1", - "puppeteer": "^24.12.0", - "chai": "^5.2.0", + "puppeteer": "^24.12.1", + "chai": "^5.2.1", "es-main": "^1.3.0", "express": "^5.1.0", "logform": "^2.7.0", diff --git a/pages/demoqa/buttonsPage.js b/pages/demoqa/buttonsPage.js index 99207608..34598436 100644 --- a/pages/demoqa/buttonsPage.js +++ b/pages/demoqa/buttonsPage.js @@ -10,6 +10,7 @@ export default class ButtonsPage extends Page { init(page) { super.init(page) + this.pageValidate = new Element("//button[text()='Click Me']", page) this.clickBtn = new Button("//button[text()='Click Me']", page) this.clickVerify = new Element("#dynamicClickMessage", page) this.doubleClickBtn = new Button("//button[text()='Double Click Me']", page) @@ -25,8 +26,8 @@ export default class ButtonsPage extends Page { // Then: I wait for click message to appear // And: I measure action time performance of the page */ - async simpleClickButton(browser) { - await browser.timespan("Simple click button", async () => { + async simpleClickButton(browser, testContext) { + await browser.timespan(`${testContext?.test?.title}`, async () => { await this.clickBtn.click() await this.clickVerify.find() await browser.waitTillRendered() @@ -40,8 +41,8 @@ export default class ButtonsPage extends Page { // Then: I wait for click message to appear // And: I measure action time performance of the page */ - async doubleClickButton(browser) { - await browser.timespan("Double click button", async () => { + async doubleClickButton(browser, testContext) { + await browser.timespan(`${testContext?.test?.title}`, async () => { await this.doubleClickBtn.doubleClick() await this.doubleClickVerify.find() await browser.waitTillRendered() @@ -55,8 +56,8 @@ export default class ButtonsPage extends Page { // Then: I wait for click message to appear // And: I measure action time performance of the page */ - async rightClickButton(browser) { - await browser.timespan("Right click button", async () => { + async rightClickButton(browser, testContext) { + await browser.timespan(`${testContext?.test?.title}`, async () => { await this.rightClickBtn.rightClick() await this.rightClickVerify.find() await browser.waitTillRendered() diff --git a/pages/demoqa/checkBoxPage.js b/pages/demoqa/checkBoxPage.js index a9ca11e7..35b3f4c0 100644 --- a/pages/demoqa/checkBoxPage.js +++ b/pages/demoqa/checkBoxPage.js @@ -10,6 +10,7 @@ export default class CheckBoxPage extends Page { init(page) { super.init(page) + this.pageValidate = new Element("//*[@id='tree-node']//span[text()='Desktop']", page) this.homeCheckBox = new Button("label[for='tree-node-home']", page) this.homeSelectVerify = new Element("//*[@id='result']/span[text()='home']", page) this.checkBoxExpandHome = new Button("#tree-node > ol > li > span > button", page) @@ -25,8 +26,8 @@ export default class CheckBoxPage extends Page { // Then: I wait for 'Home' checkbox to be selected // And: I measure action time performance of the page */ - async selectHomeCheckbox(browser) { - await browser.timespan("Select 'Home' checkBox", async () => { + async selectHomeCheckbox(browser, testContext) { + await browser.timespan(`${testContext?.test?.title}`, async () => { await this.homeCheckBox.click() await this.homeSelectVerify.find() await browser.waitTillRendered() @@ -40,8 +41,8 @@ export default class CheckBoxPage extends Page { // Then: I wait for 'Home' treeNode to be expanded // And: I measure action time performance of the page */ - async expandHomeTreeNode(browser) { - await browser.timespan("Expand 'Home' treeNode", async () => { + async expandHomeTreeNode(browser, testContext) { + await browser.timespan(`${testContext?.test?.title}`, async () => { await this.checkBoxExpandHome.click() await this.checkBoxSelectVerify.find() await browser.waitTillRendered() @@ -56,8 +57,8 @@ export default class CheckBoxPage extends Page { // Then: I wait for 'Desktop' checkbox to be deselected // And: I measure action time performance of the page */ - async deselectDesktopCheckbox(browser) { - await browser.timespan("Deselect 'Desktop' checkBox", async () => { + async deselectDesktopCheckbox(browser, testContext) { + await browser.timespan(`${testContext?.test?.title}`, async () => { await this.desktopCheckbox.click() await this.desktopCheckboxVerify.findHidden() await browser.waitTillRendered() diff --git a/pages/demoqa/homePage.js b/pages/demoqa/homePage.js index 35c61f74..3490691c 100644 --- a/pages/demoqa/homePage.js +++ b/pages/demoqa/homePage.js @@ -1,4 +1,5 @@ import Page from "lh-pptr-framework/core/page.js"; +import Element from "lh-pptr-framework/core/elements/element.js"; import Button from "lh-pptr-framework/core/elements/button.js"; import TextField from "lh-pptr-framework/core/elements/textField.js"; @@ -10,6 +11,7 @@ export default class HomePage extends Page { init(page) { super.init(page) + this.pageValidate = new Element('//h5[text()="Elements"]', page) this.elements = new Button('//h5[text()="Elements"]', page) this.forms = new Button('//h5[text()="Forms"]', page) this.alertsFrameWindows = new Button('//h5[text()="Alerts, Frame & Windows"]', page) @@ -26,8 +28,8 @@ export default class HomePage extends Page { // Then: I wait for the new page to be rendered // And: I stop measuring action time performance of the page */ - async clickOnElements(browser) { - await browser.timespan("Click on 'Elements'", async () => { + async clickOnElements(browser, testContext) { + await browser.timespan(`${testContext?.test?.title}`, async () => { await this.elements.count() await this.elements.click() await browser.waitTillRendered() diff --git a/pages/demoqa/textBoxPage.js b/pages/demoqa/textBoxPage.js index 9aaf2429..a41406ab 100644 --- a/pages/demoqa/textBoxPage.js +++ b/pages/demoqa/textBoxPage.js @@ -11,6 +11,7 @@ export default class TextBoxPage extends Page { init(page) { super.init(page) + this.pageValidate = new Element("input[id='userName']", page) this.fullName = new TextField("input[id='userName']", page) this.userEmail = new TextField("input[id='userEmail']", page) this.currentAddress = new TextField("textarea[id='currentAddress']", page) @@ -27,13 +28,13 @@ export default class TextBoxPage extends Page { // And: I wait for "textBoxVerify" to be visible // And: I stop measuring action time performance of the page */ - async submitTextForm(browser) { + async submitTextForm(browser, testContext) { await this.fullName.type("UI TESTER") await this.userEmail.type("ui_tester@gmail.com") await this.currentAddress.type("mars, musk st., 39 apt., twitter") await this.permanentAddress.type("earth, UK, cotswolds, clarkson's farm") - await browser.timespan("Submit text box form", async () => { + await browser.timespan(`${testContext?.test?.title}`, async () => { await this.submit.click() await this.textBoxVerify.find() await browser.waitTillRendered() diff --git a/pages/demoqa/uploadDownloadPage.js b/pages/demoqa/uploadDownloadPage.js index 90fa1c63..53a00094 100644 --- a/pages/demoqa/uploadDownloadPage.js +++ b/pages/demoqa/uploadDownloadPage.js @@ -11,6 +11,7 @@ export default class UploadDownloadPage extends Page { init(page) { super.init(page) + this.pageValidate = new Element("input[id='uploadFile']", page) this.uploadFile = new UploadField("input[id='uploadFile']", page) this.uploadVerify = new Element("//*[@id='uploadedFilePath' and contains(text(),'uploadTest.txt')]", page) } @@ -21,11 +22,11 @@ export default class UploadDownloadPage extends Page { // Then: I wait for upload verification message to appear // And: I measure action time performance of the page */ - async uploadFileIntoInput(browser) { - await browser.timespan("Upload file into 'Choose File'", async () => { - await this.uploadFile.upload("/testdata/files/uploadTest.txt") + async uploadFileIntoInput(browser, testContext) { + await browser.timespan(`${testContext?.test?.title}`, async () => { + await this.uploadFile.upload("/testdata/files/uploadTest.txt") // Windows requires full path await this.uploadVerify.find() - await browser.waitTillRendered() //TODO it fails with "RESULT_CODE_KILLED_BAD_MESSAGE" + await browser.waitTillRendered() }) } diff --git a/pages/powerapps/pages.js b/pages/powerapps/pages.js index 8d27e399..495fffe9 100644 --- a/pages/powerapps/pages.js +++ b/pages/powerapps/pages.js @@ -6,19 +6,20 @@ import Iframe from "lh-pptr-framework/core/elements/iframe.js"; export default class PowerApps extends Page { constructor(page) { super(page); - this.url = "https://apps.powerapps.com/play/e/default-b41b72d0-4e9f-4c26-8a69-f949f367c91d/a/4f3abb6f-5e6a-4e4a-b3b2-09123d78a5f7?tenantId=b41b72d0-4e9f-4c26-8a69-f949f367c91d&source=portal/"; + this.setPath('/'); } init(page) { super.init(page); + this.pageValidate = new Element("iframe[id='fullscreen-app-host']", page); this.appFrame = new Iframe("iframe[id='fullscreen-app-host']", page); this.marketing = new Button('(//*[@data-control-name="Button3"])[1]', page); this.marketingHeader = new Element("[data-control-name='TextBox1_13']", page); this.teamsIcon = new Button("#AddToTeamsButton", page); } - async clickOnMarketing(browser) { - await browser.timespan("Click on 'marketing'", async () => { + async clickOnMarketing(browser, testContext) { + await browser.timespan(`${testContext?.test?.title}`, async () => { this.init(await this.appFrame.createIframe()); await this.marketing.click(); await this.marketingHeader.find(); @@ -26,10 +27,10 @@ export default class PowerApps extends Page { }) } - async checkTeamsPage(browser) { + async checkTeamsPage(browser, testContext) { this.init(browser.page); await this.teamsIcon.click(); let newPage = await browser.getNewPageWhenLoaded(); - await this.coldNavigation(newPage.url()); + await this.navigation(browser, testContext, newPage.url()); } } \ No newline at end of file diff --git a/test/demo.test.steps.js b/test/demo.test.steps.js index a8ffea3f..44d75e5f 100644 --- a/test/demo.test.steps.js +++ b/test/demo.test.steps.js @@ -1,26 +1,21 @@ import logger from "lh-pptr-framework/logger/logger.js"; import HomePage from '../pages/demoqa/homePage.js'; import TextBoxPage from '../pages/demoqa/textBoxPage.js'; -import UploadDownloadPage from '../pages/demoqa/uploadDownloadPage.js'; -import CheckBoxPage from '../pages/demoqa/checkBoxPage.js'; -import ButtonsPage from '../pages/demoqa/buttonsPage.js'; import { beforeHook, beforeEachHook, afterEachHook, afterHook } from 'lh-pptr-framework/settings/mochaHooks.js'; import * as params from 'lh-pptr-framework/settings/testParams.js'; let browser; const Home = new HomePage(); const TextBox = new TextBoxPage(); -const CheckBox = new CheckBoxPage(); -const Buttons = new ButtonsPage(); +const pages = [Home, TextBox]; // Extend the common beforeHook with additional setup const customBeforeHook = async () => { await beforeHook(); // Perform the common setup first (browser startup) browser = await params.getBrowserInstance(); - Home.init(browser.page); // Sets instance of puppeteer page to Home page object - TextBox.init(browser.page); // Sets instance of puppeteer page to TextBox page object - CheckBox.init(browser.page); // Sets instance of puppeteer page to CheckBox page object - Buttons.init(browser.page); // Sets instance of puppeteer page to Buttons page object + for (const page of pages) { + page.init(browser.page); // Sets instance of puppeteer page to page objects + } }; // Specify all mocha hooks @@ -29,14 +24,23 @@ beforeEach(beforeEachHook); afterEach(afterEachHook); after(afterHook); -it(`[ColdNavigation] Check ${Home.getURL()}`, async function () { - await Home.coldNavigation(browser) +it(`[N]_${Home.getURL()}`, async function () { + await Home.navigationValidate(browser, this) }).timeout(params.testTime); -it("[WarmNavigation] Check Home URL", async function () { - await Home.warmNavigation(browser) +it("[N]_Home", async function () { + await Home.navigationValidate(browser, this) }).timeout(params.testTime); -it("[Timespan] Click on 'Elements'", async function () { - await Home.clickOnElements(browser) +it("[N]_Home--reset", async function () { + // Example of how to measure current page URL and restart browser + browser = await Home.navigationValidate(browser, this, browser.page.url(), pages) +}).timeout(params.testTime); + +it("[T]_Click_on_Elements", async function () { + await Home.clickOnElements(browser, this) +}).timeout(params.testTime); + +it(`[N]_TextBox--reset`, async function () { + browser = await TextBox.navigationValidate(browser, this, TextBox.getURL(), pages) }).timeout(params.testTime); \ No newline at end of file diff --git a/test/huge.test.steps.js b/test/huge.test.steps.js index a28800fb..31077ff8 100644 --- a/test/huge.test.steps.js +++ b/test/huge.test.steps.js @@ -14,15 +14,16 @@ const UploadDownload = new UploadDownloadPage(); const CheckBox = new CheckBoxPage(); const Buttons = new ButtonsPage(); +const pages = [Home, TextBox, UploadDownload, + CheckBox, Buttons]; + // Extend the common beforeHook with additional setup const customBeforeHook = async () => { await beforeHook(); // Perform the common setup first (browser startup) browser = await params.getBrowserInstance(); - Home.init(browser.page); // Sets instance of puppeteer page to Home page object - TextBox.init(browser.page); // Sets instance of puppeteer page to TextBox page object - UploadDownload.init(browser.page); // Sets instance of puppeteer page to UploadDownload page object - CheckBox.init(browser.page); // Sets instance of puppeteer page to CheckBox page object - Buttons.init(browser.page); // Sets instance of puppeteer page to Buttons page object + for (const page of pages) { + page.init(browser.page); // Sets instance of puppeteer page to page objects + } }; // Specify all mocha hooks @@ -31,62 +32,62 @@ beforeEach(beforeEachHook); afterEach(afterEachHook); after(afterHook); -it(`[ColdNavigation] Check ${Home.getURL()}`, async function () { - await Home.coldNavigation(browser) +it(`[N]_${Home.getURL()}`, async function () { + await Home.navigation(browser, this) }).timeout(params.testTime); -it("[WarmNavigation] Check Home URL", async function () { - await Home.warmNavigation(browser) +it("[N]_Home_URL", async function () { + await Home.navigation(browser, this) }).timeout(params.testTime); -it("[Timespan] Click on 'Elements'", async function () { - await Home.clickOnElements(browser) +it("[T]_Click_on_Elements", async function () { + await Home.clickOnElements(browser, this) }).timeout(params.testTime); -it(`[ColdNavigation] Check ${TextBox.getURL()}`, async function () { - await TextBox.coldNavigation(browser) +it(`[N]_${TextBox.getURL()}`, async function () { + await TextBox.navigation(browser, this) }).timeout(params.testTime); -it("[Timespan] Submit text box form", async function () { - await TextBox.submitTextForm(browser) +it("[T]_Submit_text_box_form", async function () { + await TextBox.submitTextForm(browser, this) }).timeout(params.testTime); -it(`[ColdNavigation] Check ${CheckBox.getURL()}`, async function () { - await CheckBox.coldNavigation(browser) +it(`[N]_${CheckBox.getURL()}`, async function () { + await CheckBox.navigation(browser, this) }).timeout(params.testTime); -it("[Timespan] Select 'Home' checkBox", async function () { - await CheckBox.selectHomeCheckbox(browser) +it("[T]_Select_Home_checkBox", async function () { + await CheckBox.selectHomeCheckbox(browser, this) }).timeout(params.testTime); -it("[Timespan] Expand 'Home' treeNode", async function () { - await CheckBox.expandHomeTreeNode(browser) +it("[T]_Expand_Home_treeNode", async function () { + await CheckBox.expandHomeTreeNode(browser, this) }).timeout(params.testTime); -it("[Timespan] Deselect 'Desktop' checkBox", async function () { - await CheckBox.deselectDesktopCheckbox(browser) +it("[T]_Deselect_Desktop_checkBox", async function () { + await CheckBox.deselectDesktopCheckbox(browser, this) }).timeout(params.testTime); -it(`[ColdNavigation] Check ${Buttons.getURL()}`, async function () { - await Buttons.coldNavigation(browser) +it(`[N]_${Buttons.getURL()}`, async function () { + await Buttons.navigation(browser, this) }).timeout(params.testTime); -it("[Timespan] Simple click button", async function () { - await Buttons.simpleClickButton(browser) +it("[T]_Simple_click_button", async function () { + await Buttons.simpleClickButton(browser, this) }).timeout(params.testTime); -it("[Timespan] Double click button", async function () { - await Buttons.doubleClickButton(browser) +it("[T]_Double_click_button", async function () { + await Buttons.doubleClickButton(browser, this) }).timeout(params.testTime); -it("[Timespan] Right click button", async function () { - await Buttons.rightClickButton(browser) +it("[T]_Right_click_button", async function () { + await Buttons.rightClickButton(browser, this) }).timeout(params.testTime); -it(`[ColdNavigation] Check ${UploadDownload.getURL()}`, async function () { - await UploadDownload.coldNavigation(browser) +it(`[N]_${UploadDownload.getURL()}`, async function () { + await UploadDownload.navigation(browser, this) }).timeout(params.testTime); -it("[Timespan] Upload file into 'Choose File'", async function () { - await UploadDownload.uploadFileIntoInput(browser) +it("[T]_Upload_file_into_input", async function () { + await UploadDownload.uploadFileIntoInput(browser, this) }).timeout(params.testTime); \ No newline at end of file diff --git a/test/powerapps.test.js b/test/powerapps.test.js index c43d6ad4..e04b849e 100644 --- a/test/powerapps.test.js +++ b/test/powerapps.test.js @@ -3,21 +3,17 @@ import PowerAppsPage from "../pages/powerapps/pages.js"; import { beforeHook, beforeEachHook, afterEachHook, afterHook } from 'lh-pptr-framework/settings/mochaHooks.js'; import * as params from 'lh-pptr-framework/settings/testParams.js'; -before(async () => { - await browser.init(); - await browser.start(); - browser.page.isSuccess = true; - PowerApps.init(browser.page); -}); - let browser; const PowerApps = new PowerAppsPage(); +const pages = [PowerApps]; // Extend the common beforeHook with additional setup const customBeforeHook = async () => { await beforeHook(); // Perform the common setup first (browser startup) browser = await params.getBrowserInstance(); - PowerApps.init(browser.page); // Sets instance of puppeteer page to PowerApps page object + for (const page of pages) { + page.init(browser.page); // Sets instance of puppeteer page to page objects + } }; // Specify all mocha hooks @@ -26,26 +22,15 @@ beforeEach(beforeEachHook); afterEach(afterEachHook); after(afterHook); -// Given: I am opening the browser -// When: I am navigating to Home page -// Then: I measure cold navigation performance of the page -it("[ColdNavigation] Check PowerApps URL", async function () { - await PowerApps.coldNavigation(browser); +it("[N]_PowerApps_URL", async function () { + await PowerApps.navigation(browser, this); await new Promise(resolve => setTimeout(resolve, 120000)); }).timeout(params.testTime); -// Given: I am on the Home page -// When: I click on "marketing" inside iframe -// Then: I wait for the new page to be rendered -// And: I stop measuring action time performance of the page -it("[Timespan] Click on 'marketing'", async function () { - await PowerApps.clickOnMarketing(browser) +it("[T]_Click_on_'marketing'", async function () { + await PowerApps.clickOnMarketing(browser, this) }).timeout(params.testTime); -// Given: I am on the "Marketing" page -// When: I click on "Teams" icon -// Then: I take the URL of the page that opened -// And: I measure cold navigation performance of the new page URL -it("[ColdNavigation] Check 'Teams' page", async function () { - await PowerApps.checkTeamsPage(browser); +it("[N]_Teams_page", async function () { + await PowerApps.checkTeamsPage(browser, this); }).timeout(params.testTime); \ No newline at end of file