27 lines
819 B
JavaScript
27 lines
819 B
JavaScript
import { expect } from "@playwright/test"
|
|
|
|
export class ProductsPage {
|
|
|
|
constructor(page) {
|
|
this.page = page
|
|
this.addButtons = page.locator('[data-qa="product-button"]')
|
|
}
|
|
|
|
visit = async () => {
|
|
await this.page.goto("/")
|
|
//console.log("Buttons --- " + await this.page.locator('[data-qa="product-button"]').count())
|
|
}
|
|
|
|
addProductToBasket = async (productIndex) => {
|
|
//data-qa="product-button"
|
|
console.log("--- addProductToBasket("+ productIndex +")")
|
|
|
|
const specificAddButton = this.addButtons.nth(productIndex)
|
|
await specificAddButton.waitFor()
|
|
await expect(specificAddButton).toHaveText("Add To Basket")
|
|
await specificAddButton.click()
|
|
await expect(specificAddButton).toHaveText("Remove from Basket")
|
|
|
|
}
|
|
|
|
} |