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

[draft] implemented new localized feature for salesforce based site tests #359

Closed
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.qaprosoft.carina.demo.beatsbydre.component.android;

import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.FindBy;

import com.qaprosoft.carina.demo.beatsbydre.component.common.AbstractCustomCard;
import com.zebrunner.carina.webdriver.decorator.ExtendedWebElement;
import com.zebrunner.carina.webdriver.decorator.annotations.Localized;

public class CustomCard extends AbstractCustomCard {
@Localized(focus = Localized.NameFocus.FULL_PATH)
@FindBy(tagName = "h2")
private ExtendedWebElement featureTitle;

@Localized(focus = Localized.NameFocus.FULL_PATH)
@FindBy(xpath = ".//div[@class='card__content-top']//div//p")
private ExtendedWebElement featureDescription;

public CustomCard(WebDriver driver, SearchContext searchContext) {
super(driver, searchContext);
}

public void interactWithElements() {
featureDescription.getText();
featureTitle.getText();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.qaprosoft.carina.demo.beatsbydre.component.android;

import java.util.List;

import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.FindBy;

import com.qaprosoft.carina.demo.beatsbydre.component.common.AbstractFooter;
import com.qaprosoft.carina.demo.beatsbydre.component.desktop.FooterItem;
import com.zebrunner.carina.utils.mobile.IMobileUtils;
import com.zebrunner.carina.webdriver.decorator.ExtendedWebElement;
import com.zebrunner.carina.webdriver.decorator.annotations.Localized;
import com.zebrunner.carina.webdriver.locator.Context;

public class Footer extends AbstractFooter implements IMobileUtils {
@Localized(focus = Localized.NameFocus.CLASS_DECLARE)
@FindBy(xpath = ".//div[@class='copyright']/p")
private ExtendedWebElement copyright;

@FindBy(xpath = ".//div[@class='mobile-select-country']")
private ExtendedWebElement countryRow;

@Localized(focus = Localized.NameFocus.CLASS_DECLARE)
@FindBy(tagName = "p")
@Context(dependsOn = "countryRow")
private ExtendedWebElement mobileLocation;

@Localized(focus = Localized.NameFocus.CLASS_DECLARE)
@FindBy(tagName = "a")
@Context(dependsOn = "countryRow")
private ExtendedWebElement locationCountry;

@FindBy(xpath = ".//div[@class='mobile-newsletter']")
private ExtendedWebElement emailRaw;

@Localized(focus = Localized.NameFocus.CLASS_DECLARE)
@Context(dependsOn = "emailRaw")
@FindBy(tagName= "p")
private ExtendedWebElement mobileEmailTitle;

@Localized(focus = Localized.NameFocus.CLASS_DECLARE)
@Context(dependsOn = "emailRaw")
@FindBy(tagName = "a")
private ExtendedWebElement signUpButton;

public Footer(WebDriver driver, SearchContext searchContext) {
super(driver, searchContext);
}

@Override
public void interactWithLocalizedElements() {
swipe(copyright);
copyright.hover();
mobileLocation.hover();
locationCountry.hover();
mobileEmailTitle.hover();
signUpButton.hover();
}

public List<FooterItem> getFooterItems() {
throw new RuntimeException("There is no footer items for android");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.qaprosoft.carina.demo.beatsbydre.component.android;

import java.util.List;

import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.FindBy;

import com.qaprosoft.carina.demo.beatsbydre.component.common.AbstractHeader;
import com.zebrunner.carina.utils.mobile.IMobileUtils;
import com.zebrunner.carina.webdriver.decorator.ExtendedWebElement;
import com.zebrunner.carina.webdriver.decorator.annotations.Localized;

public class Header extends AbstractHeader implements IMobileUtils {

@FindBy(xpath = ".//button[@aria-controls='secondary-nav-sm']")
private ExtendedWebElement navMenuButton;

@Localized(focus = Localized.NameFocus.CLASS_DECLARE)
@FindBy(xpath = ".//nav[@id='secondary-nav-sm']//li[@role='presentation']/a[not(@target='_blank')]")
private List<ExtendedWebElement> mobileHeaderTitles;

@FindBy(xpath = ".//nav[@id='secondary-nav-sm']//a[@class='has-subNavItems']")
private ExtendedWebElement expandAllNavButton;

@Localized(focus = Localized.NameFocus.CLASS_DECLARE)
@FindBy(className = "show-mobile")
private ExtendedWebElement promoText;

public Header(WebDriver driver, SearchContext searchContext) {
super(driver, searchContext);
}

@Override
public void interactWithLocalizedElements() {
promoText.hover();
navMenuButton.click();
expandAllNavButton.click();
for (ExtendedWebElement title: mobileHeaderTitles) {
swipe(title);
title.hover();
}
navMenuButton.click();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.qaprosoft.carina.demo.beatsbydre.component.android;

import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.FindBy;

import com.qaprosoft.carina.demo.beatsbydre.component.common.AbstractLargeCard;
import com.zebrunner.carina.webdriver.decorator.ExtendedWebElement;
import com.zebrunner.carina.webdriver.decorator.annotations.Localized;

public class LargeCard extends AbstractLargeCard {
@Localized(focus = Localized.NameFocus.FULL_PATH)
@FindBy(tagName = "h2")
private ExtendedWebElement popularCardTitle;

@Localized(focus = Localized.NameFocus.FULL_PATH)
@FindBy(className = "pc-originalprice")
private ExtendedWebElement popularCardPrice;
public LargeCard(WebDriver driver, SearchContext searchContext) {
super(driver, searchContext);
}

public void interactWithElements() {
popularCardTitle.getText();
popularCardPrice.getText();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.qaprosoft.carina.demo.beatsbydre.component.android;

import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.ExpectedConditions;

import com.qaprosoft.carina.demo.beatsbydre.component.common.AbstractRegistrationError;
import com.zebrunner.carina.utils.Configuration;
import com.zebrunner.carina.utils.mobile.IMobileUtils;
import com.zebrunner.carina.webdriver.decorator.ExtendedWebElement;
import com.zebrunner.carina.webdriver.decorator.annotations.Localized;

public class RegistrationError extends AbstractRegistrationError implements IMobileUtils {
@FindBy(xpath = ".//button[@class='modal-close']")
private ExtendedWebElement closeButton;

@Localized(focus = Localized.NameFocus.CLASS_DECLARE)
@FindBy(xpath = ".//h2//div")
private ExtendedWebElement errorTitle;

@Localized(focus = Localized.NameFocus.CLASS_DECLARE)
@FindBy(xpath = ".//p[contains(@class,'serial-number-error')]")
private ExtendedWebElement serNumberError;

public RegistrationError(WebDriver driver, SearchContext searchContext) {
super(driver, searchContext);
}

public String getErrorTitle() {
waitUntil(ExpectedConditions.visibilityOf(errorTitle.getElement()),
Configuration.getLong(Configuration.Parameter.EXPLICIT_TIMEOUT));
return errorTitle.getText();
}

public String getSerNumberError() {
return serNumberError.getText();
}

public void closeModal() {
tap(closeButton);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.qaprosoft.carina.demo.beatsbydre.component.common;

import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;

import com.zebrunner.carina.webdriver.gui.AbstractUIObject;

public abstract class AbstractCustomCard extends AbstractUIObject {
public AbstractCustomCard(WebDriver driver, SearchContext searchContext) {
super(driver, searchContext);
}

public abstract void interactWithElements();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.qaprosoft.carina.demo.beatsbydre.component.common;

import java.util.List;

import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;

import com.zebrunner.carina.webdriver.gui.AbstractUIObject;

public abstract class AbstractFooter extends AbstractUIObject {
public AbstractFooter(WebDriver driver, SearchContext searchContext) {
super(driver, searchContext);
}

public abstract void interactWithLocalizedElements();

public abstract List<? extends AbstractFooterItem> getFooterItems();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.qaprosoft.carina.demo.beatsbydre.component.common;

import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;

import com.zebrunner.carina.webdriver.gui.AbstractUIObject;

public abstract class AbstractFooterItem extends AbstractUIObject {

public AbstractFooterItem(WebDriver driver, SearchContext searchContext) {
super(driver, searchContext);
}

public abstract void hoverElements();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.qaprosoft.carina.demo.beatsbydre.component.common;

import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;

import com.zebrunner.carina.webdriver.gui.AbstractUIObject;

public abstract class AbstractHeader extends AbstractUIObject {

public AbstractHeader(WebDriver driver, SearchContext searchContext) {
super(driver, searchContext);
}

public abstract void interactWithLocalizedElements();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.qaprosoft.carina.demo.beatsbydre.component.common;

import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;

import com.zebrunner.carina.webdriver.gui.AbstractUIObject;

public abstract class AbstractLargeCard extends AbstractUIObject {
public AbstractLargeCard(WebDriver driver, SearchContext searchContext) {
super(driver, searchContext);
}
public abstract void interactWithElements();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.qaprosoft.carina.demo.beatsbydre.component.common;

import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;

import com.zebrunner.carina.webdriver.gui.AbstractUIObject;

public abstract class AbstractRegistrationError extends AbstractUIObject {

public AbstractRegistrationError(WebDriver driver, SearchContext searchContext) {
super(driver, searchContext);
}

public abstract String getErrorTitle();

public abstract String getSerNumberError();

public abstract void closeModal();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.qaprosoft.carina.demo.beatsbydre.component.desktop;

import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.FindBy;

import com.qaprosoft.carina.demo.beatsbydre.component.common.AbstractCustomCard;
import com.zebrunner.carina.webdriver.decorator.ExtendedWebElement;
import com.zebrunner.carina.webdriver.decorator.annotations.Localized;

public class CustomCard extends AbstractCustomCard {
@Localized(focus = Localized.NameFocus.FULL_PATH)
@FindBy(tagName = "h2")
private ExtendedWebElement featureTitle;

@Localized(focus = Localized.NameFocus.FULL_PATH)
@FindBy(xpath = ".//div[@class='card__content-top']//div//p")
private ExtendedWebElement featureDescription;

public CustomCard(WebDriver driver, SearchContext searchContext) {
super(driver, searchContext);
}

public void interactWithElements() {
featureDescription.hover();
featureTitle.hover();
}
}
Loading