This project automates key WooCommerce scenarios using the rtCamp E2E framework and WordPress E2E Test Utils Playwright package. The tests cover Product Management, Coupon Management, and User Management workflows in a WooCommerce environment.
- Node.js (v16 or later)
- Playwright installed globally
- A local or remote WordPress site with the WooCommerce plugin activated
- Admin credentials for WordPress
Run the following commands to set up the project:
# Initialize the project (if not done already)
npm init -y
# Install Playwright and dependencies
npm install --save-dev @playwright/test
# Install WordPress E2E Test Utils
npm install --save-dev @wordpress/e2e-test-utils-playwright- Install and activate the WooCommerce plugin on your WordPress site.
- Configure WooCommerce with basic settings (e.g., currency, shipping, and payment options).
- Ensure the site has at least one product category created.
- Enable coupons in WooCommerce → Settings → General (if not enabled by default).
Create a .env file in the root directory and add the following:
# Admin Credentials
ADMIN_USERNAME=
ADMIN_PASSWORD=
WP_BASE_URL=
# Customer Credentials
CUSTOMER_USERNAME=
CUSTOMER_EMAIL=
CUSTOMER_PASSWORD=Install dotenv to load environment variables:
npm install dotenvTo execute the tests, run:
npx playwright testFor running tests in headed mode (visible browser):
npx playwright test --headed- Create a WooCommerce product
- Add product categories and tags
- Upload product images
- Set pricing and inventory
- Publish and verify product visibility
- Create percentage-based and fixed amount coupons
- Apply coupons during checkout
- Verify discount calculations
- Create a customer account
- Customer places an order
- Admin/store manager reviews the order
This project utilizes @wordpress/e2e-test-utils-playwright for streamlined automation:
loginUser(page, username, password): Logs in a userlogoutUser(page): Logs out the current usercreateProduct(page, options): Creates a WooCommerce productcreateCoupon(page, options): Adds a WooCommerce couponcreateUser(page, options): Creates a new WordPress userplaceOrder(page, options): Places an order as a customerreviewOrder(page, customerEmail): Admin reviews an order
├── tests/
│ ├── product-management.spec.js
│ ├── coupon-management.spec.js
│ ├── user-management.spec.js
├── .env
├── package.json
├── playwright.config.js
├── README.md
- Extend tests for bulk product uploads
- Automate refunds and order status updates
- Implement multi-user role testing
- Improve test coverage for different WooCommerce settings
📌 Happy Testing! 🚀