1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  | 
import { test, expect } from '@playwright/test'
import { ai } from '@zerostep/playwright'
// Replace these values with your Salesforce credentials
const email = 'test@example.com'
const password = 'passwordhere'
const hostname = 'realhostnamehere.develop.lightning.force.com'
test.describe('Salesforce', () => {
  test('create an opportunity', async ({ page }) => {
    await page.goto('https://login.salesforce.com')
    await ai(`Enter the username ${email}`, { page, test })
    await ai(`Enter the password ${password}`, { page, test })
    await page.click('text="Log In"')
    // Only reaches here if we are successfully authenticated
    await page.waitForSelector('text="Home"')
    // Navigate directly to Sales app
    await page.goto(`https://${hostname}/lightning/page/home`)
    await page.waitForSelector('text="Quarterly Performance"')
    await ai('Click on Opportunities link', { page, test })
    await page.click('text="New"')
    // Wait for 'New Opportunity' form to be displayed
    await page.waitForSelector('text="New Opportunity"')
    await ai(`Enter '12000' in the Amount field.`, { page, test })
    await ai('Enter Test in the opportunity name input', { page, test })
    await ai(`Input '06/30/24' into the Close Date field`, { page, test })
    await ai('Click on the Stage dropdown', { page, test })
    await ai('Click on the Needs Analysis option', { page, test })
    await ai('Click Save', { page, test })
    const result = ai('Assert that the current stage is "Needs Analysis"', { page, test })
    expect(result).toEqual(true)
  })
})
  |