Business Applications
Salesforce
Automate Salesforce CRM workflows with Playwright when APIs aren’t available.
Was this page helpful?
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Automate Salesforce CRM workflows with Playwright when APIs aren’t available.
npm install playwright
// Use environment variables for security
const SALESFORCE_USERNAME = process.env.SALESFORCE_USERNAME;
const SALESFORCE_PASSWORD = process.env.SALESFORCE_PASSWORD;
import { chromium } from 'playwright';
// OAuth2 flow for secure authentication
const page = await browser.newPage();
await page.goto('https://login.salesforce.com/services/oauth2/authorize?...');
// Handle OAuth callback and token exchange
const accessToken = await handleOAuthCallback(page);
import { chromium } from 'playwright';
const browser = await chromium.launch();
const page = await browser.newPage();
// Login to Salesforce
await page.goto('https://login.salesforce.com/');
await page.fill('#username', process.env.SALESFORCE_USERNAME);
await page.fill('#password', process.env.SALESFORCE_PASSWORD);
await page.click('#Login');
// Navigate to Leads
await page.click('[title="App Launcher"]');
await page.fill('input[placeholder="Search apps and items..."]', 'Leads');
await page.click('text=Leads');
// Create new lead
await page.click('text=New');
await page.fill('[name="firstName"]', 'John');
await page.fill('[name="lastName"]', 'Doe');
await page.fill('[name="Company"]', 'Acme Corporation');
await page.fill('[name="Email"]', 'john.doe@acme.com');
await page.selectOption('[name="LeadSource"]', 'Website');
await page.click('button[name="SaveEdit"]');
await browser.close();
Was this page helpful?
