Skip to main content

Cypress to Playwright Command Mapping (with Boozang Placeholder)

Boozang CommandCypress CommandPlaywright CommandDescription
$script.visit(url)cy.visit(url)await page.goto(url)Navigates to a URL.
$script.go(direction)cy.go(direction)await page.goBack() / await page.goForward()Navigates back or forward in browser history.
$script.reload()cy.reload()await page.reload()Reloads the current page.
$script.viewport(width, height)cy.viewport(width, height)await page.setViewportSize({ width, height })Sets the browser viewport size.

Element Selection

Boozang CommandCypress CommandPlaywright CommandDescription
$script.get(selector)cy.get(selector)await page.$(selector) / page.locator(selector)Gets one or more DOM elements by selector.
$script.contains(text)cy.contains(text)await page.locator('text=' + text)Gets DOM elements containing the specified text.
$script.find(selector)cy.find(selector)await elementHandle.$(selector)Finds descendants of the DOM elements that match the selector.

Interactions

Boozang CommandCypress CommandPlaywright CommandDescription
$script.click(selector)cy.click()await page.click(selector)Clicks on a DOM element.
$script.type(selector, text)cy.type(text)await page.type(selector, text)Types into a DOM element.
$script.clear(selector)cy.clear()await page.fill(selector, '')Clears the value of an input or textarea.
$script.select(value)cy.select(value)await page.selectOption(selector, value)Selects an option in a <select> element.

Assertions

Boozang CommandCypress CommandPlaywright CommandDescription
$script.should(assertion)cy.should(assertion)expect(locator).toHaveProperty('property', value)Asserts that the element satisfies the given condition.
$script.expect(subject)cy.expect(subject)expect(subject).toBe(value)Asserts that the subject satisfies the condition.
$script.and(assertion)cy.and(assertion)expect(locator).toHaveProperty('property', value)Adds additional assertions.

Waiting

Boozang CommandCypress CommandPlaywright CommandDescription
$script.wait(time)cy.wait(time)await page.waitForTimeout(time)Waits for a specified amount of time.
$script.wait(alias)cy.wait(alias)await page.waitForResponse(route)Waits for a route or request alias.

Network Requests

Boozang CommandCypress CommandPlaywright CommandDescription
$script.server()cy.server()await page.route(url, handler)Starts a server to begin routing responses.
$script.route(url)cy.route(url)await page.route(url, handler)Defines a route for a URL to intercept requests.
$script.request(options)cy.request(options)await page.request(url, options)Makes an HTTP request.

Fixtures

Boozang CommandCypress CommandPlaywright CommandDescription
$script.fixture(filePath)cy.fixture(filePath)await page.addInitScript({ path: filePath })Loads a fixed set of data located in a file.

Clock and Timers

Boozang CommandCypress CommandPlaywright CommandDescription
$script.clock()cy.clock()await page.context().newCDPSession(page) and await session.send('Animation.enable')Controls the clock to test time-dependent code.
$script.tick(time)cy.tick(time)await session.send('Animation.setPlaybackRate', { playbackRate: time })Moves time forward by a specified amount.

Aliases

Boozang CommandCypress CommandPlaywright CommandDescription
$script.as(alias)cy.as(alias)const alias = await page.$(selector)Alias a DOM element or a route.
$script.get(alias)cy.get(alias)await alias.click()Gets the element or route by alias.

Custom Commands

Boozang CommandCypress CommandPlaywright CommandDescription
$script.add(name, callback)Cypress.Commands.add(name, callback)Extend Playwright's Page or Browser context by adding custom functions directly to the Playwright API objects.Adds a custom command to Cypress.

Handling Frames and Windows

Boozang CommandCypress CommandPlaywright CommandDescription
$script.frameLoaded()cy.frameLoaded()await page.frameLocator(selector)Checks that a frame has loaded.
$script.iframe()cy.iframe()await page.frameLocator(selector).frame()Gets an iframe by selector.
$script.window()cy.window()const [newPage] = await Promise.all([ page.waitForEvent('popup'), page.click(selector) ]);Accesses the window object.

File Uploads

Boozang CommandCypress CommandPlaywright CommandDescription
$script.attachFile('input[type="file"]', filePath)cy.get('input[type="file"]').attachFile(filePath)await page.setInputFiles('input[type="file"]', filePath)Sets files to upload for an input element.

Screenshots and PDFs

Boozang CommandCypress CommandPlaywright CommandDescription
$script.screenshot()cy.screenshot()await page.screenshot({ path: 'screenshot.png' })Takes a screenshot of the page.
$script.screenshot('filename')cy.screenshot('filename')await page.screenshot({ path: 'filename.png' })Takes a screenshot with a specified filename.
$script.pdf()cy.pdf()await page.pdf({ path: 'document.pdf' })Generates a PDF of the page.