Skip to content

Commit

Permalink
Merge pull request #14 from BairamovM/HeaderCategoryEnum
Browse files Browse the repository at this point in the history
Add close cookie modal method
  • Loading branch information
BairamovM authored Sep 3, 2023
2 parents c782958 + d7042d4 commit 493d0a7
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public boolean isFooterCategoryButtonPresent(FooterCategory footerCategory) {

public HM_AbstractPage clickFooterButton(FooterCategory footerCategory) {
footerCategoryButton.format(footerCategory.getFooterCategory(), footerCategory.getFooterCategory()).click();
LOGGER.info("Clicking Footer Category button: " + footerCategory);
PageFactory pageFactory = new PageFactory();
return pageFactory.createPage(footerCategory);
}
Expand Down Expand Up @@ -124,6 +125,7 @@ public boolean isSocialNetworkButtonPresent(SocialNetwork socialNetwork) {

public HM_AbstractPage clickSocialNetworkButton(SocialNetwork socialNetwork) {
socialNetworkButton.format(socialNetwork.getSocialNetwork(), socialNetwork.getSocialNetwork()).click();
LOGGER.info("Clicking Social Network button: " + socialNetwork);
PageFactory pageFactory = new PageFactory();
return pageFactory.createPage(socialNetwork);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public HeaderMenu hoverHeaderCategoryButton(HeaderCategory headerCategory) {

public HM_AbstractPage clickHeaderCategoryButton(HeaderCategory headerCategory) {
headerCategoryButton.format(headerCategory.getHeaderCategory()).click();
LOGGER.info("Clicking Header Category button: " + headerCategory);
PageFactory pageFactory = new PageFactory();
return pageFactory.createPage(headerCategory);
}
Expand Down
49 changes: 48 additions & 1 deletion src/main/java/hm/automation/demo/gui/pages/HM_AbstractPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,69 @@

import java.lang.invoke.MethodHandles;

import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.WebDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.zebrunner.carina.webdriver.decorator.ExtendedWebElement;
import com.zebrunner.carina.webdriver.gui.AbstractPage;

public abstract class HM_AbstractPage extends AbstractPage {

private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

// COOKIES MODAL
@FindBy(xpath = "//h2[@id='onetrust-policy-title' and text()='Before you start shopping']")
private ExtendedWebElement cookieMainTitle;

@FindBy(xpath = "//p[@id='onetrust-policy-text']")
private ExtendedWebElement cookiePolicyText;

@FindBy(xpath = "//p[@id='onetrust-policy-text']//a[contains(text(), 'Cookie Policy')]")
private ExtendedWebElement cookiePolicyButton;

@FindBy(xpath = ".//button[@id='onetrust-accept-btn-handler' and text()='Accept all cookies']")
private ExtendedWebElement acceptAllCookiesButton;

@FindBy(xpath = ".//button[@id='onetrust-pc-btn-handler' and text()=' Cookie settings']")
private ExtendedWebElement cookieSettingsButton;

public HM_AbstractPage(WebDriver driver) {
super(driver);
}

public void closeCookies() {
public boolean isCookieMainTitlePresent() {
return cookieMainTitle.isElementPresent();
}

public boolean isCookiePolicyTextPresent() {
return cookiePolicyText.isElementPresent();
}

public boolean isCookiePolicyButtonPresent() {
return cookiePolicyButton.isElementPresent();
}

public boolean isAcceptAllCookiesButtonPresent() {
return acceptAllCookiesButton.isElementPresent();
}

public boolean isCookieSettingsButtonPresent() {
return cookieSettingsButton.isElementPresent();
}

public boolean isAllElementsCookieModalPresent() {
return isCookieMainTitlePresent() & isCookiePolicyTextPresent() &
isCookiePolicyButtonPresent() & isAcceptAllCookiesButtonPresent() &
isCookieSettingsButtonPresent();
}

public void closeCookies() {
if (isAllElementsCookieModalPresent()) {
acceptAllCookiesButton.click();
LOGGER.info("Cookie Modal was closed");
}
}

}
6 changes: 1 addition & 5 deletions src/test/java/hm/automation/demo/HeaderMenuTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ public class HeaderMenuTest implements IAbstractTest {
@Test()
@MethodOwner(owner = "Muslim Bairamov")
public void headerMenu() {

HomePage homePage = new HomePage(getDriver());
homePage.open();

pause(5);
homePage.closeCookies();

HeaderMenu headerMenu = homePage.getHeaderMenu();

Expand Down Expand Up @@ -66,7 +64,5 @@ public void headerMenu() {
pause(5);

homePage.scrollUpToHeader();

pause(5);
}
}

0 comments on commit 493d0a7

Please sign in to comment.