Untitled
unknown
javascript
a year ago
1.1 kB
2
Indexable
Never
import { expect } from "@playwright/test"; import { ProductsListPage } from "../pages/products-list-page"; export class ProductsWebPage { constructor(page) { this.page = page; } async navAndLogin() { await this.page.goto("https://www.saucedemo.com/"); await this.page.locator('[data-test="username"]').fill("standard_user"); await this.page.locator('[data-test="password"]').fill("secret_sauce"); await this.page.locator('[data-test="login-button"]').click(); await expect(this.page.locator("span.title")).toHaveText("Products"); } async selectFromDropDown(dropImput) { await this.page.locator('[data-test="product_sort_container"]').selectOption(dropImput); } async checkDropdownStatus(statusImput, dropImput) { let productsListPage = new ProductsListPage(this.page); if (dropImput == "az" || dropImput == "za") { await expect(await productsListPage.isListSortedByName(statusImput)).toBe(true); } else if (dropImput == "hilo" || dropImput == "lohi") { await expect(await productsListPage.isListSortedByPrice(statusImput)).toBe(true); } } }