See for yourself how we automate complexity
Complex commands
Making the data a bit tricky to understand, so only those with the right key can
On the top menu, hover over Mens, then Tops, and click on Jackets
We should see a page with "Jackets" heading
On the left sidebar, select SIZE, then click on M
On the left sidebar select Price Range then click on of of the options that has > 3 items
Go through each result. The M size should be highlighed for every result
Press 'ctrl+k' to open search drawer
Enter the term "TestCase" in the search bar and hit entrxd.
Confirm that search results are displayed.
For each result with a description, ensure it fits within two lines and ends with "..." if it exceeds more than two lines.
Click on "Apps" category and click on "Last 7 Days" date option
Go through each result and ensure that each result’s date is within last 7 days
Go to this url https://abcd.com//ABC-form
User should able to see the "ABC Activity Form".
Enter "242525" in ID
Enter "test@test.com" in Business Email
Enter "Test Customer Name" in Customer Name.
Enter "Test Customer Account Number" in Customer Account Number.
Enter "Test Brief Description" in Brief Description.
//Enter "8888888888" in Phone Number.
Enter "aaaaa" in Phone Number.
Verify that the Phone Number field is still empty.
//Click on Submit button - Submit button should not be enabled b/c chars were entered in phone field
Verify that Submit button is not enabled
test('Verify size selection', async ({ page }) => { try { //On the top menu, hover over Mens, then Tops, and click on Jackets await Page_.menuHoverAndClick(page); //We should see a page with "Jackets" heading await Page_men_topsmen_jacketsmenhtml.VerifyPageHeading(page, 'Jackets'); //On the left sidebar, select SIZE, then click on M await Page_men_topsmen_jacketsmenhtml.CheckboxSelect(page, 'M'); //On the left sidebar select Price Range then click on of of the options that has > 3 items await.Page_men_topsmen_jacketsmenhtml.SelectPriceRange(IWebDriver driver, 3) //Go through each result. The M size should be highlighed for every result await Page_men_topsmen_jacketsmenhtml.fieldSizeHighlightedResults(page, 'M'); } catch (error) { console.log('An error occurred during the test execution:', error); throw error; } class Page_ { static async MenuHoverAndClick(page) { // Locate the 'Men' menu item console.log("Locate the 'Men' menu item"); const mensMenu = await page.locator("xpath=//a[@id='ui-id-5']/span[text()='Men']"); // Hover over the 'Men' menu item console.log("Hover over the 'Men' menu item"); await mensMenu.hover(); // Locate the 'Tops' submenu item console.log("Locate the 'Tops' submenu item"); const topsSubMenu = await page.locator("xpath=//a[@id='ui-id-17']/span[text()='Tops']"); // Hover over the 'Tops' submenu item console.log("Hover over the 'Tops' submenu item"); await topsSubMenu.hover(); // Locate the 'Jackets' item and click it console.log("Locate the 'Jackets' item and click it"); const jacketsItem = await page.locator("xpath=//a[@id='ui-id-19']/span[text()='Jackets']"); await jacketsItem.click(); // CLICK ACTION await page.waitForTimeout(1000); await page.waitForLoadState('networkidle', { timeout: 60000 }); } } public static void SelectPriceRange(IWebDriver driver, int minItems) { // Locate the Price filter section string priceFilterXPath = "//div[@class='filter-options-title' and text()='Price']/following-sibling::div//ol[@class='items']/li/a"; // Find all price range elements var priceElements = driver.FindElements(By.XPath(priceFilterXPath)); // Iterate over each price element foreach(var priceElement in priceElements) { // Get the count of items for each price range string itemCountText = priceElement.FindElement(By.XPath(".//span[@class='count']")).Text; int itemCount = int.Parse(itemCountText.Split(' ')[0]); // Check if the item count is greater than the specified minimum if (itemCount > minItems) { // Click on the price range element priceElement.Click(); // CLICK ACTION break; } } } class Page_men_topsmen_jacketsmenhtml { static async CheckboxSelect(page, filterOption) { // Find the SIZE filter on the left sidebar console.log('Find the SIZE filter on the left sidebar'); const sizeFilterElement = await page.locator("//div[@class='filter-options-title' and text()='Size']"); await sizeFilterElement.click(); // CLICK ACTION await page.waitForTimeout(1000); await page.waitForLoadState('networkidle', { timeout: 60000 }); // Wait for the element console.log('Wait for the element'); await page.waitForSelector("//div[@class='filter-options-content']//div[@class='swatch-option text ' and text()='" + filterOption + "']", { state: 'visible', timeout: 20000 }); // Select the M size checkbox console.log('Select the M size checkbox'); const mSizeElement = await page.locator("//div[@class='filter-options-content']//div[@class='swatch-option text ' and text()='" + filterOption + "']"); await mSizeElement.click(); // CLICK ACTION await page.waitForTimeout(1000); await page.waitForLoadState('networkidle', { timeout: 60000 }); } static async FieldSizeHighlightedResults(page, size) { // Define the XPath for the highlighted size option in each product result console.log('Define the XPath for the highlighted size option in each product result'); const xpath = `//div[contains(@class, 'swatch-attribute size')]//div[@aria-label='${size}' and contains(@class, 'selected')]`; // Check if the size is highlighted for every result console.log('Check if the size is highlighted for every result'); const elements = await page.$$(xpath); // ASSERT console.log('ASSERT'); if (elements.length === 0) { throw new Error(`Size ${size} is not highlighted in any results.`); } for (const element of elements) { const className = await element.getAttribute('class'); if (!className.includes('selected')) { throw new Error(`Size ${size} is not highlighted.`); } } } });
// Playwright version: 1.38.0 const { test, expect } = require('@playwright/test'); test('Advance search test', async ({ page }) => { try { // Press 'ctrl+k' to open search drawer console.log("Press 'ctrl+k' to open search drawer"); await page.keyboard.press('Control+k'); await page.waitForTimeout(1000); // No network load to wait for here, but adding for consistency // Enter the term "TestCase" in the search bar and hit enter. console.log('Enter the term "TestCase" in the search bar and hit enter.'); await page.type("//input[@id='search']", "TestCase"); await page.keyboard.press('Enter'); await page.waitForTimeout(1000); await page.waitForLoadState('networkidle', { timeout: 60000 }); // Confirm that search results are displayed. console.log('Confirm that search results are displayed.'); await page.waitForSelector("//div[@class='one-search']//div[@class='header']/span[text()='Search Results']", { state: 'visible' }); // For each result with a description, ensure it fits within two lines and ends with "..." if it exceeds more than two lines. console.log('For every result that has a description, verify that it is within one or two lines and truncated with ellipsis "..." if it exceeds more than two lines.'); const descriptions = await page.$$eval(".search-section .skeleton .loader-card p-skeleton:nth-child(2) > div", elements => { return elements.map(element => element.textContent.trim()); }); await page.waitForTimeout(1000); // Ensure the page is rendered completely before validation. for (const descText of descriptions) { const lineCount = descText.split('\n').length; expect(lineCount <= 2, 'Description exceeds 2 lines').toBeTruthy(); if (lineCount === 2) { expect(descText.endsWith('...'), 'Description is not truncated with ellipsis').toBeTruthy(); } } //Click on "Apps" category and click on "Last 7 Days" date option // Locate the checkbox for the specified category console.log('Locate the checkbox for the specified category'); const categoryXpath = `//h3[text()='Category']/following-sibling::div//p-checkbox//label[contains(text(), 'Apps')]`; const categoryElement = await page.locator(categoryXpath); await categoryElement.click(); // CLICK ACTION // Locate the radio button for the specified date console.log('Locate the radio button for the specified date'); const dateXpath = `//h3[text()='Date']/following-sibling::div//p-radiobutton//label[text() = 'Last 7 Days']//preceding-sibling::div`; const dateElement = await page.locator(dateXpath); await dateElement.click(); // CLICK ACTION // Go through each result and ensure that each result’s date is within last 7 days await page.waitForTimeout(1000); const date7DaysResults = await page.$$("//div[contains(@class, 'results')]//div[contains(@class, 'foot')]//span[@class='date']"); const today = new Date(); for (const dateElement of date7DaysResults) { const dateText = await dateElement.textContent(); const parsedDate = new Date(dateText.trim()); expect(parsedDate >= new Date(today.getTime() - 7 * 24 * 60 * 60 * 1000) && parsedDate <= today).toBeTruthy(); } } } catch (error) { console.log('Error encountered:', error); throw error;);
test('Test exception case', async ({ page }) => { try { //Go to this url abcd.com/ABC-form await Page_home.navigateToABCFormPage(page, 'abcd.com/ABC-form'); //User should able to see the "ABC Activity Form". await Page_ABC.verifyABCActivityFormVisibility(page) //Enter "242525" in ID await Page_ABC.fieldEnterRepId(page, '242525'); //Enter "test@test.com" in Business Email. await Page_ABC.fieldEnterBusinessEmail(page, 'test@test.com'); //Enter "Test Customer Name" in Customer Name. await Page_ABC.fieldEnterCustomerName(page, 'Test Customer Name'); //Enter "Test Customer Account Number" in Customer Account Number. await Page_Page_ABC.fieldCustomerAccountNumber(page, 'Test Customer Account Number'); //Enter "Test Brief Description" in Brief Description (include who, what, when, and why). \ await Page_ABC.fieldBriefDescription(page, 'Test Brief Description'); //Enter "aaaaa" in Phone Number. await Page_ABC.fieldPhoneNumberEnter(page, 'aaaaa'); //Verify that the Phone Number field is still empty. await Page_ABC.FieldIsEmptyPhoneNumber(page) //Verify that Submit button is not enabled await Page_ABC.buttonVerifySubmitNotEnabled(page } catch (error) { console.log('An error occurred during the test execution:', error); throw error; } class Page_home { static async navigateToABCFormPage(page, url) { // Navigate to the specified URL await page.goto(url, { waitUntil: 'load' }); // CLICK ACTION } class Page_ABC { static async buttonVerifySubmitNotEnabled(page) { // Locate the Submit button using XPath const submitButton = await page.locator("//button[contains(@class, 'p-button') and span[text()='Submit']]").elementHandle(); // Verify that the Submit button is not enabled const isEnabled = await submitButton.isEnabled(); // Assert that the button is not enabled if (isEnabled) { throw new Error('Submit button is unexpectedly enabled.'); } // ASSERT } static async fieldBriefDescription(page, descriptionText) { // Find the Brief Description field using its XPath const briefDescriptionField = await page.locator('//label[contains(text(), "Brief Description (include who, what, when, and why)")]//parent::web-label//following-sibling::textarea'); // Enter the provided description text into the Brief Description field await briefDescriptionField.fill(''); await briefDescriptionField.type(descriptionText); } static async fieldCustomerAccountNumber(page, accountNumber) { // Locate the Customer Account Number input field using XPath const CustomerAccountNumberField = await page.locator('//label[contains(text(), "*Customer Account Number")]/parent::web-label/following-sibling::web-input-text//input'); // Enter the provided account number into the Customer Account Number field await CustomerAccountNumberField.fill(accountNumber); } static async fieldEnterBusinessEmail(page, email) { // Locate the Business Email field const emailField = await page.locator('//label[contains(text(), "*Business Email")]/parent::web-label/following-sibling::web-input-text//input'); // Enter the email into the Business Email field await emailField.fill(email); // ENTER ACTION } static async fieldEnterCustomerName(page, CustomerName) { // Locate the Customer Name input field const CustomerNameField = await page.locator('//label[contains(text(), "*Customer Name")]//parent::web-label//following-sibling::web-input-text//input'); // Enter the provided Customer name await CustomerNameField.fill(''); await CustomerNameField.type(CustomerName); } static async fieldEnterRepId(page, repId) { // Find the input field for Rep ID const repIdInput = await page.locator('//label[contains(text(), "*Rep ID")]/parent::web-label/following-sibling::web-input-text//input'); // Enter the Rep ID into the input field await repIdInput.fill(repId); } static async fieldPhoneNumberEnter(page, phoneNumber) { // Locate the Phone Number input field const phoneNumberField = await page.locator('//label[contains(text(), "*Phone Number")]//parent::web-label//following-sibling::web-input-mask//input'); // Enter the phone number await phoneNumberField.fill(''); await phoneNumberField.type(phoneNumber); } //Verify that the Phone Number field is still empty. static async FieldIsEmptyPhoneNumber(page) { // Locate the Phone Number field input element const phoneNumberField = await page.locator("//label[contains(text(), '*Phone Number')]/following-sibling::web-input-mask//input[@title='phoneNumber']"); // Assert that the Phone Number field is empty const fieldValue = await phoneNumberField.inputValue(); if (fieldValue) { throw new Error('Phone Number field is not empty.'); } } static async verifyABC Activity FormVisibility(page) { // XPath to verify the visibility of the 'ABC Activity Form' const xpath = "//div[@class='headerText line-clip' and text()='ABC Activity Form']"; // Wait for the element await page.waitForSelector(xpath, { state: 'visible', timeout: 20000 }); // ASSERT const isVisible = await page.isVisible(xpath); if (!isVisible) { throw new Error("The 'ABC Activity Form' is not visible."); } } } } });
See for yourself how we automate complexity
Complex commands
Making the data a bit tricky to understand, so only those with the right key can
On the top menu, hover over Mens, then Tops, and click on Jackets
We should see a page with "Jackets" heading
On the left sidebar, select SIZE, then click on M
On the left sidebar select Price Range then click on of of the options that has > 3 items
Go through each result. The M size should be highlighed for every result
Press 'ctrl+k' to open search drawer
Enter the term "TestCase" in the search bar and hit entrxd.
Confirm that search results are displayed.
For each result with a description, ensure it fits within two lines and ends with "..." if it exceeds more than two lines.
Click on "Apps" category and click on "Last 7 Days" date option
Go through each result and ensure that each result’s date is within last 7 days
Go to this url https://abcd.com//ABC-form
User should able to see the "ABC Activity Form".
Enter "242525" in ID
Enter "test@test.com" in Business Email
Enter "Test Customer Name" in Customer Name.
Enter "Test Customer Account Number" in Customer Account Number.
Enter "Test Brief Description" in Brief Description.
//Enter "8888888888" in Phone Number.
Enter "aaaaa" in Phone Number.
Verify that the Phone Number field is still empty.
//Click on Submit button - Submit button should not be enabled b/c chars were entered in phone field
Verify that Submit button is not enabled
test('Verify size selection', async ({ page }) => { try { //On the top menu, hover over Mens, then Tops, and click on Jackets await Page_.menuHoverAndClick(page); //We should see a page with "Jackets" heading await Page_men_topsmen_jacketsmenhtml.VerifyPageHeading(page, 'Jackets'); //On the left sidebar, select SIZE, then click on M await Page_men_topsmen_jacketsmenhtml.CheckboxSelect(page, 'M'); //On the left sidebar select Price Range then click on of of the options that has > 3 items await.Page_men_topsmen_jacketsmenhtml.SelectPriceRange(IWebDriver driver, 3) //Go through each result. The M size should be highlighed for every result await Page_men_topsmen_jacketsmenhtml.fieldSizeHighlightedResults(page, 'M'); } catch (error) { console.log('An error occurred during the test execution:', error); throw error; } class Page_ { static async MenuHoverAndClick(page) { // Locate the 'Men' menu item console.log("Locate the 'Men' menu item"); const mensMenu = await page.locator("xpath=//a[@id='ui-id-5']/span[text()='Men']"); // Hover over the 'Men' menu item console.log("Hover over the 'Men' menu item"); await mensMenu.hover(); // Locate the 'Tops' submenu item console.log("Locate the 'Tops' submenu item"); const topsSubMenu = await page.locator("xpath=//a[@id='ui-id-17']/span[text()='Tops']"); // Hover over the 'Tops' submenu item console.log("Hover over the 'Tops' submenu item"); await topsSubMenu.hover(); // Locate the 'Jackets' item and click it console.log("Locate the 'Jackets' item and click it"); const jacketsItem = await page.locator("xpath=//a[@id='ui-id-19']/span[text()='Jackets']"); await jacketsItem.click(); // CLICK ACTION await page.waitForTimeout(1000); await page.waitForLoadState('networkidle', { timeout: 60000 }); } } public static void SelectPriceRange(IWebDriver driver, int minItems) { // Locate the Price filter section string priceFilterXPath = "//div[@class='filter-options-title' and text()='Price']/following-sibling::div//ol[@class='items']/li/a"; // Find all price range elements var priceElements = driver.FindElements(By.XPath(priceFilterXPath)); // Iterate over each price element foreach(var priceElement in priceElements) { // Get the count of items for each price range string itemCountText = priceElement.FindElement(By.XPath(".//span[@class='count']")).Text; int itemCount = int.Parse(itemCountText.Split(' ')[0]); // Check if the item count is greater than the specified minimum if (itemCount > minItems) { // Click on the price range element priceElement.Click(); // CLICK ACTION break; } } } class Page_men_topsmen_jacketsmenhtml { static async CheckboxSelect(page, filterOption) { // Find the SIZE filter on the left sidebar console.log('Find the SIZE filter on the left sidebar'); const sizeFilterElement = await page.locator("//div[@class='filter-options-title' and text()='Size']"); await sizeFilterElement.click(); // CLICK ACTION await page.waitForTimeout(1000); await page.waitForLoadState('networkidle', { timeout: 60000 }); // Wait for the element console.log('Wait for the element'); await page.waitForSelector("//div[@class='filter-options-content']//div[@class='swatch-option text ' and text()='" + filterOption + "']", { state: 'visible', timeout: 20000 }); // Select the M size checkbox console.log('Select the M size checkbox'); const mSizeElement = await page.locator("//div[@class='filter-options-content']//div[@class='swatch-option text ' and text()='" + filterOption + "']"); await mSizeElement.click(); // CLICK ACTION await page.waitForTimeout(1000); await page.waitForLoadState('networkidle', { timeout: 60000 }); } static async FieldSizeHighlightedResults(page, size) { // Define the XPath for the highlighted size option in each product result console.log('Define the XPath for the highlighted size option in each product result'); const xpath = `//div[contains(@class, 'swatch-attribute size')]//div[@aria-label='${size}' and contains(@class, 'selected')]`; // Check if the size is highlighted for every result console.log('Check if the size is highlighted for every result'); const elements = await page.$$(xpath); // ASSERT console.log('ASSERT'); if (elements.length === 0) { throw new Error(`Size ${size} is not highlighted in any results.`); } for (const element of elements) { const className = await element.getAttribute('class'); if (!className.includes('selected')) { throw new Error(`Size ${size} is not highlighted.`); } } } });
// Playwright version: 1.38.0 const { test, expect } = require('@playwright/test'); test('Advance search test', async ({ page }) => { try { // Press 'ctrl+k' to open search drawer console.log("Press 'ctrl+k' to open search drawer"); await page.keyboard.press('Control+k'); await page.waitForTimeout(1000); // No network load to wait for here, but adding for consistency // Enter the term "TestCase" in the search bar and hit enter. console.log('Enter the term "TestCase" in the search bar and hit enter.'); await page.type("//input[@id='search']", "TestCase"); await page.keyboard.press('Enter'); await page.waitForTimeout(1000); await page.waitForLoadState('networkidle', { timeout: 60000 }); // Confirm that search results are displayed. console.log('Confirm that search results are displayed.'); await page.waitForSelector("//div[@class='one-search']//div[@class='header']/span[text()='Search Results']", { state: 'visible' }); // For each result with a description, ensure it fits within two lines and ends with "..." if it exceeds more than two lines. console.log('For every result that has a description, verify that it is within one or two lines and truncated with ellipsis "..." if it exceeds more than two lines.'); const descriptions = await page.$$eval(".search-section .skeleton .loader-card p-skeleton:nth-child(2) > div", elements => { return elements.map(element => element.textContent.trim()); }); await page.waitForTimeout(1000); // Ensure the page is rendered completely before validation. for (const descText of descriptions) { const lineCount = descText.split('\n').length; expect(lineCount <= 2, 'Description exceeds 2 lines').toBeTruthy(); if (lineCount === 2) { expect(descText.endsWith('...'), 'Description is not truncated with ellipsis').toBeTruthy(); } } //Click on "Apps" category and click on "Last 7 Days" date option // Locate the checkbox for the specified category console.log('Locate the checkbox for the specified category'); const categoryXpath = `//h3[text()='Category']/following-sibling::div//p-checkbox//label[contains(text(), 'Apps')]`; const categoryElement = await page.locator(categoryXpath); await categoryElement.click(); // CLICK ACTION // Locate the radio button for the specified date console.log('Locate the radio button for the specified date'); const dateXpath = `//h3[text()='Date']/following-sibling::div//p-radiobutton//label[text() = 'Last 7 Days']//preceding-sibling::div`; const dateElement = await page.locator(dateXpath); await dateElement.click(); // CLICK ACTION // Go through each result and ensure that each result’s date is within last 7 days await page.waitForTimeout(1000); const date7DaysResults = await page.$$("//div[contains(@class, 'results')]//div[contains(@class, 'foot')]//span[@class='date']"); const today = new Date(); for (const dateElement of date7DaysResults) { const dateText = await dateElement.textContent(); const parsedDate = new Date(dateText.trim()); expect(parsedDate >= new Date(today.getTime() - 7 * 24 * 60 * 60 * 1000) && parsedDate <= today).toBeTruthy(); } } } catch (error) { console.log('Error encountered:', error); throw error;);
test('Test exception case', async ({ page }) => { try { //Go to this url abcd.com/ABC-form await Page_home.navigateToABCFormPage(page, 'abcd.com/ABC-form'); //User should able to see the "ABC Activity Form". await Page_ABC.verifyABCActivityFormVisibility(page) //Enter "242525" in ID await Page_ABC.fieldEnterRepId(page, '242525'); //Enter "test@test.com" in Business Email. await Page_ABC.fieldEnterBusinessEmail(page, 'test@test.com'); //Enter "Test Customer Name" in Customer Name. await Page_ABC.fieldEnterCustomerName(page, 'Test Customer Name'); //Enter "Test Customer Account Number" in Customer Account Number. await Page_Page_ABC.fieldCustomerAccountNumber(page, 'Test Customer Account Number'); //Enter "Test Brief Description" in Brief Description (include who, what, when, and why). \ await Page_ABC.fieldBriefDescription(page, 'Test Brief Description'); //Enter "aaaaa" in Phone Number. await Page_ABC.fieldPhoneNumberEnter(page, 'aaaaa'); //Verify that the Phone Number field is still empty. await Page_ABC.FieldIsEmptyPhoneNumber(page) //Verify that Submit button is not enabled await Page_ABC.buttonVerifySubmitNotEnabled(page } catch (error) { console.log('An error occurred during the test execution:', error); throw error; } class Page_home { static async navigateToABCFormPage(page, url) { // Navigate to the specified URL await page.goto(url, { waitUntil: 'load' }); // CLICK ACTION } class Page_ABC { static async buttonVerifySubmitNotEnabled(page) { // Locate the Submit button using XPath const submitButton = await page.locator("//button[contains(@class, 'p-button') and span[text()='Submit']]").elementHandle(); // Verify that the Submit button is not enabled const isEnabled = await submitButton.isEnabled(); // Assert that the button is not enabled if (isEnabled) { throw new Error('Submit button is unexpectedly enabled.'); } // ASSERT } static async fieldBriefDescription(page, descriptionText) { // Find the Brief Description field using its XPath const briefDescriptionField = await page.locator('//label[contains(text(), "Brief Description (include who, what, when, and why)")]//parent::web-label//following-sibling::textarea'); // Enter the provided description text into the Brief Description field await briefDescriptionField.fill(''); await briefDescriptionField.type(descriptionText); } static async fieldCustomerAccountNumber(page, accountNumber) { // Locate the Customer Account Number input field using XPath const CustomerAccountNumberField = await page.locator('//label[contains(text(), "*Customer Account Number")]/parent::web-label/following-sibling::web-input-text//input'); // Enter the provided account number into the Customer Account Number field await CustomerAccountNumberField.fill(accountNumber); } static async fieldEnterBusinessEmail(page, email) { // Locate the Business Email field const emailField = await page.locator('//label[contains(text(), "*Business Email")]/parent::web-label/following-sibling::web-input-text//input'); // Enter the email into the Business Email field await emailField.fill(email); // ENTER ACTION } static async fieldEnterCustomerName(page, CustomerName) { // Locate the Customer Name input field const CustomerNameField = await page.locator('//label[contains(text(), "*Customer Name")]//parent::web-label//following-sibling::web-input-text//input'); // Enter the provided Customer name await CustomerNameField.fill(''); await CustomerNameField.type(CustomerName); } static async fieldEnterRepId(page, repId) { // Find the input field for Rep ID const repIdInput = await page.locator('//label[contains(text(), "*Rep ID")]/parent::web-label/following-sibling::web-input-text//input'); // Enter the Rep ID into the input field await repIdInput.fill(repId); } static async fieldPhoneNumberEnter(page, phoneNumber) { // Locate the Phone Number input field const phoneNumberField = await page.locator('//label[contains(text(), "*Phone Number")]//parent::web-label//following-sibling::web-input-mask//input'); // Enter the phone number await phoneNumberField.fill(''); await phoneNumberField.type(phoneNumber); } //Verify that the Phone Number field is still empty. static async FieldIsEmptyPhoneNumber(page) { // Locate the Phone Number field input element const phoneNumberField = await page.locator("//label[contains(text(), '*Phone Number')]/following-sibling::web-input-mask//input[@title='phoneNumber']"); // Assert that the Phone Number field is empty const fieldValue = await phoneNumberField.inputValue(); if (fieldValue) { throw new Error('Phone Number field is not empty.'); } } static async verifyABC Activity FormVisibility(page) { // XPath to verify the visibility of the 'ABC Activity Form' const xpath = "//div[@class='headerText line-clip' and text()='ABC Activity Form']"; // Wait for the element await page.waitForSelector(xpath, { state: 'visible', timeout: 20000 }); // ASSERT const isVisible = await page.isVisible(xpath); if (!isVisible) { throw new Error("The 'ABC Activity Form' is not visible."); } } } } });