✅ Node.js installed
✅ Playwright installed and configured
npm install playforce
See licensing for further information
Configure the required environment variables either directly in your shell or by adding them to a .env
file in your project root (if your setup supports it).
set SALESFORCE_TOKEN_URL=https://login.salesforce.com/services/oauth2/token
set SALESFORCE_CONSUMER_KEY=<your consumer key here>
set SALESFORCE_CONSUMER_SECRET=<your consumer secret here>
set SALESFORCE_API_VERSION=59.0 (optional override. Default will be what Salesforce returns)
set PLAYFORCE_LICENSE=<your emailed playforce license here>
Create a file named global-setup.ts
in your project root and add the following code:
// global-setup.ts - Connects to Salesforce and gets an Access Token
import { FullConfig } from "@playwright/test";
import { getSalesforceToken } from "playforce";
export default async function globalSetup(config: FullConfig) {
await getSalesforceToken();
}
In your playwright.config.ts
, add the following to include the global setup script:
export default defineConfig({
globalSetup: ['./global-setup'],
// ... other settings
});
✅ You are all set!
Run your Playwright tests using a command like:
npx playwright test