Playwright_Java_Web_Testing/page-objects/Navigation.js

23 lines
578 B
JavaScript

export class Navigation {
constructor(page){
this.page = page
this.basketCounter = page.locator('[data-qa="header-basket-count"]')
this.checkoutLink = page.getByRole('link', { name: 'Checkout' })
}
getBasketCount = async () => {
await this.basketCounter.waitFor()
const text = await this.basketCounter.innerText()
return parseInt(text, 10)
}
goToCheckout = async () => {
this.checkoutLink.waitFor()
await this.checkoutLink.click()
await this.page.waitForURL("/basket")
}
}