PreRequsite:
- Install Netbox with it running on localhost:8000 Install Instructions here: https://netboxlabs.com/docs/netbox/en/stable/installation/
Once this repo is cloned
Install Playwright
- npm install playwright (if you want to save it to package.json use -D)
- npx playwright install (this installs the browsers like chromium, etc..)
Running the Various Mocha Tests
- Run All Tests: npx playwright test
- Run Headed Mode: npx playwright test --headed
- Run Interactive UI: npx playwright test --ui
- Run Specific Browser: npx playwright test --project=chromium npx playwright test --project=firefox
- Run Debug Mode: npx playwright test --debug
- Run Specific Test: npx playwright test tests/testExample.spec.js
- Set test() method to test.only() to force only that one test to run, then: npx playwright test
- Run an Entire Playwright Config File npx playwright test --config=playwright.config.js Could create and name as many config files as you want for controlled, environments, browsers, and much more.
Intention of Tests
- Create a test that logs into Netbox and validates the dashboard page is loaded
- Create a test that clicks links in the Left Sidebar a. Create a method that Clicks the Parent Link by the name of the Text in the Link b. Create a method that Clicks the Child of an Expanded Parent Link also by the name of the Text
Build out the Framework
- Started with a Mocha Playwright Native TDD Framework
- In the process of Building a Cucumber BDD Framework
Install Cucumber
- npm install @cucumber/cucumber
- Install the VS Code Cucumber (Gherkin) Full Support Plugin - For Feature File
Create Project Structure
- Create "features" folder in project root to hold *.feature file Test Suites a. Each Feature file will contain Scenarios and Parameterized Scenario Outlines b. Scenario and Scenario Outlines will be appropriately Tagged to control test execution
- Create "features/stepdefs" folder to hold step definition javascript code
- Create "features/hooks.js" file to store all hook annotations
Running the Various Cucumber Tests NOTE: cucumber-js lives inside of node_modules/.bin/cucumber-js. This file will blindly search the entire project for any files with a *.feature extension and execute it respectively
- Run all Feature Files + Scenarios + Scenario Outlines: npx cucumber-js
- Return Control to the Terminal after Execution: npx cucumber-js --exit
- Run an Individual Feature File npx cucumber-js features/myFeature.feature --exit
- Control Test Execution for example Smoke and Regression NOTE: Set annotations on top of any Scenario of Scenario Outline within Feature Files npx cucumber-js --tags "@Regression" --exit npx cucumber-js --tags "@Regression or @Smoke" --exit npx cucumber-js --tags "@Regression and @Smoke" --exit
- Execute Tests in Parallel NOTE: The parameter after --parallel 2 is how many threads to execute. 2 in this case. NOTE: Cucumber only supports for Scenarios and Scenario Outlines within Feature Files to run in Parallel. It does not support running Feature Files in Parallel. npx cucumber-js --parallel 2 // This would execute 2 scenarios in parallel. npx cucumber-js --parallel 5 // This would execute 5 scenarios in parallel.
- Write a Test Result Report npx cucumber-js --format html:cucumber-report.html npx cucumber-js --format xml:cucumber-report.xml npx cucumber-js --format json:cucumber-report.json