Since Playwright Version 1.46 it is possible to provide a certificate to login.
It would make sense to integrate this into the login middleware.
In a minimal sample i was able to login with my SAP Passport X.509 Certificate in pfx format:
playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
headless: false, // Set to true if you want headless mode
viewport: { width: 1280, height: 720 },
ignoreHTTPSErrors: false,
clientCertificates: [
{
origin: 'https://accounts.sap.com',
pfxPath: 'sap.pfx',
passphrase: 'XXX', // Password for the .pfx file
}
]
},
});
sap-login.spec.ts
import { test, expect } from '@playwright/test';
test('Login to SAP BTP Cockpit with client certificate', async ({ page }) => {
// Go to the SAP BTP Cockpit URL
await page.goto('https://emea.cockpit.btp.cloud.sap/cockpit#/');
// Wait for the login page to load (adjust the selector based on the actual login form structure)
await expect(page).toHaveURL('https://emea.cockpit.btp.cloud.sap/cockpit#/');
// You can add further checks to ensure successful login based on page content, URL change, etc.
// add 10 seconds wait
await page.waitForTimeout(10000);
// Take a screenshot of the page
await page.screenshot({ path: 'screenshot.png' });
});
Since Playwright Version
1.46
it is possible to provide a certificate to login.It would make sense to integrate this into the login middleware.
In a minimal sample i was able to login with my SAP Passport X.509 Certificate in pfx format:
playwright.config.ts
sap-login.spec.ts
package.json