Skip to content
This repository has been archived by the owner on Jan 23, 2022. It is now read-only.

hungdao-testing/amazonweb

Repository files navigation

Using CodeceptJs to test Amazon Website

CodeceptJS is a modern end to end testing framework with sugar syntax built on top of node-js along with some popular libraries. It bypasses execution commands to helpers. Depending on the helper enabled, your tests will be executed differently.

List of available helpers: WebDriver, Protractor, Puppeteer, Playwright, Nightmare, TestCafe

List all scenarios are being covered in the framework

  1. Login with valid account
  • [:mag:Analysis] Due to the security reason, Amazon forces customer provide OTP code once logging.

  • [:white_check_mark:Solution] Writing Email API function to grab latest email from Amazon by query 'in:inbox from:account-update@amazon.com', then using regex to extract OTP code (One Time Password \(OTP\):)(.\d{6})/

    Notes: In this POC, I use Gmail as the main registration email to work with Amazon Web.

  1. Login with invalid account
  • [:mag:Analysis] no email, no password, invalid credential.
  1. Search a book with keyword "apple" and language "en", and verify each pags in search result returns 16 items.
  • [:mag:Analysis] To verify each pages return 16 items exactly: grab items in first page, second page and last pages. If the number of items in 3 pages are 16, the test will be passed.
  1. Search a book with keyword "apple" and sort Publication date
  • The configuration of framework is placed in ./configs folder, to learn more details, visit: configuration

    • codecept_shared.js common configuration.
    • puppeteer.conf.js puppeteer configuration
    • webdriver.conf.js webdriverio configuration

    ** Notes: To run specific configuration above, passing -c ./configs/<name_configuration>

  • The data files are placed under /fixtures/data

  • Apply Puppeteer as the main browser execution

  • Apply Page Object pattern to construct the pages.

  • Apply Page fragment to gather all autonomous parts of a page, like modal boxes, components, widgets.

  • Apply Page Factory design pattern to control page objects and page fragment (./tests/pageFactory.js)

  • Apply Data-driven for invalid login scenario

  • Apply Allure report to generate report under output

  1. Environments
  • Install Nodejs https://nodejs.org/en/
  • Install an editor supported Nodejs (suggestion: Vscode)
  • Upgrade your Chrome browser (as the main one) to latest.
  1. Accounts
  • Register an account to Amazon web.
  1. Deployment the source code.

    • Run command line npm i at the root of the folder
  2. Precondition to run test cases.

    • Input account information in .env file (email, password, name)
  • Notes: in .env file, remove HEADLESS= if you want to run in UI mode
  • Type: npm run test to run all tests under folder ./tests/specs
  • Type: npx codeceptjs run ./tests/specs/<filename>.spec.js to run a specific script
  • Type: npm run test:smoke to run scenarios marking tag @smoke which is highest-priority scenarios running in Chrome only.
  • Type: npm run test: regression to run scenarions marking tag @regression, this commands issues parallel-execution running in both of Firefox and Chrome
  • To generate report: type npm run report:allure

Allure_error Allure_success

About

Codeceptjs POC for automation web testing

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published