-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test Case :: Order Min Max #2367
base: develop
Are you sure you want to change the base?
Changes from all commits
242edc6
9f243d5
9d189ab
439d5d5
0f4eba0
db8f058
328e2fe
78aa53a
f38ba64
09f5490
4b1662c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
|
||
export default class CartPage extends BasePage { | ||
quantityErrorElement() { | ||
return this.page.locator('//td[@class="product-quantity"]/div[@class="required"]'); | ||
} | ||
|
||
woocommerceErrorMessage() { | ||
return this.page.locator('//div[@class="woocommerce-notices-wrapper"]/ul[@class="woocommerce-error"]/li'); | ||
} | ||
|
||
async enterQuantityValue(productTitle: string, quantityValue: string) { | ||
await this.page.locator(`//div[@class="quantity"]/label[contains(text(), "${productTitle}")]/following-sibling::input`).fill(quantityValue); | ||
} | ||
|
||
async clickOnUpdateCartButton() { | ||
await this.page.locator('//button[@name="update_cart"]').click(); | ||
} | ||
|
||
async removeProductByName(productName: string) { | ||
await this.page.locator(`//div[@class="quantity"]/label[contains(text(), "${productName}")]/../../../td[1]/a`).click(); | ||
} | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
|
||
export default class MyAccountAuthPage extends BasePage { | ||
async enterUsername(username: string) { | ||
await this.page.locator('#username').fill(username); | ||
} | ||
|
||
async enterPassword(password: string) { | ||
await this.page.locator('#password').fill(password); | ||
} | ||
|
||
async clickOnLoginButton() { | ||
await this.page.locator('//button[@name="login"]').click(); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of creating a class with already implemented methods. use login methods from the LoginPage class |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
|
||
export default class AllMyOrdersPage extends BasePage { | ||
async clickOnViewButtonByOrderId(orderId: string) { | ||
await this.page.locator(`//td[@class="order-number"]/a[contains(text(), "${orderId}")]/../following-sibling::td[5]/a`).click(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
|
||
export default class CustomerOrderDetailsPage extends BasePage { | ||
trackingStatusByShipmentNumber(shipmentNumber: string) { | ||
return this.page.locator(`//h4[@class="shippments-tracking-title"]/strong[text()="Shipment ${shipmentNumber} "]/../../div[1]/p/strong`); | ||
} | ||
|
||
async markOrderAsReceived(shipmentNumber: string) { | ||
await this.page.locator(`//h4[@class="shippments-tracking-title"]/strong[text()="Shipment ${shipmentNumber} "]/../../div[1]/strong[@class="customer-status"]`).click(); | ||
} | ||
|
||
async clickOnDialogBoxOkButton() { | ||
await this.page.locator('//div[@role="dialog"]/div[6]/button[text()="OK"]').click(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
|
||
export default class StorefrontMainMenu extends BasePage { | ||
async clickOnCartContentLink() { | ||
await this.page.locator('.cart-contents').click(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
|
||
export default class ShopPage extends BasePage { | ||
async clickOnProductWithTitle(productTitle: string) { | ||
await this.page.locator('.woocommerce-loop-product__title').getByText(productTitle).click(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
|
||
export default class SingleProductPage extends BasePage { | ||
errorMessageElement() { | ||
return this.page.locator('//ul[@class="woocommerce-error"]/li'); | ||
} | ||
|
||
async enterQuantityValue(productTitle: string, quantityValue: string) { | ||
await this.page.locator(`//div[@class="quantity"]/label[contains(text(), "${productTitle}")]/following-sibling::input`).fill(quantityValue); | ||
} | ||
|
||
async clickOnAddToCartButton() { | ||
await this.page.locator('.single_add_to_cart_button').click(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
|
||
export default class VendorDashboardSidebarPage extends BasePage { | ||
sidebarMenu(title: string) { | ||
return this.page.locator(`//li[contains(@class, "${title}")]/a`); | ||
} | ||
|
||
async clickOnOrdersTab() { | ||
await this.sidebarMenu('orders').click(); | ||
} | ||
|
||
async clickOnProductsTab() { | ||
await this.sidebarMenu('products').click(); | ||
} | ||
|
||
async clickOnSettingsTab() { | ||
await this.sidebarMenu('settings').click(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
|
||
export default class VendorAllOrdersPage extends BasePage { | ||
orderTitleById(orderId: string) { | ||
return this.page.locator(`//td[@data-title="Order"]/a/strong[text()="Order ${orderId}"]`); | ||
} | ||
|
||
async clickOnOrderById(orderId: string) { | ||
await this.orderTitleById(orderId).click(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
|
||
export default class VendorEditOrderPage extends BasePage { | ||
async clickOnCreateNewShipmentButton() { | ||
await this.page.locator('#create-tracking-status-action').click(); | ||
} | ||
|
||
async clickOnShipmentItemCheckboxByIndex(itemNumber: string) { | ||
await this.page.locator(`//form[@id="add-shipping-tracking-status-form"]/div/table/tbody[@id="order_line_items"]/tr[${itemNumber}]/td[1]/label/input`).click(); | ||
} | ||
|
||
async selectShippingStatus(status: string) { | ||
await this.page.locator('#shipment-status').selectOption(status); | ||
} | ||
|
||
async selectShippingProvider(providerName: string) { | ||
await this.page.locator('#shipping_status_provider').selectOption(providerName); | ||
} | ||
|
||
async enterShippingDate(date: string) { | ||
await this.page.locator('#shipped_status_date').fill(date); | ||
} | ||
|
||
async enterShippingTrackingNumber(trackingNumber: string) { | ||
await this.page.locator('#tracking_status_number').fill(trackingNumber); | ||
} | ||
|
||
async clickOnCreateShipmentButton() { | ||
await this.page.locator('#add-tracking-status-details').click(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
|
||
export default class VendorProductAddEditPage extends BasePage { | ||
async enterSimpleProductMinQty(quantity: string) { | ||
await this.page.locator('#min_quantity').fill(quantity); | ||
} | ||
|
||
async enterSimpleProductMaxQty(quantity: string) { | ||
await this.page.locator('#max_quantity').fill(quantity); | ||
} | ||
|
||
async selectProductStatus(status: 'publish' | 'draft' | 'pending') { | ||
await this.page.locator('#post_status').selectOption(status); | ||
} | ||
|
||
async clickOnSaveProduct() { | ||
await this.page.locator('#publish').click(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
|
||
export default class VendorProductListPage extends BasePage { | ||
productTitle() { | ||
return this.page.locator(`//td[@data-title="Name"]/strong/a`); | ||
} | ||
|
||
async clickOnProductWithTitle(productTitle: string) { | ||
await this.productTitle().getByText(productTitle).click(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
|
||
export default class VendorStoreSettingsPage extends BasePage { | ||
async enterMinimumOrderAmount(amount: string) { | ||
await this.page.locator('#min_amount_to_order').fill(amount); | ||
} | ||
|
||
async enterMaximumOrderAmount(amount: string) { | ||
await this.page.locator('#max_amount_to_order').fill(amount); | ||
} | ||
|
||
async clickOnUpdateSettingsButton() { | ||
await this.page.locator(`//input[@name="dokan_update_store_settings"]`).click(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
|
||
export default class WpAdminSidebar extends BasePage { | ||
sideMenu(title: string) { | ||
return this.page.locator('.wp-menu-name').getByText(title); | ||
} | ||
|
||
async clickOnProductsLink() { | ||
await this.sideMenu('Products').click(); | ||
} | ||
|
||
async clickOnDokanLink() { | ||
await this.sideMenu('Dokan').click(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
|
||
export default class DokanModulesPage extends BasePage { | ||
moduleTitle() { | ||
return this.page.locator(`//div[@class="module-details"]/h3/a`); | ||
} | ||
|
||
async searchFor(searchTerm: string) { | ||
await this.page.locator('//div[@class="search-box"]/input').fill(searchTerm); | ||
} | ||
|
||
async clickOnModuleToggleButton(moduleName: string) { | ||
await this.page.locator(`//div[@class="module-details"]/h3/a[contains(text(), "${moduleName}")]/../../following-sibling::div/div[2]/label`).click(); | ||
} | ||
|
||
async clickOnActiveModulesTab() { | ||
await this.page.locator(`//div[@class="module-filter-left"]/ul/li[2]/a`).click(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,33 @@ | ||||||||||||||||||||||||||||||||||
import { BasePage } from '@pages/basePage'; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
export default class DokanShippingStatusPage extends BasePage { | ||||||||||||||||||||||||||||||||||
async shippingStatusItem(status: string) { | ||||||||||||||||||||||||||||||||||
const list = this.page.locator('//ul[@class="dokan-settings-repeatable-list"]/li').all(); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
let locator; | ||||||||||||||||||||||||||||||||||
for (const item of await list) { | ||||||||||||||||||||||||||||||||||
const text = await item.textContent(); | ||||||||||||||||||||||||||||||||||
if (text?.includes(status)) { | ||||||||||||||||||||||||||||||||||
locator = item; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
return locator; | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This type of method should be in helpers or Basepage class. |
||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
Comment on lines
+4
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM, but consider optimizing the method. The method is correctly implemented and should work as expected. However, it could be optimized by using a more specific XPath selector to find the element with the given status directly, instead of looping through all the elements. Apply this diff to optimize the method: -async shippingStatusItem(status: string) {
- const list = this.page.locator('//ul[@class="dokan-settings-repeatable-list"]/li').all();
-
- let locator;
- for (const item of await list) {
- const text = await item.textContent();
- if (text?.includes(status)) {
- locator = item;
- }
- }
-
- return locator;
-}
+async shippingStatusItem(status: string) {
+ return this.page.locator(`//ul[@class="dokan-settings-repeatable-list"]/li[contains(., "${status}")]`);
+} Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
async clickOnShippingStatusTab() { | ||||||||||||||||||||||||||||||||||
await this.page.locator('//div[@class="nav-title"][text()="Shipping Status"]').click(); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
async clickOnAllowShipmentTrackingCheckbox() { | ||||||||||||||||||||||||||||||||||
await this.page.locator('(//p/../following-sibling::div/label/label)[1]').click(); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
async clickOnAllowMarkAsReceivedCheckbox() { | ||||||||||||||||||||||||||||||||||
await this.page.locator('(//p/../following-sibling::div/label/label)[2]').click(); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
async clickOnSaveChangesButton() { | ||||||||||||||||||||||||||||||||||
await this.page.locator('#submit').click(); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
|
||
export default class AllProductsPage extends BasePage { | ||
async clickOnProductTitleById(productId: string) { | ||
await this.page.locator(`//tr[@id="post-${productId}"]/td[2]/strong/a`).click(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
|
||
export default class EditProductPage extends BasePage { | ||
async clickOnPublishButton() { | ||
await this.page.locator('#publish').click(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Locators are already defined in pages/selectors. Add new locators there if they are not already included. Using multiple files solely for locators can unnecessarily complicate the project.