Skip to content

hotSellersSection first test rework#99

Open
AlexStefan17 wants to merge 4 commits intomainfrom
hotSellersSection-rework
Open

hotSellersSection first test rework#99
AlexStefan17 wants to merge 4 commits intomainfrom
hotSellersSection-rework

Conversation

@AlexStefan17
Copy link
Collaborator

@AlexStefan17 AlexStefan17 commented Jan 26, 2024

Rework hotSellectorSecion with POM

const productDetails = new ProductDetails(page);

await homePage.navigateToHomePage();
const randomNumber = Math.floor(Math.random() * 6);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a method. In a file called utils, under a folder called lib or helpers. Once that is done, just import here and call the method

.locator(`nth=${randomNumber}`)
.innerText()
).split("\n")[0];
await homePage.hotSellersProducts().locator(`nth=${randomNumber}`).click();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

În POM you don't have selectors in test. Moving this into page and try something nice there

Comment on lines +17 to +22
const productName = (
await homePage
.hotSellersProducts()
.locator(`nth=${randomNumber}`)
.innerText()
).split("\n")[0];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a method inside of productPage and just referenced here.
Tests don't have logic or selectors.

import { HomePage } from "../pages/home.page";
/**
* Navigates to the home page and generates a random number between 0 and max (exclusive).
* @param {Object} homePage - The object representing the home page.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annotations says you take two params, but function takes only one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants