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
- 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:[email protected]'
, 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.
- Login with invalid account
- [:mag:Analysis] no email, no password, invalid credential.
- 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.
- Search a book with keyword "apple" and sort Publication date
-
The configuration of framework is placed in
./configs
folder, to learn more details, visit: configurationcodecept_shared.js
common configuration.puppeteer.conf.js
puppeteer configurationwebdriver.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
- Environments
- Install Nodejs https://nodejs.org/en/
- Install an editor supported Nodejs (suggestion: Vscode)
- Upgrade your Chrome browser (as the main one) to latest.
- Accounts
- Register an account to Amazon web.
-
Deployment the source code.
- Run command line
npm i
at the root of the folder
- Run command line
-
Precondition to run test cases.
- Input account information in
.env
file (email, password, name)
- Input account information in
- Notes: in
.env
file, removeHEADLESS=
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