Installation
Fast setup for Playwright-SAP.
Using npm, yarn or pnpm​
You can install Playwright-SAP using your preferred JavaScript package manager. The installation process will either initialize a new project or add Playwright-SAP to your existing project.
- npm
- yarn
- pnpm
npm init playwright-sap@latest
yarn create playwright-sap
pnpm create playwright-sap
Installation Options​
During installation, you'll be prompted to configure your project with the following options:
Prompt | What It Does | Default |
---|---|---|
Language | TS or JS project | TypeScript |
Tests folder | Where tests go | tests (or e2e fallback) |
GitHub Actions | Adds CI workflow | Yes |
Install browsers | Downloads Playwright browsers | Yes |
Understanding Package Aliasing​
Playwright-SAP uses a technique called package aliasing to seamlessly integrate with the standard Playwright API. This means:
- You'll import from
@playwright/test
in your code (the standard Playwright import) - Behind the scenes, npm redirects this to the Playwright-SAP package
- This allows Playwright-SAP to extend Playwright without changing your imports
Your package.json
will contain an entry like this:
"devDependencies": {
"@playwright/test": "npm:@playwright-sap/test@^1.1.4",
"@types/node": "^24.2.0"
}
The npm:@playwright-sap/test@^1.0.2
syntax tells npm to use the @playwright-sap/test
package whenever code imports from @playwright/test
.
Read more about package aliasing​
Add to an Existing Playwright Project​
Already have a Playwright test suite? You can drop Playwright-SAP in without rewriting any tests. Your existing imports like:
import { test, expect } from '@playwright/test';
continue to work exactly the same because we use npm package aliasing to substitute the underlying implementation. All core Playwright APIs keep their behavior; Playwright-SAP only augments them with SAP-aware locators/utilities.
1. Manually Edit package.json
​
Open your package.json
and in devDependencies
(or dependencies
if you put them there) replace any of these if present:
@playwright/test
playwright
playwright-core
with alias lines pointing to Playwright-SAP, e.g.:
"dependencies": {
"@playwright/test": "npm:@playwright-sap/test@^1.1.4",
"playwright": "npm:@playwright-sap/test@^1.1.4",
"playwright-core": "npm:@playwright-sap/test@^1.1.4"
// other deps...
}
(If you only had one or two of them, just change only those.)
2. Remove Lock File & Reinstall​
Delete the lock file so the alias is resolved cleanly, then install:
rm -f package-lock.json yarn.lock pnpm-lock.yaml
npm install
(Use yarn install
or pnpm install
if you prefer those.)
Now every import like import { test } from '@playwright/test'
transparently uses Playwright-SAP—no code changes needed.
2. (Optional) Verify​
Run your current test suite—everything should pass as before:
npx playwright test
Getting Help​
If you encounter issues during installation:
- Check the FAQs for common problems and solutions
- Open an issue on GitHub
Next Steps​
After installation, you're ready to:
- Configure automatic SAP login for your tests
- Learn about specialized SAP locators
- Create your first test script