Skip to content
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

Amazon feature #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Amazon feature #1

wants to merge 2 commits into from

Conversation

mukundgpt2025
Copy link
Owner

No description provided.

And User validates add to cart
When User add product to cart
And User opens cart
Then User able to see added product in cart

Choose a reason for hiding this comment

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

Scenario: User is able to add product to the cart
Given User is on the homepage
When User searches for product "iphone 13"
Then User should be able to see the product "iphone 13" in the results and add it to cart

public void userAbleToSeeAddedProductInCart() {
new AmazonBL(SAMPLE_TEST_CONTEXT.ME,Runner.platform).verifyProductAddedToCart();
}
}

Choose a reason for hiding this comment

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

You need to make changes to all files according to the changes in the feature file

if(sponsoredLinkList.size()>20){
firstResultLink = By.xpath("//div[@data-cel-widget='search_result_2']//h2/a");
} else if (sponsoredLinkList.size()>15) {
firstResultLink = By.xpath("//div[@data-cel-widget='search_result_1']//h2/a");

Choose a reason for hiding this comment

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

xpaths should be define above as
private final By sponsoredLink = By.xpath("//div[@data-cel-widget='search_result_2']//h2/a"");

} else if (sponsoredLinkList.size()>15) {
firstResultLink = By.xpath("//div[@data-cel-widget='search_result_1']//h2/a");
}
driver.findElement(firstResultLink).click();

Choose a reason for hiding this comment

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

use waitFor methods instead of sleeps

if(driver.findElements(currentlyUnavailableElement).size()>0)
return -2;
else if(driver.findElement(addToCartButton).isDisplayed())
return 1;

Choose a reason for hiding this comment

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

can simply return boolean if present

}

public void openCart() {
waitFor(5);

Choose a reason for hiding this comment

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

sleeps not recommenced

}

public boolean verifyProductAddedToCart() {
return totalProductsinCart+1==Integer.parseInt(driver.findElement(cartCurrentValueElement).getText());

Choose a reason for hiding this comment

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

you should just return the number of products from here and put assertions in BL by comparing. Do not compare here

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