Cypress Vs Playwright 220527005559 F81b9cee PDF
Cypress Vs Playwright 220527005559 F81b9cee PDF
cy.get('#username').type('filip')
cy.get('#password').type('i<3slovakia!')
cy.get('#log-in').click()
await page.locator("id=username").fill("andy");
await page.locator("id=password").fill("panda<3");
await page.locator("id=log-in").click();
await expect(page.locator(".element-header").first())
.toHaveText("Financial Overview");
await expect(table).toBeVisible();
cy.iframe('#the-kitchen-table')
.find('#fruits-vegetables')
.should('be.visible')
cy.get('#searchBar').type('testing')
cy.get('li:visible').should('have.length', 1)
await page.locator("id=searchBar").fill("testing");
await expect(page.locator("li:visible")).toHaveCount(1);
// Dismiss alert
page.on('dialog', dialog => dialog.dismiss());
await page.goto("https://kitchen.applitools.com/ingredients/alert");
await page.locator("id=confirm-button").click();
// Answer prompt
page.on('dialog', dialog => dialog.accept("nachos"));
await page.goto("https://kitchen.applitools.com/ingredients/alert");
await page.locator("id=prompt-button").click();
// Dismiss alert
cy.visit('https://kitchen.applitools.com/ingredients/alert')
const dismiss = () => false
cy.get('#confirm-button').click()
cy.on('window:confirm', dismiss)
// Answer prompt
cy.visit('https://kitchen.applitools.com/ingredients/alert', {
onLoad(win: Window) {
cy.stub(win, 'prompt').returns('Hi mom!');
}
})
cy.get('#prompt-button').click()
cy.get('#button-the-kitchen-table')
.invoke('removeAttr', 'target')
.click()
cy.location('pathname')
.should('eq', '/ingredients/table')
cy.get('#fruits-vegetables:visible')
.should('have.length', 1)
await newPage.waitForLoadState();
expect(newPage.url()).toContain('/ingredients/table');
await expect(newPage.locator("id=fruits-vegetables")).toBeVisible();
load() {
cy.visit('https://demo.applitools.com/')
return this
},
constructor(page: Page) {
this.page = page;
this.usernameInput = page.locator("id=username");
this.passwordInput = page.locator("id=password");
this.loginButton = page.locator("id=log-in")
}
async load() {
await this.page.goto("https://demo.applitools.com/");
}
● TypeScript/JavaScript ● TypeScript/JavaScript
● Python
● Java
● .NET (C#)
Can only test one browser at a time. Can test multiple browsers in parallel.
Command: Command:
npx cypress run --browser chrome npx playwright test –-project chromium
#LetTheCodeSpeak
@filip_hric
@AutomationPanda
@applitools
Cypress | @filip_hric #LetTheCodeSpeak Playwright | @AutomationPanda