qms-automation-testing-2
v1.23.2
Published
- Pull the latest code from the repository ``` git pull ``` - Add all code to staged (to push code to repository) ``` git add . ``` - Push code to repository ``` git push ```
Downloads
2
Readme
git
- Pull the latest code from the repository
git pull
- Add all code to staged (to push code to repository)
git add .
- Push code to repository
git push
Docs
Running end-to-end tests
Run ng e2e
to execute the end-to-end tests via Protractor.
Chemical-db
e2e site
https://backend.chemical-db.e2e.qms.netpower.cloud/
- Run all test cases
npm run e2e-chemical-db-e2e
- Run the specific test case
npm run e2e-chemical-db-e2e-dev
Staging site
https://backend.chemical-db.qms.netpower.cloud/
- Run all test cases
npm run e2e-chemical-db-staging
- Run the specific test case
npm run e2e-chemical-db-staging-dev
dev site
http://backend.dev.qms.netpower.cloud/
- Run all test cases
npm run e2e-chemical-db-dev
- Run the specific test case
npm run e2e-chemical-db-dev-dev
Deviation
qc site
http://deviation.qc.qms.netpower.cloud/
- Run all test cases
npm run e2e-deviation-qc
- Run the specific test case
npm run e2e-deviation-qc-dev
backend qc site
http://backend.qc.qms.netpower.cloud/deviation/
- Run all test cases
npm run e2e-deviation-backend-qc
- Run the specific test case
npm run e2e-deviation-backend-qc-dev
Risk
qc site
http://backend.qc.qms.netpower.cloud/rm
- Run all test cases
npm run e2e-risk-backend-qc
- Run the specific test case
npm run e2e-risk-backend-qc-dev
Process
backend-staging
http://backend.process.qms.netpower.cloud/
- Run all test cases
npm run e2e-process-backend-staging
- Run the specific test case
npm run e2e-process-backend-staging-dev
staging
http://handbook.process.qms.netpower.cloud/
- Run all test cases
npm run e2e-process-staging
- Run the specific test case
npm run e2e-process-staging-dev
Methods
Click
Click to element
clickById(id, itemNumber = 1)
- itemNumber: 1-n (position of array element)
- Ex:
await page.clickById('#submit-button') await page.clickById('#submit-button', 2)
clickByName(name, itemNumber = 1)
- itemNumber: 1-n (position of array element)
- Ex:
await page.clickByName('submitButton') await page.clickByName('submitButton', 2)
clickBySelector(name, itemNumber = 1)
- itemNumber: 1-n (position of array element)
- Ex:
await page.clickBySelector('#submit-button') await page.clickBySelector('btn-loading[name="submitButton"]', 2)
clickByCssSelector(selectorClass)
- Ex:
await page.clickByCssSelector('#sidebarContent > div.left-content_add_button.ng-star-inserted > app-button > button', 5000);
- Ex:
clickByXPath(path)
- Ex: '/html/body/app-root/mat-sidenav-container/mat-sidenav-content/div/div/app-risk/div/div[1]/div[2]/div[3]/mat-form-field/div/div[1]/div'
await page.clickByCssSelector('/html/body/app-root...');
- Ex: '/html/body/app-root/mat-sidenav-container/mat-sidenav-content/div/div/app-risk/div/div[1]/div[2]/div[3]/mat-form-field/div/div[1]/div'
Click to item in select
clickItemPositionInSelectorControlById(optionId, position)
- optionId: id of element item in select control
- position: position of selected element in list (1-n)
- Ex:
await page.clickItemPositionInSelectorControlById('sorter-option', 2);
clickItemPositionInSelectorControlByName(optionName, position)
- optionName: name of element item in select control
- position: position of selected element in list (1-n)
- Ex:
await page.clickItemPositionInSelectorControlByName('sorterOption', 2);
clickItemValueInSelectorControlById(optionId, value)
- optionId: id of element item in select control
- value: value text of selected element in list
- Ex:
await page.clickItemValueInSelectorControlById('sorter-option', 'Name Z - A');
clickItemValueInSelectorControlByName(optionName, value)
- optionName: name of element item in select control
- value: value text of selected element in list
- Ex:
await page.clickItemValueInSelectorControlByName('sorterOption', 'Name Z - A');
Wait for loaded
waitForTableShownById(id: string, expectedNumber: number, timeout = 10000)
- id: id of table element
- expectedNumber: number of row in table
- timeout: default = 10s
- Ex:
await page.waitForTableShownById('sds-list-table', 10);
waitForTableShownBySelector(selector: string, expectedNumber: number, timeout = 10000)
- expectedNumber: number of row in table
- timeout: default = 10s
- Ex:
await page.waitForTableShownBySelector('#pdf-viewer-left div.ng2-pdf-viewer-container div.pdfViewer div.page', 10, 10000);
waitForSelectorHavingContent(selector: string, timeout = 10000)
waitForSelectorHavingHref(selector: string, timeout = 10000)
waitForFileExisted(fileName: string, timeout = 10000)
Field Input
- sendKeysById(id: string, value: string)
- sendKeysByName(name: string, value: string)
- sendKeysByXPath(xpath: string, value: string)
- sendKeys(selector: string, text = '', timeout = 5000)
Table
getBodyColumnTextInTableBySelector(selector: string, rowNumber = 1, colNumber = 1)
- Get text of td element in a table
- rowNumber: 1-n
- colNumber: 1-n
Scroll
- scrollInElementById(id: string, height: number)
- scrollToPositionByOptionId(optionId: string, position: number)
- scrollToPositionByName(name: string, position: number)
- scrollToElementById(id: string)
- scrollBy(height: number)
Working with files
deleteAlreadyDownloadedFiles(fileName: string)
- Base folder: variable DOWNLOAD_FOLDER in .env file
verifyFileExisted(fileName: string)
- Base folder: variable DOWNLOAD_FOLDER in .env file
waitForFileExisted(fileName: string, timeout = 10000)
expect methods
expectText(val1: string, val2: string)
expectEqual(val1: any, val2: any)
expectNotEqual(val1: any, val2: any)
- mustHaveContent(value: string)
- Check page has content which contains value.
Console Log
printTextById(id: string)
- printTextByXPath(path: string)
- printTextBySelector(selector: string)
Set up new site
Ex: Set up backend-qc site for Handbook
url: http://backend.qc.qms.netpower.cloud/
Create folder e2e/src/hanbook/backend to contain test case files.
Create 2 files
- e2e/protractor.conf.handbook.backend.js to run all test cases
- e2e/protractor.conf.handbook.backend.dev.js to run specific test case
In protractor file, change baseUrl and specs variables.
In angular/json file, create new project for handbook-backend (the same with chemical-db and deviation)
- create new configurations: qc and qc-dev.
- Configurate protractorConfig and baseUrl.
In package.json file, create new scripts
- e2e-handbook-backend-qc:
"e2e-handbook-backend-qc": "ng e2e handbook-backend --dev-server-target=\"\" -c qc"
- e2e-handbook-backend-qc-dev
"e2e-handbook-backend-qc": "ng e2e handbook-backend --dev-server-target=\"\" -c qc-dev"
- e2e-handbook-backend-qc:
Common methods
- await page.waitForSelector('#category-simple-list div.simple-list-conatiner div.row-item');
- await page.clickBySelector('#category-simple-list div.simple-list-conatiner div.row-item div.custom-icon-display button')
- await page.clearKeyBySelector('#name');
- await page.sendKeyBySelector('#name', value);
- page.expectText(value1, value2);
- page.expectNotEqual(value1, value2);
- await page.getTextBySelector('div.simple-list-conatiner div.row-item div.col-md-7 span.mat-checkbox-label');
- await page.getTextBySelector('div.simple-list-conatiner div.row-item:nth-child(1) div.col-md-7 span.mat-checkbox-label');