1.0.0 • Published 2 years ago

qms-automation-testing-21 v1.0.0

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

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

Chemical - Documentation


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

  1. clickById(id, itemNumber = 1)

    • itemNumber: 1-n (position of array element)
    • Ex:
      await page.clickById('#submit-button')
      await page.clickById('#submit-button', 2)
  2. clickByName(name, itemNumber = 1)

    • itemNumber: 1-n (position of array element)
    • Ex:
      await page.clickByName('submitButton')
      await page.clickByName('submitButton', 2)
  3. 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)
  4. clickByCssSelector(selectorClass)

    • Ex:
      await page.clickByCssSelector('#sidebarContent > div.left-content_add_button.ng-star-inserted > app-button > button', 5000);
  5. clickByXPath(path)

    • Ex: '/html/body/app-root/mat-sidenav-container/mat-sidenav-content/div/div/app-risk/div/div1/div2/div3/mat-form-field/div/div1/div'
      await page.clickByCssSelector('/html/body/app-root...');

Click to item in select

  1. 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);
  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);
  3. 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');
  4. 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

  1. 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);
  2. 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);
  3. waitForSelectorHavingContent(selector: string, timeout = 10000)

  4. waitForSelectorHavingHref(selector: string, timeout = 10000)
  5. waitForFileExisted(fileName: string, timeout = 10000)

Field Input

  1. sendKeysById(id: string, value: string)
  2. sendKeysByName(name: string, value: string)
  3. sendKeysByXPath(xpath: string, value: string)
  4. sendKeys(selector: string, text = '', timeout = 5000)

Table

  1. getBodyColumnTextInTableBySelector(selector: string, rowNumber = 1, colNumber = 1)

    • Get text of td element in a table
    • rowNumber: 1-n
    • colNumber: 1-n

Scroll

  1. scrollInElementById(id: string, height: number)
  2. scrollToPositionByOptionId(optionId: string, position: number)
  3. scrollToPositionByName(name: string, position: number)
  4. scrollToElementById(id: string)
  5. scrollBy(height: number)

Working with files

  1. deleteAlreadyDownloadedFiles(fileName: string)

    • Base folder: variable DOWNLOAD_FOLDER in .env file
  2. verifyFileExisted(fileName: string)

    • Base folder: variable DOWNLOAD_FOLDER in .env file
  3. waitForFileExisted(fileName: string, timeout = 10000)

expect methods

  1. expectText(val1: string, val2: string)
  2. expectEqual(val1: any, val2: any)
  3. expectNotEqual(val1: any, val2: any)

    • mustHaveContent(value: string)
    • Check page has content which contains value.

Console Log

  1. 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/

  1. Create folder e2e/src/hanbook/backend to contain test case files.
  2. 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
  3. In protractor file, change baseUrl and specs variables.

  4. 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.
  5. 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"
  6. 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');