Sure, you can pass unique identifiers like vuser ids to your Playwright tests using Artillery. Here's how:
You can set environment variables through the command line. For instance, to set a "VUSER_ID" variable with a value of "12345", run this command:
VUSER_ID=12345 npx playwright test
In your Playwright test, you can access this value using process.env.VUSER_ID
.
You can also set environment variables through configuration files. In your playwright.config.ts
file, define an object called "use" that contains your environment variables as key-value pairs:
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
VUSER_ID: '12345',
},
});
Again, you can access this value in your Playwright test using process.env.VUSER_ID
.
If you need to pass multiple unique identifiers or other data points for each vuser, consider creating a CSV file with all the necessary data. You can then read from this file within your Playwright test. Since the Playwright test-runner runs in Node.js, you can directly read files from the file system and parse them with your preferred CSV library.
Remember, the key is flexibility. You can easily change these values without modifying the code itself. Happy testing with @playwright/test!
If you still have questions, please ask a question and I will try to answer it.
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].