|
1 | | -import { test, expect, Locator, Page } from "@playwright/test"; |
| 1 | +import { Locator, Page } from "@playwright/test"; |
2 | 2 | export class InventoryPage { |
3 | 3 | page: Page; |
4 | | - userMenu: Locator; |
5 | | - crossUserMenuIcon: Locator; |
6 | | - logoutLink: Locator; |
7 | 4 | addToCartFirstButtonItem: Locator; |
8 | | - shoppingContainerIcon:Locator; |
| 5 | + removeButtonFirstItem: Locator; |
| 6 | + |
| 7 | + addToCartButton2ndItem: Locator; |
| 8 | + removeButton2ndItem: Locator; |
| 9 | + |
| 10 | + addToCartButton3rdItem: Locator; |
| 11 | + removeButton3rdItem: Locator; |
| 12 | + |
| 13 | + addToCartButton4thItem: Locator; |
| 14 | + removeButton4thItem: Locator; |
| 15 | + |
| 16 | + addToCartButton5thItem: Locator; |
| 17 | + removeButton5thItem: Locator; |
| 18 | + |
| 19 | + addToCartButton6thItem: Locator; |
| 20 | + removeButton6thItem: Locator; |
| 21 | + |
| 22 | + shoppingContainerIcon: Locator; |
| 23 | + shoppingCartBagde: Locator; |
9 | 24 |
|
10 | 25 | constructor(page: Page) { |
11 | 26 | this.page = page; |
12 | | - this.userMenu = page.locator("#react-burger-menu-btn"); |
13 | | - this.crossUserMenuIcon = page.locator("#react-burger-cross-btn"); |
14 | | - this.logoutLink = page.locator("#logout_sidebar_link"); |
15 | | - this.addToCartFirstButtonItem = page.locator("#add-to-cart-sauce-labs-backpack") |
| 27 | + this.addToCartFirstButtonItem = page.locator("#add-to-cart-sauce-labs-backpack"); |
| 28 | + this.removeButtonFirstItem = page.locator("#remove-sauce-labs-backpack"); |
| 29 | + |
| 30 | + this.addToCartButton2ndItem = page.locator("#add-to-cart-sauce-labs-bike-light"); |
| 31 | + this.removeButton2ndItem = page.locator("#remove-sauce-labs-bike-light"); |
| 32 | + |
| 33 | + this.addToCartButton3rdItem = page.locator("#add-to-cart-sauce-labs-bolt-t-shirt"); |
| 34 | + this.removeButton3rdItem = page.locator("#remove-sauce-labs-bolt-t-shirt"); |
| 35 | + |
| 36 | + this.addToCartButton4thItem = page.locator("#add-to-cart-sauce-labs-fleece-jacket"); |
| 37 | + this.removeButton4thItem = page.locator("#remove-sauce-labs-fleece-jacket"); |
| 38 | + |
| 39 | + this.addToCartButton5thItem = page.locator("#add-to-cart-sauce-labs-onesie"); |
| 40 | + this.removeButton5thItem = page.locator("#remove-sauce-labs-onesie"); |
| 41 | + |
| 42 | + this.addToCartButton6thItem = page.locator('[id*="add-to-cart-test.allthethings()-t-shirt-(red)"]'); |
| 43 | + this.removeButton6thItem = page.locator('[id*="remove-test.allthethings()-t-shirt-(red)"]'); |
| 44 | + |
16 | 45 | this.shoppingContainerIcon = page.locator("#shopping_cart_container"); |
| 46 | + this.shoppingCartBagde = page.locator('a span[class="shopping_cart_badge"]'); |
17 | 47 | } |
18 | 48 |
|
19 | | - async UserMenuIcon() { |
20 | | - await this.userMenu.click(); |
| 49 | + async addToCartFirstItem() { |
| 50 | + await this.addToCartFirstButtonItem.click(); |
21 | 51 | } |
22 | | - async closeMenuIcon() { |
23 | | - await this.crossUserMenuIcon.click(); |
| 52 | + async addToCart2ndItem() { |
| 53 | + await this.addToCartButton2ndItem.click(); |
24 | 54 | } |
25 | | - async addToCartFirstItem(){ |
26 | | - await this.addToCartFirstButtonItem.click(); |
| 55 | + async addToCart3rdItem() { |
| 56 | + await this.addToCartButton3rdItem.click(); |
27 | 57 | } |
28 | | - async ShopContainerIcon(){ |
29 | | - await this.shoppingContainerIcon.click(); |
| 58 | + async addToCart4thItem() { |
| 59 | + await this.addToCartButton4thItem.click(); |
| 60 | + } |
| 61 | + async addToCart5thItem() { |
| 62 | + await this.addToCartButton5thItem.click(); |
| 63 | + } |
| 64 | + async addToCart6thItem() { |
| 65 | + await this.addToCartButton6thItem.click(); |
| 66 | + } |
| 67 | + async removeFirstItem() { |
| 68 | + await this.removeButtonFirstItem.click(); |
30 | 69 | } |
31 | | - async Logout() { |
32 | | - await this.logoutLink.click(); |
| 70 | + async remove2ndItem() { |
| 71 | + await this.removeButton2ndItem.click(); |
| 72 | + } |
| 73 | + async remove3rdItem() { |
| 74 | + await this.removeButton3rdItem.click(); |
| 75 | + } |
| 76 | + async remove4thItem() { |
| 77 | + await this.removeButton4thItem.click(); |
| 78 | + } |
| 79 | + async remove5thItem() { |
| 80 | + await this.removeButton5thItem.click(); |
| 81 | + } |
| 82 | + async remove6thItem() { |
| 83 | + await this.removeButton6thItem.click(); |
| 84 | + } |
| 85 | + async ShopContainerIcon() { |
| 86 | + await this.shoppingContainerIcon.click(); |
33 | 87 | } |
34 | | - |
35 | 88 | } |
36 | 89 |
|
37 | 90 | module.exports = { InventoryPage }; |
0 commit comments