|
| 1 | +package anhtester.com.pom.pages; |
| 2 | + |
| 3 | +import com.microsoft.playwright.Page; |
| 4 | +import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat; |
| 5 | + |
| 6 | +public class CategoryPage extends CommonPage { |
| 7 | + |
| 8 | + private String buttonAddNewCategory = "//span[normalize-space()='Add New category']"; |
| 9 | + private String inputCategoryName = "//input[@id='name']"; |
| 10 | + private String dropdownParentCategory = "//label[normalize-space()='Parent Category']/following-sibling::div//button"; |
| 11 | + private String inputParentCategory = "//div[@class='dropdown-menu show']//input[@aria-label='Search']"; |
| 12 | + private String inputOrderNUmber = "//input[@id='order_level']"; |
| 13 | + private String inputMetaTitle = "//input[@placeholder='Meta Title']"; |
| 14 | + private String inputMetaDescription = "//textarea[@name='meta_description']"; |
| 15 | + private String buttonSave = "//button[normalize-space()='Save']"; |
| 16 | + private String inputSearchCategory = "//input[@id='search']"; |
| 17 | + private String itemCategoryNameFirst = "//tbody/tr[1]/td[2]"; |
| 18 | + |
| 19 | + Page page; |
| 20 | + |
| 21 | + public CategoryPage(Page _page) { |
| 22 | + super(_page); |
| 23 | + page = _page; |
| 24 | + } |
| 25 | + |
| 26 | + public void addNewCategory(String categoryName) { |
| 27 | + page.click(buttonAddNewCategory); |
| 28 | + page.fill(inputCategoryName, categoryName); |
| 29 | + page.click(dropdownParentCategory); |
| 30 | + page.waitForTimeout(1000); |
| 31 | + page.fill(inputParentCategory, "Gaming pc"); |
| 32 | + page.waitForTimeout(1000); |
| 33 | + page.press(inputParentCategory, "Enter"); |
| 34 | + page.fill(inputOrderNUmber, "1"); |
| 35 | + page.fill(inputMetaTitle, categoryName); |
| 36 | + page.fill(inputMetaDescription, categoryName); |
| 37 | + page.click(buttonSave); |
| 38 | + } |
| 39 | + |
| 40 | + public void checkCategory(String categoryName){ |
| 41 | + page.waitForLoadState(); |
| 42 | + page.fill(inputSearchCategory, categoryName); |
| 43 | + page.press(inputSearchCategory, "Enter"); |
| 44 | + page.waitForTimeout(1000); |
| 45 | + assertThat(page.locator(itemCategoryNameFirst)).isVisible(); |
| 46 | + assertThat(page.locator(itemCategoryNameFirst)).hasText(categoryName); |
| 47 | + } |
| 48 | +} |
0 commit comments