Last active
August 16, 2023 15:41
-
-
Save nadvolod/d67061ecf619ec571c27ef7d4f780c95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//usage | |
const actualQuantity = | |
await locationInventoryPage.getQuantityColumnValueUsing(adjustment.receiptData.lotNumber); | |
const actualQuantity = | |
await locationInventoryPage.getInventoryQuantityUsing(adjustment.receiptData.lotNumber); | |
async getQuantityColumnValue(item: string): Promise<string> { | |
return this.getInventoryQuantityCellFromRowUsingOtherLabelSelector(item).innerText(); | |
} | |
getInventoryQuantityCellFromRowUsingOtherLabelSelector(item: string): Locator { | |
return this.page | |
.frameLocator(this.locationInventoryIframe) | |
.getByRole('row') | |
.filter({ | |
has: this.page.frameLocator(this.locationInventoryIframe).getByLabel(lotNumber), | |
has: this.page.frameLocator(this.locationInventoryIframe).getByLabel(item), | |
}) | |
.locator('div[class="x-grid3-cell-inner x-grid3-col-SCC$Inventory$Quantity"]').getByText(quantity, { exact: true }); | |
.locator('[class="x-grid3-cell-inner x-grid3-col-SCC$Inventory$Quantity"]'); | |
} | |
function sum(a: any, b: any): string { | |
let num1 = typeof a === "string" ? parseFloat(a) : a; | |
let num2 = typeof b === "string" ? parseFloat(b) : b; | |
return toEnglishFormat(num1 + num2) | |
} | |
function toEnglishFormat(sum){ | |
if (sum > 1000) { | |
return sum.toLocaleString('en-US'); | |
} | |
return sum; | |
} | |
//PageA | |
iFrameTitle = 'New Inventory Discrepancy' | |
function getIframeTitle(){ | |
return 'New Inventory Discrepancy'; | |
} | |
//Pageb | |
iFrameTitle = 'Page B' | |
function getIframeTitle(){ | |
return 'Page B'; | |
} | |
//common.page.ts | |
async selectDropdownItem( | |
pageName: string, dropdownItem: string | |
): Promise<void> { | |
await this.page | |
.frameLocator(`iframe[title="${pageName}"]`) | |
.locator(`.x-combo-list-item`) | |
.getByText(item, { exact: true }) | |
.nth(0) | |
.click({ timeout: TIMEOUTS.ten_seconds }); | |
} | |
// usage in a | |
async chooseNewOwnerCode(newOwnerCode: string): Promise<void> { | |
await this.newOwnerCodeInputField.type(newOwnerCode); | |
await this.selectDropdownItem('iFrame Title', newOwnerCode); | |
} | |
async chooseNewOwnerCode(newOwnerCode: string): Promise<void> { | |
await this.newOwnerCodeInputField.type(newOwnerCode); | |
await this.selectDropdownItem('iFrame Title', newOwnerCode); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment