ZeroStep's ai() function unlocks the power of GPT3.5
and GPT4 to make Playwright tests simpler and more resilient to change.
npm i @zerostep/playwright -D
So long, selectors
Instead of CSS selectors or XPath locators, ZeroStep's AI assistant determines what actions to take at runtime
based on your plain-text instructions.
Since ZeroStep integrates directly into Playwright, you can incorporate AI into as few or as many tests as you'd
like,
without changing your development workflow.
ZeroStep AI Prompt
ai("Fill out the form with realistic values")
System under test
Write E2E tests that are resilient to change
Script complex interactions and assertions using plain-text instructions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import{test,expect}from'@playwright/test'import{ai}from'@zerostep/playwright'test.describe('Calendly',()=>{test('book the next available timeslot',async({page})=>{awaitpage.goto('https://calendly.com/zerostep-test/test-calendly')awaitai('Verify that a calendar is displayed',{page,test})awaitai('Dismiss the privacy modal',{page,test})awaitai('Click on the first day in the month with times available',{page,test})awaitai('Click on the first available time in the sidebar',{page,test})awaitai('Click the Next button',{page,test})awaitai('Fill out the form with realistic values',{page,test})awaitai('Submit the form',{page,test})constelement=awaitpage.getByText('You are scheduled')expect(element).toBeDefined()})})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import{test,expect}from'@playwright/test'import{ai}from'@zerostep/playwright'test.describe('Google',()=>{constsearchTerm='software testing'test('search and verify the first organic search result',async({page})=>{awaitpage.goto('https://www.google.com')awaitai(`Search for '${searchTerm}'`,{page,test})awaitai('Hit enter',{page,test})awaitpage.waitForURL('https://www.google.com/search**')consttitle=awaitai(`What is the title of the first organic search result?`,{page,test})console.log('First organic search result is: ',title)})})
import{test,expect}from'@playwright/test'import{ai}from'@zerostep/playwright'// Replace these values with your Salesforce credentials
constemail='test@example.com'constpassword='passwordhere'consthostname='realhostnamehere.develop.lightning.force.com'test.describe('Salesforce',()=>{test('create an opportunity',async({page})=>{awaitpage.goto('https://login.salesforce.com')awaitai(`Enter the username ${email}`,{page,test})awaitai(`Enter the password ${password}`,{page,test})awaitpage.click('text="Log In"')// Only reaches here if we are successfully authenticated
awaitpage.waitForSelector('text="Home"')// Navigate directly to Sales app
awaitpage.goto(`https://${hostname}/lightning/page/home`)awaitpage.waitForSelector('text="Quarterly Performance"')awaitai('Click on Opportunities link',{page,test})awaitpage.click('text="New"')// Wait for 'New Opportunity' form to be displayed
awaitpage.waitForSelector('text="New Opportunity"')awaitai(`Enter '12000' in the Amount field.`,{page,test})awaitai('Enter Test in the opportunity name input',{page,test})awaitai(`Input '06/30/24' into the Close Date field`,{page,test})awaitai('Click on the Stage dropdown',{page,test})awaitai('Click on the Needs Analysis option',{page,test})awaitai('Click Save',{page,test})constresult=ai('Assert that the current stage is "Needs Analysis"',{page,test})expect(result).toEqual(true)})})
1
2
3
4
5
6
7
8
9
10
11
12
13
import{test,expect}from'@playwright/test'import{ai}from'@zerostep/playwright'test.describe('Yahoo Finance',()=>{test('get the latest stock price',async({page})=>{awaitpage.goto('https://finance.yahoo.com')constprice=awaitai('Return the current price for the S&P 500. Strip out all commas.',{page,test})constformattedPrice=parseFloat(price)expect(formattedPrice>4000).toEqual(true)})})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import{test,expect}from'@playwright/test'import{ai}from'@zerostep/playwright'test.describe('Wikipedia',()=>{test('view article history and verify earliest revision',async({page})=>{awaitpage.goto('https://en.wikipedia.org/wiki/Software_testing')awaitai(`Click on "View history" link`,{page,test})awaitpage.waitForURL('https://en.wikipedia.org/w/index.php?title=Software_testing&action=history')awaitai('Sort by "oldest"',{page,test})awaitpage.waitForURL('https://en.wikipedia.org/w/index.php?title=Software_testing&action=history&dir=prev')constdate=awaitai('What is the date of the first revision listed on this page?',{page,test})expect(date).toEqual('16 April 2004')})})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import{test,expect}from'@playwright/test'import{ai}from'@zerostep/playwright'test.describe('New York Times',()=>{test('go to section and verify ad is displayed',async({page})=>{awaitpage.goto('https://www.nytimes.com')awaitai(`Hover over the World top nav item`,{page,test})awaitai('Click the "World" section',{page,test})awaitpage.waitForURL('https://www.nytimes.com/section/world')constcta=awaitai('What is the CTA of the ad at the top of the page?',{page,test})console.log('Call to action is: ',cta)})})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import{test,expect}from'@playwright/test'import{ai}from'@zerostep/playwright'test.describe('GitHub',()=>{test('verify the number of labels in a repo',async({page})=>{awaitpage.goto('https://github.com/zerostep-ai/zerostep')awaitai(`Click on the Issues tabs`,{page,test})awaitpage.waitForURL('https://github.com/zerostep-ai/zerostep/issues')awaitai('Click on Labels',{page,test})awaitpage.waitForURL('https://github.com/zerostep-ai/zerostep/labels')constnumLabels=awaitai('How many labels are listed?',{page,test})expect(parseInt(numLabels)).toEqual(9)})})
Why use ZeroStep?
Use the good parts of Playwright while avoiding common E2E testing pitfalls
The Conventional Approach
Selectors are tightly coupled to the application's markup.
Every action must be precisely translated to code, making E2E tests much slower to implement than unit and
integration tests.
Complex scenarios are difficult to automate and constantly break.
E2E tests can only be written after the functionality it's testing is feature-complete.
Testing with ZeroStep
No selectors are used, ever. ZeroStep's AI assistant determines what actions to take at runtime.
Build tests quickly by expressing actions and assertions as plain text instructions.
If you can express what you want tested, you can automate it.
Since tests aren't coupled to implementation details of the application, you can take a TDD-approach to
writing E2E tests.
Pricing
We provide a generous free tier and straight-forward pricing