SAP Login
Overview​
The SAPLogin
utility simplifies authentication by handling the complete login flow (username, password, optional URL navigation) for both SAP Fiori Launchpad and SAP NetWeaver login pages. This utility saves you from having to write repetitive login code and handles the various SAP login page formats automatically.
Signature​
page.SAPLogin(username: string,
password: string,
url?: string): Promise<void>
Parameter | Type | Required | Description |
---|---|---|---|
username | string | ✔ | SAP user ID. |
password | string | ✔ | User password. |
url | string | ✖ | If provided, the browser first navigates to the URL; otherwise it assumes that the login page is already open. |
Compatibility
Currently works with Fiori Launchpad and SAP WebGUI login pages. Other SAP interfaces may not be supported. Click here to report a bug with SAPLogin
Examples​
Basic Login​
// Login with URL navigation
await page.SAPLogin(SAP_USER, SAP_PASS, 'https://sap.example.com');
Login to an Already Open Page​
// Navigate to the login page first
await page.goto('https://sap.example.com');
// Then login (no URL parameter needed)
await page.SAPLogin(SAP_USER, SAP_PASS);
Login with Environment Variables​
// Using environment variables for credentials (recommended for security)
await page.SAPLogin(
process.env.SAP_USERNAME,
process.env.SAP_PASSWORD,
'https://sap.example.com'
);
How It Works​
The SAPLogin
utility performs the following steps:
- If a URL is provided, it navigates to that URL first
- Automatically detects the type of SAP login page (Fiori Launchpad or WebGUI)
- Locates the appropriate username and password fields
- Enters the provided credentials
- Submits the login form
- Handles any additional screens (like client selection if needed)