Wednesday

Loadrunner -- provide wait with waste time and timer

Action()

{

lr_start_transaction("Wait");

Wait(130000);

//lr_think_time(130);

lr_end_transaction("Wait", LR_AUTO);

return 0;

}

Create new action with name Wait

Wait(int time)

{

double timeElapsed;

merc_timer_handle_t timer;

if(time!=NULL)

{

timer = lr_start_timer();

sleep(time);

timeElapsed= lr_end_timer(timer);

lr_wasted_time(timeElapsed*1000);

}


return 0;

}

Sunday

Selenium 2 - rest of the code of classes ( contd from past post)

kindly change ChangetoLINK to LINK


package uk.co.shopzilla.qa.regression.dsl;

import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;


public class FooterPod extends AbstractPositionedPod{
public FooterPod(WebElement webElement) {
super(webElement);
}

public Changetolink findChangetolink(FooterChangetolink changetolink) {
return findChangetolink(changetolink.getElementId());
}

private Changetolink findChangetolink(final String id) {
try {
WebElement changetolinkElement = this.webElement.findElement(By.id(id));

return new Changetolink(changetolinkElement.getText(), changetolinkElement.getAttribute("href"));
}
catch (NoSuchElementException e) {
return null;
}
}


}


package uk.co.shopzilla.qa.regression.dsl;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.RenderedWebElement;
import org.openqa.selenium.WebElement;

import java.awt.*;
import java.util.List;


public class Home_page extends AbstractPositionedPod {

public Home_page(WebElement webElement) {
super(webElement);
}

public String getHeading() {
WebElement heading = webElement.findElement(By.xpath("//h2[@class = 'sponsored_changetolinks_heading']"));

if (heading == null) {
throw new IllegalStateException("Unable to find SL heading");
}

return heading.getText();
}


public int getChangetolinkCount() {
List changetolinks = webElement.findElements(By.tagName("li"));

return changetolinks.size();


}

public boolean getLogo(){
boolean isLogoExist;

WebElement logo = this.webElement.findElement(By.id("logobar"));
// WebElement logo = webElement.findElements(By.id("logobar"));
if(logo.toString()== null)
{

System.out.println("logo.toString()" + logo.toString());
isLogoExist=false;

}
else{
System.out.println("logo.toString()" + logo.toString());
isLogoExist=true;
}

return isLogoExist;

}
}


package uk.co.shopzilla.qa.regression.dsl;

public enum Home_page_Element
{

// Elements Comman for all Sites
isLogoPresent,
getPopularSearch,
ispopularbrandSearch,
isSearchBoxPresent,
isImageAtHomePagePresent,
isWhatSellingPodPresent,
isLogoAtFooterPresent,
isFooter_MerchantLoginPresent,
isFooterMerchantListingsPresent,
isFooterProductRreviewsPresent,
isPodNavigationPresent

// Elements ONLY in SZ_GB for all Sites


}

package uk.co.shopzilla.qa.regression.dsl;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import java.util.List;


public class Home_page_pod extends AbstractPositionedPod{


public Home_page_pod(WebElement webElement) {
super(webElement);
}

public int getlogo() {

// return webElement.findElements(By.id("logobara")).size();

// webElement.findElements(By.id("logobara"));

// WebElement heading = webElement.findElement(By.id("logobara"));
WebElement heading=webElement.findElement(By.id("logobar"));

if (heading == null) {
throw new IllegalStateException("Unable to find logo");


}
else{
// System.out.println("Home Page LOGO Exist - ");
System.out.println("\n PASS - Logo Exists on Home page ");

return 1;

}
}

public int getPopularSearch() {

// return webElement.findElements(By.id("logobara")).size();

// webElement.findElements(By.id("logobara"));

// WebElement heading = webElement.findElement(By.id("logobara"));
WebElement heading=webElement.findElement(By.className("popular_searches_body"));

if (heading == null) {
throw new IllegalStateException("Unable to find popular Search");


}
else{
// System.out.println("popular_searches_body found");
System.out.println("\n PASS - Popular Search on Home page Exist \n ");

return 1;

}


}


public int getPopularbrandSearch() {

// return webElement.findElements(By.id("logobara")).size();

// webElement.findElements(By.id("logobara"));

// WebElement heading = webElement.findElement(By.id("logobara"));
WebElement heading=webElement.findElement(By.className("popular_brands_body"));

if (heading == null) {
throw new IllegalStateException("Unable to find popular brand");


}
else{
// System.out.println("popular_searches_body found");
System.out.println("\n PASS - Popular brand on Home page Exist \n ");

return 1;

}


}

public int isSearchBoxPresent() {

// return webElement.findElements(By.id("logobara")).size();

// webElement.findElements(By.id("logobara"));

// WebElement heading = webElement.findElement(By.id("logobara"));
WebElement heading=webElement.findElement(By.className("search_input_field"));

if (heading == null) {
throw new IllegalStateException("Unable to find popular brand");


}
else{
// System.out.println("popular_searches_body found");
System.out.println("\n PASS - Search Box is present on Home page \n ");

return 1;

}

}


public int isImageAtHomePagePresent() {

// return webElement.findElements(By.id("logobara")).size();

// webElement.findElements(By.id("logobara"));

// WebElement heading = webElement.findElement(By.id("logobara"));
WebElement heading=webElement.findElement(By.className("merch_pod_container"));

if (heading == null) {
throw new IllegalStateException("Unable to find popular brand");


}
else{
// System.out.println("popular_searches_body found");
System.out.println("\n PASS - Image At Home Page is present on Home page \n ");

return 1;

}

}


public int isWhatSellingPodPresent() {

// return webElement.findElements(By.id("logobara")).size();

// webElement.findElements(By.id("logobara"));

// WebElement heading = webElement.findElement(By.id("logobara"));
WebElement heading=webElement.findElement(By.id("whats_selling_pod"));

if (heading == null) {
throw new IllegalStateException("Unable to find popular brand");


}
else{
// System.out.println("popular_searches_body found");
System.out.println("\n PASS - WhatisSellingPod Present on Home page \n ");

return 1;

}

}

public int isLogoAtFooterPresent() {

// return webElement.findElements(By.id("logobara")).size();

// webElement.findElements(By.id("logobara"));

// WebElement heading = webElement.findElement(By.id("logobara"));
WebElement heading=webElement.findElement(By.className("popular_brands_body"));

if (heading == null) {
throw new IllegalStateException("Unable to find popular brand");


}
else{
// System.out.println("popular_searches_body found");
System.out.println("\n PASS - Logo At Footer Present on Home page \n ");

return 1;

}

}

public int isFooter_MerchantLoginPresent() {

// return webElement.findElements(By.id("logobara")).size();

// webElement.findElements(By.id("logobara"));

// WebElement heading = webElement.findElement(By.id("logobara"));
WebElement heading=webElement.findElement(By.id("footer_merchant_login"));

if (heading == null) {
throw new IllegalStateException("Unable to find popular brand");


}
else{
// System.out.println("popular_searches_body found");
System.out.println("\n PASS - Footer Merchant Login changetolink Present on Home page \n ");

return 1;

}

}



public int isFooterMerchantListingsPresent() {

// return webElement.findElements(By.id("logobara")).size();

// webElement.findElements(By.id("logobara"));

// WebElement heading = webElement.findElement(By.id("logobara"));
WebElement heading=webElement.findElement(By.id("footer_merchant_listings"));

if (heading == null) {
throw new IllegalStateException("Unable to find popular brand");


}
else{
// System.out.println("popular_searches_body found");
System.out.println("\n PASS - Footer Merchant Listings changetolink Present on Home page \n ");

return 1;

}

}

public int isFooterProductRreviewsPresent() {

// return webElement.findElements(By.id("logobara")).size();

// webElement.findElements(By.id("logobara"));

// WebElement heading = webElement.findElement(By.id("logobara"));
WebElement heading=webElement.findElement(By.id("footer_product_reviews"));

if (heading == null) {
throw new IllegalStateException("Unable to find popular brand");


}
else{
// System.out.println("popular_searches_body found");
System.out.println("\n PASS - FooterProductRreviews changetolink Present Present on Home page \n ");

return 1;

}

}



public int isPodNavigationPresent() {

// return webElement.findElements(By.id("logobara")).size();

// webElement.findElements(By.id("logobara"));

// WebElement heading = webElement.findElement(By.id("logobara"));
WebElement heading=webElement.findElement(By.className("pod_navigation"));

if (heading == null) {
throw new IllegalStateException("Unable to find popular Search");


}
else{
// System.out.println("popular_searches_body found");
System.out.println("\n PASS - PodNavigation is Present on Home page Exist \n ");

return 1;

}


}



}




package uk.co.shopzilla.qa.regression.dsl;

import com.google.common.base.Function;
import com.google.common.collect.Lists;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import java.util.List;


public class HotCategoryPod extends AbstractPositionedPod {
public HotCategoryPod(WebElement webElement) {
super(webElement);
}

public List getChangetolinks() {
return Lists.transform(webElement.findElements(By.tagName("a")), new Function() {
@Override
public Changetolink apply(WebElement webElement) {
return new Changetolink(webElement.getText(), webElement.getAttribute("href"));
}
});
}
}


package uk.co.shopzilla.qa.regression.dsl;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;


public class Item {
private final WebElement webElement;

public Item(WebElement webElement) {
this.webElement = webElement;
}

public RedirectChangetolink getRedirectChangetolink() {
String redirectChangetolinkString = findElement("product_changetolink").getAttribute("href");

return RedirectChangetolink.from(redirectChangetolinkString);
}

public String getTitle() {
return findElement("product_img").getAttribute("alt");
}

public String getButtonText() {
return findElement("button").getText();
}

private WebElement findElement(final String className) {
return webElement.findElement(By.className(className));
}
}

package uk.co.shopzilla.qa.regression.dsl;

public class Changetolink {
private final String title;
private final String target;

public Changetolink(String title, String target) {
this.title = title;
this.target = target;
}

public String getTitle() {
return title;
}

public String getTarget() {
return target;
}

@Override
public String toString() {
return "Changetolink{" +
"title='" + title + '\'' +
", target='" + target + '\'' +
'}';
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

Changetolink changetolink = (Changetolink) o;

if (target != null ? !target.equals(changetolink.target) : changetolink.target != null) return false;
if (title != null ? !title.equals(changetolink.title) : changetolink.title != null) return false;

return true;
}

@Override
public int hashCode() {
int result = title != null ? title.hashCode() : 0;
result = 31 * result + (target != null ? target.hashCode() : 0);
return result;
}
}


package uk.co.shopzilla.qa.regression.dsl;

import com.google.common.collect.ImmutableMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openqa.selenium.*;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;


public class Page {
private static final Log LOG = LogFactory.getLog(Page.class);

private static final Map, By> POD_CONDITIONS =
ImmutableMap., By>builder()
.put(RelatedSearchesPod.class, By.id("more_searches"))
.put(RelatedSearchesContractedPod.class, By.id("less_searches"))
.put(ProductListPod.class, By.id("productionForm"))
.put(FooterPod.class, By.id("footer_changetolinks"))
.put(BreadCrumbsPod.class, By.id("breadcrumb"))
.put(ScorchingProductPod.class, By.id("scorching_product_details"))
.put(HotCategoryPod.class, By.id("other_matches"))
.put(FooterBanner.class, By.id("search_bar"))
// .put(Home_page_pod.class, By.className("content"))
.put(Home_page_pod.class,By.xpath("/html/body"))

// /x:html/x:body

.build();

private final WebDriver webDriver;
private static final Class[] SINGLE_WEBELEMENT = new Class[] { WebElement.class };

public Page(WebDriver webDriver) {
this.webDriver = webDriver;
}

public String getUrl() {
return webDriver.getCurrentUrl();
}



public FooterPod getFooterPod(){

return gettingFooterPod();
}

private FooterPod gettingFooterPod(){

final List FooterPod = webDriver.findElements(By.id("footer_changetolinks"));

System.out.println("\n Number of Footer Pod avilable = " + FooterPod.size());
System.out.println();

// if footer page available then return or give null
if (FooterPod.size() != 0) {
return new FooterPod(FooterPod.get(0));
}

return null;
}

public SponsoredChangetolinksPod getSponsoredChangetolinksPod() {
return findSponsoredChangetolinksPod(1, 1);
}

public SponsoredChangetolinksPod getTopSponsoredChangetolinksPod() {
return findSponsoredChangetolinksPod(1, 2);
}


public SponsoredChangetolinksPod getSingleSponsoredChangetolinksPod() {
return findSponsoredChangetolinksPod(1, 1);
}


public SponsoredChangetolinksPod getBottomSponsoredChangetolinksPod() {
return findSponsoredChangetolinksPod(2, 2);
}

private SponsoredChangetolinksPod findSponsoredChangetolinksPod(final int oneBasedIndex, final int expectedCount) {
final List sponsoredChangetolinksPods = webDriver.findElements(By.className("sponsored_changetolinks"));

if (sponsoredChangetolinksPods.size() == expectedCount) {
return new SponsoredChangetolinksPod(sponsoredChangetolinksPods.get(oneBasedIndex - 1));

}

return null;
}

public String getH1HeadingText() {
WebElement h1Heading = webDriver.findElement(By.tagName("h1"));

return h1Heading.getText();
}

public T getPod(Class podClass) {
By condition = POD_CONDITIONS.get(podClass);

if (condition == null) {
throw new RuntimeException("No condition defined for class: " + podClass);
}

try {
WebElement webElement = webDriver.findElement(condition);

Constructor podConstructor = podClass.getConstructor(SINGLE_WEBELEMENT);


// System.out.println("\n This is the text in selected Element" + webElement.getText());
return podConstructor.newInstance(webElement);



} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
} catch (NotFoundException e) {
LOG.debug("pod not found with condition: " + condition, e);
return null;
}
}
}





package uk.co.shopzilla.qa.regression.dsl;


public interface PageRequest {
PageRequest NONE = new PageRequest() {
@Override
public Page fetch(With... with) {
throw new UnsupportedOperationException();
}

@Override
public String getKeyword() {
throw new UnsupportedOperationException();
}

@Override
public void close() {
throw new UnsupportedOperationException();
}
};

Page fetch(With... with);

String getKeyword();

void close();
}

package uk.co.shopzilla.qa.regression.dsl;

import org.apache.log4j.Logger;
import org.openqa.selenium.WebDriver;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class PageRequestImpl implements PageRequest {
private static final Logger LOG = Logger.getLogger(PageRequestImpl.class);

private static final Pattern KEYWORD_PATTERN = Pattern.compile(".*__keyword--([\\w\\+]+).*");



private static final Pattern KEYWORD_PATTERN2 = Pattern.compile(".*__keyword--([\\w\\+]+)__sfsk.*");

private final WebDriver webDriver;
private final String url;

public PageRequestImpl(WebDriver webDriver, String url) {
this.webDriver = webDriver;
this.url = url;
}

@Override
public Page fetch(With... additionalParameters) {
webDriver.manage().deleteAllCookies();

StringBuilder withParams = new StringBuilder();

for (With with : additionalParameters) {
if (withParams.length() == 0) {
withParams.append("?");
}
else {
withParams.append("&");
}

withParams.append(with.param());
}


final String theUrl = url + withParams.toString();

LOG.info("Fetching url: " + theUrl);

webDriver.get(theUrl);

return new Page(webDriver);
}

@Override
public String getKeyword() {
Matcher matcher = KEYWORD_PATTERN.matcher(url);
Matcher matcher2 = KEYWORD_PATTERN2.matcher(url);



if (matcher.matches()) {


System.out.println("The URL is " + url);

if (matcher2.matches())


try {
System.out.println(" The URL have unwanted suffix __sfsk at the last so we are truncating it to get the keyword from URL. The keyword is " + matcher2.group(1));
return URLDecoder.decode(matcher2.group(1), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("This is weird, since UTF-8 is always supported by Java", e);
}

else

try {
return URLDecoder.decode(matcher.group(1), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("This is weird, since UTF-8 is always supported by Java", e);
}

}

if (matcher.matches()) {
try {
return URLDecoder.decode(matcher.group(1), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("This is weird, since UTF-8 is always supported by Java", e);
}
}

return "";
}

@Override
public void close() {
webDriver.close();
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

PageRequestImpl that = (PageRequestImpl) o;

if (url != null ? !url.equals(that.url) : that.url != null) return false;
if (webDriver != null ? !webDriver.equals(that.webDriver) : that.webDriver != null)
return false;

return true;
}

@Override
public int hashCode() {
int result = webDriver != null ? webDriver.hashCode() : 0;
result = 31 * result + (url != null ? url.hashCode() : 0);
return result;
}

@Override
public String toString() {
return "PageRequestImpl{" +
"webDriver=" + webDriver +
", url='" + url + '\'' +
'}';
}
}


package uk.co.shopzilla.qa.regression.dsl;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;


public class PaginationChangetolink {
private final WebElement webElement;

public PaginationChangetolink(WebElement webElement) {
this.webElement = webElement;
}

public String getText() {
return webElement.getText();
}

public boolean isShown() {
return webElement.findElements(By.tagName("a")).isEmpty();
}
}



package uk.co.shopzilla.qa.regression.dsl;


public class Position {
public static final Position UNKNOWN = new Position(Integer.MIN_VALUE, Integer.MIN_VALUE);

private final int x;
private final int y;

public Position(int x, int y) {
this.x = x;
this.y = y;
}

public int getX() {
return x;
}

public int getY() {
return y;
}
}



package uk.co.shopzilla.qa.regression.dsl;


public interface PositionedPod {
public boolean isAbove(PositionedPod other);
public boolean isLeftOf(PositionedPod other);
public boolean isBelow(PositionedPod other);

public Position getPosition();
}



/**
* Copyright (C) 2004 - 2009 Shopzilla, Inc.
* All rights reserved. Unauthorized disclosure or distribution is prohibited.
*/

package uk.co.shopzilla.qa.regression.dsl;

import org.openqa.selenium.By;
import org.openqa.selenium.NotFoundException;
import org.openqa.selenium.RenderedWebElement;
import org.openqa.selenium.WebElement;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;


public class ProductListPod extends AbstractPositionedPod {


public ProductListPod(WebElement webElement) {
super(webElement);
}


public List getItems() {
List result = new ArrayList();

for (WebElement itemElement : webElement.findElements(By.className("rev"))) {
result.add(new Item(itemElement));
}

return result;
}

public List getPaginationChangetolinks() {
List result = new ArrayList();

try {
final WebElement paginationBox = webElement.findElement(By.id("product_page_nav"));
for (WebElement changetolinkElement : paginationBox.findElements(By.tagName("li"))) {
result.add(new PaginationChangetolink(changetolinkElement));
}
}
catch (NotFoundException e) {
// ignore, we'll just return an empty result
}

return result;
}

public int getproductListPod() {
//List FooterPod = webDriver.findElements(By.id("footer_changetolinks"));
WebElement heading=webElement.findElement(By.className("popup_info"));

// List heading = webDriver.findElements(By.className("popup_info"));

if (heading == null) {
throw new IllegalStateException("Unable to find popular brand");


}
else{
// System.out.println("popular_searches_body found");
System.out.println("\n PASS - Product detail pop-up is present \n ");

return 1;

}
}

}




package uk.co.shopzilla.qa.regression.dsl;

import com.google.common.collect.ImmutableMap;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;


public class RedirectChangetolink {
private final Map parameters;

private RedirectChangetolink(Map parameters) {
this.parameters = ImmutableMap.copyOf(parameters);
}

public boolean hasParameter(String parameter) {
return parameters.containsKey(parameter);
}

public String getParameter(String parameter) {
return parameters.get(parameter);
}


public static RedirectChangetolink from(String url) {
Map params = new HashMap();

String[] urlParts = url.split("\\?");
if (urlParts.length > 1) {
String query = urlParts[1];
for (String param : query.split("&")) {
String[] pair = param.split("=");
String key = decode(pair[0]);
String value = decode(pair[1]);

if (params.containsKey(key)) {
throw new IllegalStateException("Key " + key + " occurred multiple times in redirect changetolink: " + url);
}

params.put(key, value);
}
}

return new RedirectChangetolink(params);
}

private static String decode(String s) {
try {
return URLDecoder.decode(s, "UTF-8");
}
catch (UnsupportedEncodingException e) {
// this can't happen, as UTF-8 is always supported...
return null;
}
}
}





package uk.co.shopzilla.qa.regression.dsl;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;


public class RelatedSearchesContractedPod extends AbstractPositionedPod{
public RelatedSearchesContractedPod(WebElement webElement) {
super(webElement);
}

public int getRelatedSearchesContractedCount() {
return webElement.findElements(By.tagName("a")).size();
}
}




package uk.co.shopzilla.qa.regression.dsl;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;


public class RelatedSearchesPod extends AbstractPositionedPod{
public RelatedSearchesPod(WebElement webElement) {
super(webElement);
}

public int getRelatedSearchesCount() {
return webElement.findElements(By.tagName("a")).size();

}
}






package uk.co.shopzilla.qa.regression.dsl;

/**
* Selector class that enables us to call the same URL with different parameters. The current
* implementation of this and PageRequestImpl only allows tacking the paramerers on to the URL, but
* if need be, we can easily extend that to manipulating cookies as well.
*

*/
public abstract class With {

public abstract String param();

public static With trafficSource(final String trafficSource) {
return new With() {
@Override
public String param() {
return "rf=" + trafficSource;
}
};
}

public static With matureAgreed(final boolean agreed) {
return new With() {
@Override
public String param() {
return "mature=" + String.valueOf(agreed);
}
};
}
}

package uk.co.shopzilla.qa.regression.dsl;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;


public class ScorchingProductPod extends AbstractPositionedPod {
public ScorchingProductPod(WebElement webElement) {
super(webElement);
}

public String getProductTitle() {
WebElement productTitleElement = webElement.findElement(By.tagName("h1"));

return productTitleElement.getText();
}

public String getImageUrl() {
WebElement image = webElement.findElement(By.tagName("img"));

return image.getAttribute("src");
}
}



package uk.co.shopzilla.qa.regression.dsl;

import org.openqa.selenium.By;
import org.openqa.selenium.RenderedWebElement;
import org.openqa.selenium.WebElement;

import java.awt.*;
import java.util.List;


public class SponsoredChangetolinksPod extends AbstractPositionedPod {

public SponsoredChangetolinksPod(WebElement webElement) {
super(webElement);
}

public String getHeading() {
WebElement heading = webElement.findElement(By.xpath("//h2[@class = 'sponsored_changetolinks_heading']"));

if (heading == null) {
throw new IllegalStateException("Unable to find SL heading");
}

return heading.getText();
}


public int getChangetolinkCount() {
List changetolinks = webElement.findElements(By.tagName("li"));

return changetolinks.size();
}
}


package uk.co.shopzilla.qa.regression.framework;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;


public class ChromeDriverFactory implements WebDriverFactory {
@Override
public WebDriver createDriver() {
return new ChromeDriver();
}

@Override
public String toString() {
return "chrome";
}
}

package uk.co.shopzilla.qa.regression.framework;

public enum Driver {
HTMLUNIT(new HtmlUnitDriverFactory()),
FIREFOX(new FirefoxWebDriverFactory()),
IE(new InternetExplorerDriverFactory()),
CHROME(new ChromeDriverFactory());

private final WebDriverFactory factory;

Driver(WebDriverFactory factory) {
this.factory = factory;
}

public WebDriverFactory getFactory() {
return factory;
}
}


package uk.co.shopzilla.qa.regression.framework;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class FirefoxWebDriverFactory implements WebDriverFactory {
@Override
public WebDriver createDriver() {
return new FirefoxDriver();
}

@Override
public String toString() {
return "firefox";
}
}


package uk.co.shopzilla.qa.regression.framework;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;


public class HtmlUnitDriverFactory implements WebDriverFactory {
@Override
public WebDriver createDriver() {
return new HtmlUnitDriver();
}

@Override
public String toString() {
return "HtmlUnit";
}
}



package uk.co.shopzilla.qa.regression.framework;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class InternetExplorerDriverFactory implements WebDriverFactory {
@Override
public WebDriver createDriver() {
return new InternetExplorerDriver();
}

@Override
public String toString() {
return "Internet Explorer";
}
}

package uk.co.shopzilla.qa.regression.framework;

import org.openqa.selenium.WebDriver;

public interface WebDriverFactory {
public WebDriver createDriver();
}

package uk.co.shopzilla.qa.regression.util;

import uk.co.shopzilla.qa.regression.dsl.PageRequest;

public interface PageTest {
void test(PageRequest pageRequest);
}


package uk.co.shopzilla.qa.regression.util;

import uk.co.shopzilla.qa.regression.configuration.Configuration;
import uk.co.shopzilla.qa.regression.configuration.PageIdentifier;
import uk.co.shopzilla.qa.regression.dsl.PageRequest;

public class RegressionTester {
public static void testIfConfigured(Configuration configuration, PageIdentifier pageIdentifier, PageTest pageTest) {
PageRequest pageRequest = configuration.getPageRequest(pageIdentifier);

if (pageRequest == PageRequest.NONE) {
return;
}

pageTest.test(pageRequest);

// note that if a test fails by throwing an exception, we'll never get here and thus the window will
// be left open. That's pretty good.
pageRequest.close();
}
}


package uk.co.shopzilla.qa.regression.verifiers;

import uk.co.shopzilla.qa.regression.dsl.BreadCrumbsPod;

import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertTrue;


public class BreadCrumbsPodVerifier {
public static void verify(String url, BreadCrumbsPod breadCrumbsPod) {
assertNotNull(url + ": breadCrumbsPod present", breadCrumbsPod);
System.out.println("Bread crumb items " + breadCrumbsPod.getBreadCrumbsCount());
assertTrue(url + ": bread crumb count > 1", breadCrumbsPod.getBreadCrumbsCount() > 1);


}
}

package uk.co.shopzilla.qa.regression.verifiers;
import org.openqa.selenium.WebElement;
import uk.co.shopzilla.qa.regression.dsl.AbstractPositionedPod;
import uk.co.shopzilla.qa.regression.dsl.FooterBanner;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;


public class FooterBannerVerifier {


public static void isfooterBannerExist(FooterBanner footerBanner){
int verifyFooterBanner;


verifyFooterBanner= footerBanner.isFooterBannerExist();


}

public static void isEditBoxinBannerExist(FooterBanner footerBanner){

footerBanner.isEditBoxinBanner();

}


}

package uk.co.shopzilla.qa.regression.verifiers;

import org.apache.log4j.Logger;
import org.openqa.selenium.WebElement;
import uk.co.shopzilla.qa.regression.dsl.FooterBanner;
import uk.co.shopzilla.qa.regression.dsl.FooterChangetolink;
import uk.co.shopzilla.qa.regression.dsl.FooterPod;
import uk.co.shopzilla.qa.regression.dsl.Changetolink;

import java.util.Map;

import static org.testng.AssertJUnit.*;
import static org.testng.AssertJUnit.assertEquals;

public class FooterPodVerifier {
private static final Logger LOG = Logger.getLogger(FooterPodVerifier.class);

public static void verify(String url, FooterPod footerPod, Map expectedFooterPodData) {
if (expectedFooterPodData == null) {
LOG.info("Footer pod verification turned off for url: " + url);
return;
}

for (FooterChangetolink footerChangetolink : FooterChangetolink.values()) {
compareChangetolink(url, expectedFooterPodData, footerPod, footerChangetolink);
}
}




private static void compareChangetolink(String message, Map expectedFooterPodData, FooterPod footerPod, FooterChangetolink changetolink) {
Changetolink expected = expectedFooterPodData.get(changetolink);
Changetolink actual = footerPod.findChangetolink(changetolink);

String messageWithChangetolinkName = message + " footer changetolink " + changetolink;

if (expected == null) {
assertNull(messageWithChangetolinkName + " - expected null but found: " + actual, actual);
}
else {
assertEquals(messageWithChangetolinkName + " - title mismatch", expected.getTitle(), actual.getTitle());
assertTrue(messageWithChangetolinkName + " - target mismatch (expected it to end with: " + expected.getTarget() + ", was: " + actual.getTarget() + ")", actual.getTarget().endsWith(expected.getTarget()));
}
}
}



package uk.co.shopzilla.qa.regression.verifiers;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertTrue;

import com.google.common.base.Strings;
import org.openqa.selenium.WebElement;
import uk.co.shopzilla.qa.regression.dsl.FooterPod;
import uk.co.shopzilla.qa.regression.dsl.Home_page;
import uk.co.shopzilla.qa.regression.dsl.Home_page_pod;
import uk.co.shopzilla.qa.regression.dsl.Home_page_Element;
import uk.co.shopzilla.qa.regression.dsl.RelatedSearchesContractedPod;


public class HomePageVerifier {

public static void verifyBanner(String url){

System.out.println( "\n Verifying the Home page upper Banner" );
// assertNotNull(url + ": pod is null", sponsoredChangetolinksPod);

//assertTrue(url, sponsoredChangetolinksPod.getHeading().endsWith(heading));
// if (changetolinkCount > -1){
}



public static void verify(String url, Home_page_Element home_page_element,Home_page_pod home_page_pod) {


switch (home_page_element)
{
case isLogoPresent: assertEquals(1,home_page_pod.getlogo());
break;
case getPopularSearch: assertEquals(1,home_page_pod.getPopularSearch());
break;
case ispopularbrandSearch: assertEquals(1,home_page_pod.getPopularbrandSearch());
break;
case isSearchBoxPresent: assertEquals(1,home_page_pod.isSearchBoxPresent());
break;

case isWhatSellingPodPresent: assertEquals(1,home_page_pod.isWhatSellingPodPresent());
break;
case isImageAtHomePagePresent: assertEquals(1,home_page_pod.isImageAtHomePagePresent());
break;

case isLogoAtFooterPresent: assertEquals(1,home_page_pod.isLogoAtFooterPresent());
break;

case isFooter_MerchantLoginPresent: assertEquals(1,home_page_pod.isFooter_MerchantLoginPresent());
break;

case isFooterMerchantListingsPresent: assertEquals(1,home_page_pod.isFooterMerchantListingsPresent());
break;
case isFooterProductRreviewsPresent: assertEquals(1,home_page_pod.isFooterProductRreviewsPresent());
break;


case isPodNavigationPresent: assertEquals(1,home_page_pod.isPodNavigationPresent());
break;


default: System.out.println("\n We find NO element on home page");
}

//System.out.println("\n Popular Search on Home page Exist " + home_page_pod.getPopularSearch());

}


}

package uk.co.shopzilla.qa.regression.verifiers;

import uk.co.shopzilla.qa.regression.dsl.HotCategoryPod;
import uk.co.shopzilla.qa.regression.dsl.Changetolink;

import java.util.List;

import static org.testng.AssertJUnit.assertEquals;

public class HotCategoryPodVerifier {
public static void verify(String url, HotCategoryPod pod, int numberOfCategories, String moreText) {

List changetolinks = pod.getChangetolinks();

assertEquals(url + ": correct # categories shown", numberOfCategories, changetolinks.size() - 1);
assertEquals(url + ": last changetolink is 'more'", moreText, changetolinks.get(changetolinks.size() - 1).getTitle());
}
}



package uk.co.shopzilla.qa.regression.verifiers;

import org.testng.AssertJUnit;
import uk.co.shopzilla.qa.regression.dsl.Page;



public class MatureWarningVerifier {
public static void assertIsWarning(Page page, final String expectedHeading) {
AssertJUnit.assertEquals(expectedHeading, page.getH1HeadingText());
}
}


package uk.co.shopzilla.qa.regression.verifiers;

import org.openqa.selenium.By;
import java.util.List;
import org.openqa.selenium.WebElement;
import uk.co.shopzilla.qa.regression.dsl.*;
import uk.co.shopzilla.qa.regression.dsl.RelatedSearchesPod;
import java.util.List;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openqa.selenium.*;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;


import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;


public class ProductListPodVerifier {
/** Pass this as the changetolinkCount parameter if you just want to check that there's at least one item in the product list pod. */
public static final int MORE_THAN_ZERO = -1;



public static void verify(String url, ProductListPod pod, int changetolinkCount, String pageToken, String cobrand, String goToStore, int expectedFurtherPages, Object nextText) {
final List items = pod.getItems();
int countItem;
countItem=1;

verifyChangetolinkCount(url, changetolinkCount, items);

//System.out.println("Total number of product listed on page == " + items.size());

for (Item item : items) {
RedirectChangetolink rd = item.getRedirectChangetolink();

checkParameterExists(url, item, rd, "mid");
checkParameterExists(url, item, rd, "catId");
checkParameterExists(url, item, rd, "pos");
checkParameterHasValue(url, item, rd, "tokenId", pageToken);
checkParameterExists(url, item, rd, "lg");
checkParameterExists(url, item, rd, "bAmt");
checkParameterExists(url, item, rd, "ppr");
checkParameterExists(url, item, rd, "oid");
checkParameterExists(url, item, rd, "atom");
checkParameterExists(url, item, rd, "bidType");
checkParameterExists(url, item, rd, "bId");
checkParameterHasValue(url, item, rd, "cobrand", cobrand);
checkParameterExists(url, item, rd, "mpid");
checkParameterExists(url, item, rd, "squid");

checkProductDetailPopUp(url,pod,item,countItem);
countItem++;

assertEquals(url + ": " + item.getTitle() + " button text", goToStore, item.getButtonText());
}


assertEquals(countItem-1,items.size());

System.out.println("******************************************************************");
System.out.println("\n PASS - The ProductDetail POP-UP : Total product pop-up on PAGE == " + items.size() +"\n");
System.out.println("******************************************************************");


List paginationChangetolinks = pod.getPaginationChangetolinks();


final int expectedChangetolinkCount = expectedFurtherPages == 0 ? 0 : expectedFurtherPages + 1;

System.out.println("expected pagination is = " + expectedFurtherPages + " while Actaul pagination =" + (paginationChangetolinks.size()-1));

assertEquals(url + ": #pagination changetolinks", expectedChangetolinkCount, paginationChangetolinks.size());
// The pagination index starts from 1 instead of 0 so fix the code below to start the loop from 1 instead of 0.
if (expectedFurtherPages > 0) {
for (int i = 1 ; i <= expectedFurtherPages ; i++) { assertEquals(url + ": pagination changetolink " + (i), String.valueOf(i), paginationChangetolinks.get(i - 1).getText()); assertEquals(url + ": page shown", (i == 0), paginationChangetolinks.get(i).isShown()); } assertEquals(url + ": 'next' pagination changetolink", nextText, paginationChangetolinks.get(expectedFurtherPages).getText()); } } public static void verifyCtr(String url, int ctr_parameter,ProductListPod pod, int changetolinkCount, Object nextText) { final List items = pod.getItems();
if(ctr_parameter == 1) {
for (Item item : items) {
RedirectChangetolink rd = item.getRedirectChangetolink();


checkParameterExists(url, item, rd, "ctr_pos");
checkParameterExists(url, item, rd, "ctr_brand");
checkParameterExists(url, item, rd, "ctr_rel"); //Just made it disbaled to test 9L page as in 9L page there is no CTR_REL


}
}

}

public static void verifyCtr9L(String url, int ctr_parameter,ProductListPod pod, int changetolinkCount, Object nextText) {
final List items = pod.getItems();
if(ctr_parameter == 1) {
for (Item item : items) {
RedirectChangetolink rd = item.getRedirectChangetolink();

checkParameterExists(url, item, rd, "ctr_pos");
//checkParameterExists(url, item, rd, "ctr_brand");
checkParameterExists(url, item, rd, "ctr_rel"); //Just made it disbaled to test 9L page as in 9L page there is no CTR_REL


}
}

}

private static void verifyChangetolinkCount(String url, int changetolinkCount, List items) {
switch (changetolinkCount) {
case MORE_THAN_ZERO:
assertTrue(url + ": changetolink count > 0", items.size() > 0);
break;
default:
assertEquals(url + ": changetolink count", changetolinkCount, items.size());
}
}

private static void checkParameterExists(String url, Item item, RedirectChangetolink rd, final String parameter) {
assertTrue(url + ": changetolink for " + item.getTitle() + " " + parameter, rd.hasParameter(parameter));
}


public static void checkProductDetailPopUp(String url, ProductListPod pod, Item item,int countItems) {

System.out.println("Product At Number " + countItems );
assertEquals(1,pod.getproductListPod());

// assertTrue(url + ": changetolink for " + item.getTitle() + " " + parameter, rd.hasParameter(parameter));
}

private static void checkParameterHasValue(String url, Item item, RedirectChangetolink rd, String parameter, String value) {
assertEquals(url + ": changetolink for " + item.getTitle() + " " + parameter, value, rd.getParameter(parameter));
}
}



package uk.co.shopzilla.qa.regression.verifiers;

import uk.co.shopzilla.qa.regression.dsl.RelatedSearchesContractedPod;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;


public class RelatedSearchesContractedPodVerifier {
public static void verify(String url, RelatedSearchesContractedPod relatedSearchesContractedPod, int numSearches) {
assertNotNull(url + ": related searches pod exists", relatedSearchesContractedPod);
assertEquals(url + ": related searches count", numSearches, relatedSearchesContractedPod.getRelatedSearchesContractedCount());
}
}

package uk.co.shopzilla.qa.regression.verifiers;

import uk.co.shopzilla.qa.regression.dsl.RelatedSearchesPod;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;


public class RelatedSearchesVerifier {
public static void verify(String url, RelatedSearchesPod relatedSearchesPod, int numSearches) {
assertNotNull(url + ": related searches pod exists", relatedSearchesPod);
assertEquals(url + ": related searches count", numSearches, relatedSearchesPod.getRelatedSearchesCount());
}
}




package uk.co.shopzilla.qa.regression.verifiers;

import com.google.common.base.Strings;
import uk.co.shopzilla.qa.regression.dsl.ScorchingProductPod;

import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertTrue;


public class ScorchingProductPodVerifier {
public static void verify(String url, ScorchingProductPod scorchingProductPod) {
assertNotNull(url + ": scorching product pod exists", scorchingProductPod);
assertTrue(url + ": product title present", !Strings.isNullOrEmpty(scorchingProductPod.getProductTitle()));

// the below check could be more detailed by figuring out the PID from the page URL and comparing.
// But that seems a little extravagant for now - I don't think that'll break.
assertTrue(url + ": image url present", !Strings.isNullOrEmpty(scorchingProductPod.getImageUrl()));
}
}


package uk.co.shopzilla.qa.regression.verifiers;

import uk.co.shopzilla.qa.regression.dsl.SponsoredChangetolinksPod;

import static org.testng.AssertJUnit.*;



public class SponsoredChangetolinksPodVerifier {

public static void verify(String url, SponsoredChangetolinksPod sponsoredChangetolinksPod, int changetolinkCount, String heading) {

System.out.println( "The name of the sponsored changetolink Pod is " + heading );
assertNotNull(url + ": pod is null", sponsoredChangetolinksPod);

assertTrue(url, sponsoredChangetolinksPod.getHeading().endsWith(heading));
if (changetolinkCount > -1){

assertEquals(url, changetolinkCount, sponsoredChangetolinksPod.getChangetolinkCount());

// assertEquals(url, changetolinkCount, sponsoredChangetolinksPod.getChangetolinkCount());

}

}
}


package uk.co.shopzilla.qa.regression.configuration;

import com.google.inject.internal.ImmutableMap;
import org.openqa.selenium.WebDriver;
import org.testng.Assert;
import org.testng.TestNG;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import uk.co.shopzilla.qa.regression.dsl.FooterChangetolink;
import uk.co.shopzilla.qa.regression.dsl.Changetolink;
import uk.co.shopzilla.qa.regression.dsl.PageRequestImpl;
import uk.co.shopzilla.qa.regression.framework.WebDriverFactory;

import java.util.HashMap;
import java.util.Map;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;


public class ConfigurationTest {
Configuration configuration;

WebDriverFactory webDriverFactory;
Map pages;

WebDriver webDriver;

@BeforeMethod
public void setUp() throws Exception {
webDriver = mock(WebDriver.class);

webDriverFactory = mock(WebDriverFactory.class);
when(webDriverFactory.createDriver()).thenReturn(webDriver);

pages = new HashMap();
pages.put(PageIdentifier.COOL_7Y, new SubdomainAndPath("/search__keyword--shoes.html"));
pages.put(PageIdentifier.COOL_8E, new SubdomainAndPath("dvds","/search__keyword--harley+davidson+motorcycle__sfsk--1.html"));

configuration = new Configuration("http://www.stage.bizrate.co.uk", webDriverFactory, pages, 0, ImmutableMap.of(), ImmutableMap.of());
}



@Test
public void mapTest() throws Exception {



}


// @Test
// public void testGetPageRequestNoSubdomain() throws Exception {
// PageRequestImpl expected = new PageRequestImpl(webDriver, "http://www.stage.bizrate.co.uk/search__keyword--shoes.html");
//
// assertEquals(configuration.getPageRequest(PageIdentifier.COOL_7Y), expected);
// }

// @Test
// public void testGetPageRequestWithSubdomain() throws Exception {
// PageRequestImpl expected = new PageRequestImpl(webDriver, "http://dvds.stage.bizrate.co.uk/search__keyword--harley+davidson+motorcycle__sfsk--1.html");
//
// assertEquals(configuration.getPageRequest(PageIdentifier.COOL_8E), expected);
// }

}

package uk.co.shopzilla.qa.regression.data;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.testng.annotations.DataProvider;
import uk.co.shopzilla.qa.regression.configuration.*;
import uk.co.shopzilla.qa.regression.framework.Driver;

import java.util.*;

import static uk.co.shopzilla.qa.regression.configuration.Site.*;


public class Configurations {

private static final Map AVAILABLE_CONFIGS = ImmutableMap.builder()
.put(BR_GB, createConfigurationBuilder(BR_GB).itemCount(30))
.put(SZ_GB, createConfigurationBuilder(SZ_GB))
.put(LW_GB, createConfigurationBuilder(LW_GB))
.put(PC_FR, createConfigurationBuilder(PC_FR).itemCount(30))
.put(SZ_FR, createConfigurationBuilder(SZ_FR))
.put(BR_DE, createConfigurationBuilder(BR_DE).itemCount(30))
.put(SG_DE, createConfigurationBuilder(SG_DE).itemCount(30))
.put(SZ_DE, createConfigurationBuilder(SZ_DE))
.build();

private static Configuration.Builder createConfigurationBuilder(final Site site) {
return new Configuration.Builder()
.pages(Pages.getPages(site))
.texts(Texts.getTexts(site))
.footerData(Footers.getFooterPodData(site));
}

private static List enabledConfigs = null;

@DataProvider(name = "configurations", parallel = true)
public static Iterator enabledConfigurations() {

synchronized (Configurations.class) {
if (enabledConfigs == null) {
List> hostAddresses = getHostAddressesFromEnvironment();
List drivers = getDriversFromEnvironment();

final List configsToEnable = new ArrayList();

for (Pair hostAddress : hostAddresses) {
for (Driver driver : drivers) {
Configuration configuration = AVAILABLE_CONFIGS.get(hostAddress.fst).baseUrl(hostAddress.snd).driverFactory(driver.getFactory()).build();

configsToEnable.add(new Configuration[] { configuration });
}
}

if (configsToEnable.isEmpty()) {
throw new IllegalStateException("no configurations enabled - specify with -DBRAND_COUNTRY (e.g., -DBR_GB)");
}

enabledConfigs = ImmutableList.copyOf(configsToEnable);
}
}

return enabledConfigs.iterator();
}

private static List> getHostAddressesFromEnvironment() {
List enabledSites = getEnabledSitesFromEnvironment();

final String hostOverride = System.getenv("host.override");

if (specified(hostOverride)) {
if (enabledSites.size() != 1) {
throw new IllegalStateException("Can only specify host override (" + hostOverride + ") with a single site enabled - enabled sites are: " + enabledSites);
}

return Arrays.asList(Pair.of(enabledSites.get(0), hostOverride));
}

List> result = new ArrayList>();

String urlPrefix = getUrlPrefixFromEnvironment();

for (Site site: enabledSites) {
result.add(Pair.of(site, urlPrefix + site.getBaseUrl()));
}

return result;
}

private static boolean specified(String hostOverride) {
// this is great ugliness, but I gave up trying to make the passing of environment variables from maven nicer.
return hostOverride != null && hostOverride.length() > 0 && !"null".equals(hostOverride);
}

private static List getEnabledSitesFromEnvironment() {
List result = new ArrayList();

for (Site site : Site.values()) {
if (System.getenv(site.name()) != null) {
result.add(site);
}
}

return result;
}

private static List getDriversFromEnvironment() {
List result = new ArrayList();

for (Driver driver : Driver.values()) {
if (System.getenv(driver.toString()) != null) {
result.add(driver);
}
}

if (result.isEmpty()) {
result.add(Driver.HTMLUNIT);
}

return result;
}

private static String getUrlPrefixFromEnvironment() {
String environmentName = System.getenv("environment");

Environment environment = environmentName == null ? Environment.STAGE : Environment.valueOf(environmentName);

/**
* Trying to see how things will work if we remove "http://www." and juts pass base url without it.
* later when we build the whole url then subdomain and relative path can be prefix and suffix respectively
* after this solution it is working for branch, master, stage and prod need to verify for localohost.
* @author sd
* @since
*/

// return "http://www." + environment.getSubdomain();

return environment.getSubdomain();

}


static class Pair {
final F fst;
final S snd;


Pair(F fst, S snd) {
this.fst = fst;
this.snd = snd;
}


static Pair of(F f, S s) {
return new Pair(f, s);
}
}
}



package uk.co.shopzilla.qa.regression.data;

import com.google.common.collect.ImmutableMap;
import uk.co.shopzilla.qa.regression.configuration.Site;
import uk.co.shopzilla.qa.regression.dsl.FooterChangetolink;
import uk.co.shopzilla.qa.regression.dsl.Changetolink;

import java.util.Map;

public class Footers {

private static final Map SZ_GB_FOOTER = ImmutableMap.builder()
.put(FooterChangetolink.HOME, new Changetolink("Home", "/"))
.put(FooterChangetolink.ABOUT, new Changetolink("About Shopzilla UK", "http://about.shopzilla.co.uk"))
.put(FooterChangetolink.PRIVACY_POLICY, new Changetolink("Privacy Policy", "/privacy-policy"))
.put(FooterChangetolink.USER_AGREEMENT, new Changetolink("User Agreement", "/user-agreement"))
.put(FooterChangetolink.PRESS, new Changetolink("Press", "shopzilla.co.uk/press"))
.put(FooterChangetolink.JOBS, new Changetolink("Jobs at Shopzilla", "http://about.shopzilla.com/careers-at-shopzilla/shopzilla-europe/benefits-europe"))
.put(FooterChangetolink.SITEMAP, new Changetolink("Shopzilla UK Sitemap Index", "/13K"))
.put(FooterChangetolink.TOP_SEARCHES, new Changetolink("Shopzilla UK Top Searches", "/13S"))
.put(FooterChangetolink.NEWSLETTER, new Changetolink("Sign up for the Shopzilla newsletter", ""))
.put(FooterChangetolink.MERCHANT_LOGIN, new Changetolink("Merchant Login", "merchant.shopzilla.co.uk/"))
.put(FooterChangetolink.MERCHANT_LISTINGS, new Changetolink("Merchant Listings and Advertising", "shopping_search/"))
.put(FooterChangetolink.PRODUCT_REVIEWS, new Changetolink("Product Reviews", "shopzillasolutions.co.uk/solutions/product-reviews"))
.put(FooterChangetolink.RATINGS_AND_RESEARCH, new Changetolink("Ratings and Research", "/customer_ratings/"))
.put(FooterChangetolink.AFFILIATES, new Changetolink("Affiliates", "publisher.shopzilla.co.uk"))
.put(FooterChangetolink.SZ_SOLUTIONS, new Changetolink("Shopzilla Solutions", "shopzillasolutions.co.uk/"))
.build();
private static final Map PC_FR_FOOTER = ImmutableMap.builder()
.put(FooterChangetolink.HOME, new Changetolink("Accueil", "/"))
.put(FooterChangetolink.ABOUT, new Changetolink("A propos de PrixMoinsCher", "http://about.prixmoinscher.com"))
.put(FooterChangetolink.PRIVACY_POLICY, new Changetolink("Politique de confidentialité", "/politique-de-confidentialite"))
.put(FooterChangetolink.USER_AGREEMENT, new Changetolink("Accord utilisateur", "/accord-utilisateur"))
.put(FooterChangetolink.TOP_PRODUCTS, new Changetolink("Top produits PrixMoinsCher", "/sitemap/top_products.html"))
.put(FooterChangetolink.PRESS, new Changetolink("Presse", "about.prixmoinscher.com/presse"))
.put(FooterChangetolink.SITEMAP, new Changetolink("Plan du site PrixMoinsCher", "/sitemap/index.html"))
.put(FooterChangetolink.TOP_SEARCHES, new Changetolink("Top requêtes PrixMoinsCher", "/sitemap/top_searches.html"))
.put(FooterChangetolink.RATINGS_GUIDE, new Changetolink("Evaluation des marchands", "/ratings_guide/guide.html"))
.put(FooterChangetolink.MERCHANT_LOGIN, new Changetolink("Espace Marchands - Connexion", "merchant.shopzilla.fr"))
.put(FooterChangetolink.MERCHANT_LISTINGS, new Changetolink("Campagne de publicité marchands", "shopping_search/"))
.put(FooterChangetolink.RATINGS_AND_RESEARCH, new Changetolink("Evaluations et recherche", "/customer_ratings/"))
.put(FooterChangetolink.AFFILIATES, new Changetolink("Affiliation", "affiliation.shopzilla.fr"))
.put(FooterChangetolink.SZ_SOLUTIONS, new Changetolink("Les Solutions Shopzilla", "lessolutionsshopzilla.fr/"))
.build();
private static final Map SZ_DE_FOOTER = ImmutableMap.builder()
.put(FooterChangetolink.HOME, new Changetolink("Startseite", "/"))
.put(FooterChangetolink.ABOUT, new Changetolink("Über Shopzilla Deutschland / Impressum", "http://about.shopzilla.de"))
.put(FooterChangetolink.PRIVACY_POLICY, new Changetolink("Datenschutzrichtlinien", "/datenschutzrichtlinien"))
.put(FooterChangetolink.USER_AGREEMENT, new Changetolink("Nutzungsbedingungen", "/nutzungsbedingungen"))
.build();

private static final Map> footerPodsPerSite = ImmutableMap.>builder()
.put(Site.SZ_GB, SZ_GB_FOOTER)
.put(Site.PC_FR, PC_FR_FOOTER)
// .put(Site.SZ_DE, SZ_DE_FOOTER)
.build();


public static Map getFooterPodData(Site site) {
return footerPodsPerSite.get(site);
}
}


package uk.co.shopzilla.qa.regression.data;

import com.google.common.collect.ImmutableMap;
import uk.co.shopzilla.qa.regression.configuration.Site;
import uk.co.shopzilla.qa.regression.configuration.TextIdentifier;

import java.util.Map;


public class Texts {
private static final Map GB_TEXTS = ImmutableMap.builder()
.put(TextIdentifier.GO_TO_STORE, "Go to store")
.put(TextIdentifier.MATURE_WARNING, "Warning: Adult Content.")
.put(TextIdentifier.SL_SUFFIX, " at other stores")
.put(TextIdentifier.NEXT, "Next")
.put(TextIdentifier.MORE, "More")
.build();

private static final Map FR_TEXTS = ImmutableMap.builder()
.put(TextIdentifier.GO_TO_STORE, "Voir l'offre")
.put(TextIdentifier.MATURE_WARNING, "Attention : Contenu pour adultes.")
.put(TextIdentifier.SL_SUFFIX, " chez d'autres marchands")
.put(TextIdentifier.NEXT, "Suivant")
.put(TextIdentifier.MORE, "Plus")
.build();

// Select encoding UTF8 in eclipse to load the localised characters correctly

private static final Map DE_TEXTS = ImmutableMap.builder()
.put(TextIdentifier.GO_TO_STORE, "Zum Shop")
.put(TextIdentifier.MATURE_WARNING, "Warnung: Inhalt für Erwachsene.")
.put(TextIdentifier.SL_SUFFIX, " von anderen Shops")
.put(TextIdentifier.NEXT, "Nächste")
.put(TextIdentifier.MORE, "Mehr")
.build();



private static final Map BR_TEXTS = ImmutableMap.builder()
.put(TextIdentifier.COBRAND, "1")
.build();

private static final Map SZ_TEXTS = ImmutableMap.builder()
.put(TextIdentifier.COBRAND, "2")
.build();

private static final Map SG_TEXTS = ImmutableMap.builder()
.put(TextIdentifier.COBRAND, "38")
.build();

private static final Map LW_TEXTS = ImmutableMap.builder()
.put(TextIdentifier.COBRAND, "22")
.build();

private static final Map PC_TEXTS = ImmutableMap.builder()
.put(TextIdentifier.COBRAND, "43")
.build();



private static final Map> textsForSites = ImmutableMap.>builder()
.put(Site.BR_GB, ImmutableMap.builder().putAll(GB_TEXTS).putAll(BR_TEXTS).build())
.put(Site.LW_GB, ImmutableMap.builder().putAll(GB_TEXTS).putAll(LW_TEXTS).build())
.put(Site.SZ_GB, ImmutableMap.builder().putAll(GB_TEXTS).putAll(SZ_TEXTS).build())
.put(Site.PC_FR, ImmutableMap.builder().putAll(FR_TEXTS).putAll(PC_TEXTS).build())
.put(Site.SZ_FR, ImmutableMap.builder().putAll(FR_TEXTS).putAll(SZ_TEXTS).build())
.put(Site.BR_DE, ImmutableMap.builder().putAll(DE_TEXTS).putAll(BR_TEXTS).build())
.put(Site.SG_DE, ImmutableMap.builder().putAll(DE_TEXTS).putAll(SG_TEXTS).build())
.put(Site.SZ_DE, ImmutableMap.builder().putAll(DE_TEXTS).putAll(SZ_TEXTS).build())
.build();


public static Map getTexts(Site site) {
return textsForSites.get(site);
}
}



package uk.co.shopzilla.qa.regression.test;

import static org.testng.AssertJUnit.assertTrue;
import static uk.co.shopzilla.qa.regression.util.RegressionTester.testIfConfigured;
import org.testng.annotations.Test;
import uk.co.shopzilla.qa.regression.configuration.Configuration;
import uk.co.shopzilla.qa.regression.configuration.PageIdentifier;
import uk.co.shopzilla.qa.regression.configuration.TextIdentifier;
import uk.co.shopzilla.qa.regression.data.Configurations;
import uk.co.shopzilla.qa.regression.dsl.*;
import uk.co.shopzilla.qa.regression.util.PageTest;
import uk.co.shopzilla.qa.regression.verifiers.*;

public class Cool7ZTest {
@Test(dataProvider = "configurations", dataProviderClass = Configurations.class)
public void testCool7ZWalkin(final Configuration configuration) throws Exception {
testIfConfigured(configuration, PageIdentifier.COOL_7Z, new PageTest() {
@Override
public void test(PageRequest pageRequest) {
Page page = pageRequest.fetch(With.trafficSource("wlk"));


FooterBannerVerifier.isfooterBannerExist(page.getPod(FooterBanner.class));

FooterBannerVerifier.isEditBoxinBannerExist(page.getPod(FooterBanner.class));



BreadCrumbsPodVerifier.verify(page.getUrl(), page.getPod(BreadCrumbsPod.class));
SponsoredChangetolinksPodVerifier.verify(page.getUrl(), page.getTopSponsoredChangetolinksPod(), 5, pageRequest.getKeyword() + configuration.getText(TextIdentifier.SL_SUFFIX));
SponsoredChangetolinksPodVerifier.verify(page.getUrl(), page.getBottomSponsoredChangetolinksPod(), 7, pageRequest.getKeyword() + configuration.getText(TextIdentifier.SL_SUFFIX));
ProductListPodVerifier.verify(page.getUrl(), page.getPod(ProductListPod.class), 20, "7Z", configuration.getText(TextIdentifier.COBRAND), configuration.getText(TextIdentifier.GO_TO_STORE), 5, configuration.getText(TextIdentifier.NEXT));
RelatedSearchesVerifier.verify(page.getUrl(), page.getPod(RelatedSearchesPod.class), 22);
FooterPodVerifier.verify(page.getUrl(), page.getPod(FooterPod.class), configuration.getFooterPodData());

assertTrue(page.getPod(BreadCrumbsPod.class).isAbove(page.getTopSponsoredChangetolinksPod()));
assertTrue(page.getTopSponsoredChangetolinksPod().isAbove(page.getPod(ProductListPod.class)));
assertTrue(page.getPod(ProductListPod.class).isAbove(page.getBottomSponsoredChangetolinksPod()));
assertTrue(page.getBottomSponsoredChangetolinksPod().isAbove(page.getPod(RelatedSearchesPod.class)));
assertTrue(page.getPod(RelatedSearchesPod.class).isAbove(page.getPod(FooterPod.class)));
}
});
}
}


package uk.co.shopzilla.qa.regression.test;

import static org.testng.AssertJUnit.assertTrue;
import static uk.co.shopzilla.qa.regression.util.RegressionTester.testIfConfigured;

import org.testng.annotations.Test;

import uk.co.shopzilla.qa.regression.configuration.Configuration;
import uk.co.shopzilla.qa.regression.configuration.PageIdentifier;
import uk.co.shopzilla.qa.regression.configuration.TextIdentifier;
import uk.co.shopzilla.qa.regression.data.Configurations;
import uk.co.shopzilla.qa.regression.dsl.*;
import uk.co.shopzilla.qa.regression.util.PageTest;
import uk.co.shopzilla.qa.regression.verifiers.*;
import org.openqa.selenium.*;

public class Cool8CTest {
@Test(dataProvider = "configurations", dataProviderClass = Configurations.class)
public void testCool8CWalkin(final Configuration configuration) throws Exception {
testIfConfigured(configuration, PageIdentifier.COOL_8C, new PageTest() {
@Override
public void test(PageRequest pageRequest) {
Page page = pageRequest.fetch(With.trafficSource("wlk"));



BreadCrumbsPodVerifier.verify(page.getUrl(), page.getPod(BreadCrumbsPod.class));
SponsoredChangetolinksPodVerifier.verify(page.getUrl(), page.getTopSponsoredChangetolinksPod(), 5, pageRequest.getKeyword() + configuration.getText(TextIdentifier.SL_SUFFIX));
SponsoredChangetolinksPodVerifier.verify(page.getUrl(), page.getBottomSponsoredChangetolinksPod(), 7, pageRequest.getKeyword() + configuration.getText(TextIdentifier.SL_SUFFIX));


//verifying the footer banner exist or not



FooterBannerVerifier.isfooterBannerExist(page.getPod(FooterBanner.class));

FooterBannerVerifier.isEditBoxinBannerExist(page.getPod(FooterBanner.class));



ProductListPodVerifier.verifyCtr(page.getUrl(), 1,page.getPod(ProductListPod.class), 3, configuration.getText(TextIdentifier.NEXT));
ProductListPodVerifier.verify(page.getUrl(), page.getPod(ProductListPod.class), 20, "8C", configuration.getText(TextIdentifier.COBRAND), configuration.getText(TextIdentifier.GO_TO_STORE), 5, configuration.getText(TextIdentifier.NEXT));
RelatedSearchesVerifier.verify(page.getUrl(), page.getPod(RelatedSearchesPod.class), 22);
FooterPodVerifier.verify(page.getUrl(), page.getPod(FooterPod.class), configuration.getFooterPodData());

assertTrue(page.getPod(BreadCrumbsPod.class).isAbove(page.getTopSponsoredChangetolinksPod()));
assertTrue(page.getTopSponsoredChangetolinksPod().isAbove(page.getPod(ProductListPod.class)));
assertTrue(page.getPod(ProductListPod.class).isAbove(page.getBottomSponsoredChangetolinksPod()));
assertTrue(page.getBottomSponsoredChangetolinksPod().isAbove(page.getPod(RelatedSearchesPod.class)));
assertTrue(page.getPod(RelatedSearchesPod.class).isAbove(page.getPod(FooterPod.class)));
}
});
}
}

package uk.co.shopzilla.qa.regression.test;

import static org.testng.AssertJUnit.assertTrue;
import static uk.co.shopzilla.qa.regression.util.RegressionTester.testIfConfigured;

import org.testng.annotations.Test;

import uk.co.shopzilla.qa.regression.configuration.Configuration;
import uk.co.shopzilla.qa.regression.configuration.PageIdentifier;
import uk.co.shopzilla.qa.regression.configuration.TextIdentifier;
import uk.co.shopzilla.qa.regression.data.Configurations;
import uk.co.shopzilla.qa.regression.dsl.*;
import uk.co.shopzilla.qa.regression.util.PageTest;
import uk.co.shopzilla.qa.regression.verifiers.*;

public class Cool8ETest {
@Test(dataProvider = "configurations", dataProviderClass = Configurations.class)
public void testCool8EWalkin(final Configuration configuration) throws Exception {
testIfConfigured(configuration, PageIdentifier.COOL_8E, new PageTest() {
@Override
public void test(PageRequest pageRequest) {
Page page = pageRequest.fetch(With.trafficSource("wlk"));

BreadCrumbsPodVerifier.verify(page.getUrl(), page.getPod(BreadCrumbsPod.class));
SponsoredChangetolinksPodVerifier.verify(page.getUrl(), page.getTopSponsoredChangetolinksPod(), 5, pageRequest.getKeyword() + configuration.getText(TextIdentifier.SL_SUFFIX));
SponsoredChangetolinksPodVerifier.verify(page.getUrl(), page.getBottomSponsoredChangetolinksPod(), 7, pageRequest.getKeyword() + configuration.getText(TextIdentifier.SL_SUFFIX));




// ProductListPodVerifier.verify(page.getUrl(), page.getPod(ProductListPod.class), 20, "8E", configuration.getText(TextIdentifier.COBRAND), configuration.getText(TextIdentifier.GO_TO_STORE), 2, configuration.getText(TextIdentifier.NEXT));
FooterBannerVerifier.isfooterBannerExist(page.getPod(FooterBanner.class));

FooterBannerVerifier.isEditBoxinBannerExist(page.getPod(FooterBanner.class));


RelatedSearchesVerifier.verify(page.getUrl(), page.getPod(RelatedSearchesPod.class), 22);
FooterPodVerifier.verify(page.getUrl(), page.getPod(FooterPod.class), configuration.getFooterPodData());

assertTrue(page.getPod(BreadCrumbsPod.class).isAbove(page.getTopSponsoredChangetolinksPod()));
assertTrue(page.getTopSponsoredChangetolinksPod().isAbove(page.getPod(ProductListPod.class)));
assertTrue(page.getPod(ProductListPod.class).isAbove(page.getBottomSponsoredChangetolinksPod()));
assertTrue(page.getBottomSponsoredChangetolinksPod().isAbove(page.getPod(RelatedSearchesPod.class)));
assertTrue(page.getPod(RelatedSearchesPod.class).isAbove(page.getPod(FooterPod.class)));
}
});
}
}



package uk.co.shopzilla.qa.regression.test;

import org.testng.annotations.Test;
import uk.co.shopzilla.qa.regression.configuration.Configuration;
import uk.co.shopzilla.qa.regression.configuration.PageIdentifier;
import uk.co.shopzilla.qa.regression.data.Configurations;
import uk.co.shopzilla.qa.regression.dsl.FooterBanner;
import uk.co.shopzilla.qa.regression.dsl.Page;
import uk.co.shopzilla.qa.regression.dsl.PageRequest;
import uk.co.shopzilla.qa.regression.util.PageTest;
import uk.co.shopzilla.qa.regression.verifiers.FooterBannerVerifier;
import uk.co.shopzilla.qa.regression.verifiers.HomePageVerifier;

import static uk.co.shopzilla.qa.regression.util.RegressionTester.testIfConfigured;
import uk.co.shopzilla.qa.regression.dsl.With;

import org.testng.annotations.Test;
import uk.co.shopzilla.qa.regression.configuration.Configuration;
import uk.co.shopzilla.qa.regression.configuration.PageIdentifier;
import uk.co.shopzilla.qa.regression.configuration.TextIdentifier;
import uk.co.shopzilla.qa.regression.data.Configurations;
import uk.co.shopzilla.qa.regression.dsl.*;
import uk.co.shopzilla.qa.regression.util.PageTest;
import uk.co.shopzilla.qa.regression.verifiers.*;
import uk.co.shopzilla.qa.regression.verifiers.FooterBannerVerifier;

import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertTrue;
import static uk.co.shopzilla.qa.regression.util.RegressionTester.testIfConfigured;


public class Home_SZTest {

@Test(dataProvider = "configurations", dataProviderClass = Configurations.class)
public void testHomePage(final Configuration configuration) throws Exception {


testIfConfigured(configuration, PageIdentifier.Home_SZ, new PageTest() {


@Override
public void test(PageRequest pageRequest) {
Page page = pageRequest.fetch(With.trafficSource("wlk"));

// HomePageVerifier.verifyBanner(page.getUrl());
Boolean isLogoPresent;
isLogoPresent=false;


HomePageVerifier.verify(page.getUrl(), Home_page_Element.isLogoPresent,page.getPod(Home_page_pod.class));
HomePageVerifier.verify(page.getUrl(), Home_page_Element.getPopularSearch,page.getPod(Home_page_pod.class));
HomePageVerifier.verify(page.getUrl(), Home_page_Element.ispopularbrandSearch,page.getPod(Home_page_pod.class));
HomePageVerifier.verify(page.getUrl(), Home_page_Element.isSearchBoxPresent,page.getPod(Home_page_pod.class));

HomePageVerifier.verify(page.getUrl(), Home_page_Element.isImageAtHomePagePresent,page.getPod(Home_page_pod.class));
HomePageVerifier.verify(page.getUrl(), Home_page_Element.isWhatSellingPodPresent,page.getPod(Home_page_pod.class));
HomePageVerifier.verify(page.getUrl(), Home_page_Element.isPodNavigationPresent,page.getPod(Home_page_pod.class));


HomePageVerifier.verify(page.getUrl(), Home_page_Element.isFooter_MerchantLoginPresent,page.getPod(Home_page_pod.class));
HomePageVerifier.verify(page.getUrl(), Home_page_Element.isLogoAtFooterPresent,page.getPod(Home_page_pod.class));
HomePageVerifier.verify(page.getUrl(), Home_page_Element.isFooterMerchantListingsPresent,page.getPod(Home_page_pod.class));
HomePageVerifier.verify(page.getUrl(), Home_page_Element.isFooterProductRreviewsPresent,page.getPod(Home_page_pod.class));


}
});
}




package uk.co.shopzilla.qa.regression.test;

import org.testng.annotations.Test;
import uk.co.shopzilla.qa.regression.configuration.Configuration;
import uk.co.shopzilla.qa.regression.configuration.PageIdentifier;
import uk.co.shopzilla.qa.regression.configuration.TextIdentifier;
import uk.co.shopzilla.qa.regression.data.Configurations;
import uk.co.shopzilla.qa.regression.dsl.*;
import uk.co.shopzilla.qa.regression.util.PageTest;
import uk.co.shopzilla.qa.regression.verifiers.*;

import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertTrue;
import static uk.co.shopzilla.qa.regression.util.RegressionTester.testIfConfigured;


public class Hot7STest {

@Test(dataProvider = "configurations", dataProviderClass = Configurations.class)
public void testHot7S_5SL(final Configuration configuration) throws Exception {
testIfConfigured(configuration, PageIdentifier.HOT_7S_5SLS, new PageTest() {
@Override
public void test(PageRequest pageRequest) {
Page page = pageRequest.fetch(With.trafficSource("wlk"));

SponsoredChangetolinksPodVerifier.verify(page.getUrl(), page.getSponsoredChangetolinksPod(), 5, pageRequest.getKeyword() + configuration.getText(TextIdentifier.SL_SUFFIX));
ProductListPodVerifier.verify(page.getUrl(),
page.getPod(ProductListPod.class),
20,
"7S",
configuration.getText(TextIdentifier.COBRAND),
configuration.getText(TextIdentifier.GO_TO_STORE),
5,
configuration.getText(TextIdentifier.NEXT));



FooterPodVerifier.verify(page.getUrl(), page.getPod(FooterPod.class), configuration.getFooterPodData());
BreadCrumbsPodVerifier.verify(page.getUrl(), page.getPod(BreadCrumbsPod.class));
RelatedSearchesVerifier.verify(page.getUrl(), page.getPod(RelatedSearchesPod.class), 22);

assertTrue(page.getPod(ProductListPod.class).isAbove(page.getSponsoredChangetolinksPod()));
}
});
}

@Test(dataProvider = "configurations", dataProviderClass = Configurations.class)
public void testHot7SGgl(final Configuration configuration) throws Exception {
testIfConfigured(configuration, PageIdentifier.HOT_7S_5SLS, new PageTest() {
@Override
public void test(PageRequest pageRequest) {
Page page = pageRequest.fetch(With.trafficSource("ggl"));
SponsoredChangetolinksPodVerifier.verify(page.getUrl(), page.getSponsoredChangetolinksPod(), 5, pageRequest.getKeyword() + configuration.getText(TextIdentifier.SL_SUFFIX));
BreadCrumbsPodVerifier.verify(page.getUrl(), page.getPod(BreadCrumbsPod.class));
RelatedSearchesVerifier.verify(page.getUrl(), page.getPod(RelatedSearchesPod.class), 22);

assertTrue(page.getSponsoredChangetolinksPod().isAbove(page.getPod(ProductListPod.class)));
}
});
}

@Test(dataProvider = "configurations", dataProviderClass = Configurations.class)
public void testHot7SWalkin(final Configuration configuration) throws Exception {
testIfConfigured(configuration, PageIdentifier.HOT_7S_5SLS, new PageTest() {
@Override
public void test(PageRequest pageRequest) {
Page page = pageRequest.fetch(With.trafficSource("wlk"));

SponsoredChangetolinksPodVerifier.verify(page.getUrl(), page.getSponsoredChangetolinksPod(), 5, pageRequest.getKeyword() + configuration.getText(TextIdentifier.SL_SUFFIX));
ProductListPodVerifier.verify(page.getUrl(),
page.getPod(ProductListPod.class),
20,
"7S",
configuration.getText(TextIdentifier.COBRAND),
configuration.getText(TextIdentifier.GO_TO_STORE),
5,
configuration.getText(TextIdentifier.NEXT));
FooterPodVerifier.verify(page.getUrl(), page.getPod(FooterPod.class), configuration.getFooterPodData());

BreadCrumbsPodVerifier.verify(page.getUrl(), page.getPod(BreadCrumbsPod.class));
RelatedSearchesVerifier.verify(page.getUrl(), page.getPod(RelatedSearchesPod.class), 22);
HotCategoryPodVerifier.verify(page.getUrl(), page.getPod(HotCategoryPod.class), 4, configuration.getText(TextIdentifier.MORE));

assertTrue(page.getPod(ProductListPod.class).isAbove(page.getSponsoredChangetolinksPod()));
}
});
}
}




package uk.co.shopzilla.qa.regression.test;

import org.testng.annotations.Test;
import uk.co.shopzilla.qa.regression.configuration.Configuration;
import uk.co.shopzilla.qa.regression.configuration.PageIdentifier;
import uk.co.shopzilla.qa.regression.configuration.TextIdentifier;
import uk.co.shopzilla.qa.regression.data.Configurations;
import uk.co.shopzilla.qa.regression.dsl.*;
import uk.co.shopzilla.qa.regression.util.PageTest;
import uk.co.shopzilla.qa.regression.verifiers.*;

import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertTrue;
import static uk.co.shopzilla.qa.regression.util.RegressionTester.testIfConfigured;

public class HotTest {

@Test(dataProvider = "configurations", dataProviderClass = Configurations.class)
public void testHot8BWalkin(final Configuration configuration) throws Exception {
testIfConfigured(configuration, PageIdentifier.HOT_8B_10SLS, new PageTest() {
@Override
public void test(PageRequest pageRequest) {
Page page = pageRequest.fetch(With.trafficSource("wlk"));

SponsoredChangetolinksPodVerifier.verify(page.getUrl(), page.getSponsoredChangetolinksPod(), 10, pageRequest.getKeyword() + configuration.getText(TextIdentifier.SL_SUFFIX));
ProductListPodVerifier.verify(page.getUrl(),
page.getPod(ProductListPod.class),
configuration.getDefaultItemCount(),
"8B",
configuration.getText(TextIdentifier.COBRAND),
configuration.getText(TextIdentifier.GO_TO_STORE),
5,
configuration.getText(TextIdentifier.NEXT));

FooterBannerVerifier.isfooterBannerExist(page.getPod(FooterBanner.class));

FooterBannerVerifier.isEditBoxinBannerExist(page.getPod(FooterBanner.class));


FooterPodVerifier.verify(page.getUrl(), page.getPod(FooterPod.class), configuration.getFooterPodData());

BreadCrumbsPodVerifier.verify(page.getUrl(), page.getPod(BreadCrumbsPod.class));
RelatedSearchesVerifier.verify(page.getUrl(), page.getPod(RelatedSearchesPod.class), 22);
RelatedSearchesContractedPodVerifier.verify(page.getUrl(), page.getPod(RelatedSearchesContractedPod.class), 2);
HotCategoryPodVerifier.verify(page.getUrl(), page.getPod(HotCategoryPod.class), 4, configuration.getText(TextIdentifier.MORE));

assertTrue(page.getPod(ProductListPod.class).isAbove(page.getSponsoredChangetolinksPod()));
}
});
}

@Test(dataProvider = "configurations", dataProviderClass = Configurations.class)
public void testHot8BGgl(final Configuration configuration) throws Exception {
testIfConfigured(configuration, PageIdentifier.HOT_8B_10SLS, new PageTest() {
@Override
public void test(PageRequest pageRequest) {
Page page = pageRequest.fetch(With.trafficSource("ggl"));


FooterBannerVerifier.isfooterBannerExist(page.getPod(FooterBanner.class));

FooterBannerVerifier.isEditBoxinBannerExist(page.getPod(FooterBanner.class));
SponsoredChangetolinksPodVerifier.verify(page.getUrl(), page.getTopSponsoredChangetolinksPod(), 5, pageRequest.getKeyword() + configuration.getText(TextIdentifier.SL_SUFFIX));
SponsoredChangetolinksPodVerifier.verify(page.getUrl(), page.getBottomSponsoredChangetolinksPod(), 5, pageRequest.getKeyword() + configuration.getText(TextIdentifier.SL_SUFFIX));
BreadCrumbsPodVerifier.verify(page.getUrl(), page.getPod(BreadCrumbsPod.class));
RelatedSearchesVerifier.verify(page.getUrl(), page.getPod(RelatedSearchesPod.class), 22);

assertTrue(page.getTopSponsoredChangetolinksPod().isAbove(page.getPod(ProductListPod.class)));
assertTrue(page.getPod(ProductListPod.class).isAbove(page.getBottomSponsoredChangetolinksPod()));
}
});
}


@Test(dataProvider = "configurations", dataProviderClass = Configurations.class)
public void testHot8B_5SL(final Configuration configuration) throws Exception {
testIfConfigured(configuration, PageIdentifier.HOT_8B_5SLS, new PageTest() {
@Override
public void test(PageRequest pageRequest) {
Page page = pageRequest.fetch(With.trafficSource("wlk"));

SponsoredChangetolinksPodVerifier.verify(page.getUrl(), page.getSponsoredChangetolinksPod(), 5, pageRequest.getKeyword() + configuration.getText(TextIdentifier.SL_SUFFIX));
ProductListPodVerifier.verify(page.getUrl(),
page.getPod(ProductListPod.class),
configuration.getDefaultItemCount(),
"8B",
configuration.getText(TextIdentifier.COBRAND),
configuration.getText(TextIdentifier.GO_TO_STORE),
5,
configuration.getText(TextIdentifier.NEXT));

FooterBannerVerifier.isfooterBannerExist(page.getPod(FooterBanner.class));

FooterBannerVerifier.isEditBoxinBannerExist(page.getPod(FooterBanner.class));

FooterPodVerifier.verify(page.getUrl(), page.getPod(FooterPod.class), configuration.getFooterPodData());
BreadCrumbsPodVerifier.verify(page.getUrl(), page.getPod(BreadCrumbsPod.class));
RelatedSearchesVerifier.verify(page.getUrl(), page.getPod(RelatedSearchesPod.class), 22);

assertTrue(page.getPod(ProductListPod.class).isAbove(page.getSponsoredChangetolinksPod()));
}
});
}



@Test(dataProvider = "configurations", dataProviderClass = Configurations.class)
public void testHot8BMatureWarningNotAgreed(final Configuration configuration) throws Exception {
testIfConfigured(configuration, PageIdentifier.HOT_8B_MATURE, new PageTest() {
@Override
public void test(PageRequest pageRequest) {
Page page = pageRequest.fetch(With.matureAgreed(false));

MatureWarningVerifier.assertIsWarning(page, configuration.getText(TextIdentifier.MATURE_WARNING));
}
});
}

@Test(dataProvider = "configurations", dataProviderClass = Configurations.class)
public void testHot8BMatureWarningAgreed(final Configuration configuration) throws Exception {
testIfConfigured(configuration, PageIdentifier.HOT_8B_MATURE, new PageTest() {
@Override
public void test(PageRequest pageRequest) {
Page page = pageRequest.fetch(With.matureAgreed(true));

// check that the page is a regular hot page

FooterBannerVerifier.isfooterBannerExist(page.getPod(FooterBanner.class));

FooterBannerVerifier.isEditBoxinBannerExist(page.getPod(FooterBanner.class));

SponsoredChangetolinksPodVerifier.verify(page.getUrl(), page.getSponsoredChangetolinksPod(), -1, pageRequest.getKeyword() + configuration.getText(TextIdentifier.SL_SUFFIX));
BreadCrumbsPodVerifier.verify(page.getUrl(), page.getPod(BreadCrumbsPod.class));
// TODO: check if we actually don't want related searches for mature categories - today, they are disabled via touchpoint 80 for some or all mature categories
RelatedSearchesVerifier.verify(page.getUrl(), page.getPod(RelatedSearchesPod.class), 22);
//Disabling this test for now. It fails because it identifies the popular searches as related searches.
//Will enable again once the pod ids are fixed.
//assertNull("no related searches pod", page.getPod(RelatedSearchesPod.class));
}
});
}
}