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));
}
});
}
}

Selenium 2- SZ - Code of Configuration and some of DSL package

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

import com.google.inject.internal.ImmutableMap;
import org.apache.log4j.Logger;
import uk.co.shopzilla.qa.regression.dsl.FooterLink;
import uk.co.shopzilla.qa.regression.dsl.Link;
import uk.co.shopzilla.qa.regression.dsl.PageRequest;
import uk.co.shopzilla.qa.regression.dsl.PageRequestImpl;
import uk.co.shopzilla.qa.regression.framework.WebDriverFactory;

import java.util.Map;

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

private final String baseUrl;
private final WebDriverFactory webDriverFactory;
private final Map pages;
private final int defaultItemCount;
private final Map footerPodData;
private final Map footerPodDatalink;
private final Map texts;

public Configuration(String baseUrl, WebDriverFactory webDriverFactory, Map pages, int defaultItemCount, Map footerPodData, Map texts) {
this.baseUrl = baseUrl;
this.webDriverFactory = webDriverFactory;
this.pages = pages;
this.defaultItemCount = defaultItemCount;
this.footerPodData = footerPodData;
this.footerPodDatalink= footerPodData;
this.texts = texts;
}
public PageInfo getPageDetails(final PageIdentifier pageIdentifier){
final SubdomainAndPath page = pages.get(pageIdentifier);
return page.getPageinfo();
}

public PageRequest getPageRequest(final PageIdentifier pageIdentifier) {
final SubdomainAndPath page = pages.get(pageIdentifier);

if (page == null) {
LOG.warn("No page with identifier: " + pageIdentifier + " for configuration: " + this + " - returning dummy");

return PageRequest.NONE;
}


System.out.println("This is the Base URL == " + baseUrl);
System.out.println("This is the full URL == " + "http://" + page.getSubdomain()+ "." + baseUrl + page.getPath());


/**
* Code has been modified from return new PageRequestImpl(webDriverFactory.createDriver(), baseUrl + page.getPath());
* to return new PageRequestImpl(webDriverFactory.createDriver(),"http://" + page.getSubdomain()+ "." + baseUrl + page.getPath());
*Previously we were not able to get the subdomain but this will handle the subdomain part .
*also from the Configuration.class returing the http://www. string as base url so to update that file to just return base url.
* @author Krishan Shukla
* @since Mar 23, 2011
*/


return new PageRequestImpl(webDriverFactory.createDriver(),"http://" + page.getSubdomain()+ "." + baseUrl + page.getPath());

// if (baseUrl.equalsIgnoreCase("bizrate.co.uk") || baseUrl.equalsIgnoreCase("stage.bizrate.co.uk") )
// {
// // return new PageRequestImpl(webDriverFactory.createDriver(), baseUrl + page.getPath());
// return new PageRequestImpl(webDriverFactory.createDriver(),"http://" + page.getSubdomain()+ "." + baseUrl + page.getPath());
// }
//
// else
//
// return new PageRequestImpl(webDriverFactory.createDriver(),"http://" + page.getSubdomain()+ "." + baseUrl + page.getPath());
//

}


@Override
public String toString() {
return "Configuration{" +
"webDriverFactory=" + webDriverFactory +
", baseUrl='" + baseUrl + '\'' +
'}';
}

public String getText(TextIdentifier textIdentifier) {
return texts.get(textIdentifier);
}

public int getDefaultItemCount() {
return defaultItemCount;
}

public Map getFooterPodData() {
return footerPodData;
}


//This code is not completed -
public void getFooterPodLinks() {

Map footerPodDatalink;

footerPodDatalink=getFooterPodData();

int sizeOffooter=footerPodDatalink.size();

for (int i=0;i pages;
private int defaultItemCount = 20; // Matches the default item count in the search command - used for SZ sites
private Map footerPodData;
private Map texts;

public Builder baseUrl(String baseUrl) {
this.baseUrl = baseUrl;

return this;
}

public Builder pages(Map pages) {
this.pages = ImmutableMap.copyOf(pages);
return this;
}

public Builder driverFactory(WebDriverFactory driverFactory) {
this.webDriverFactory = driverFactory;
return this;
}

public Builder texts(Map texts) {
this.texts = ImmutableMap.copyOf(texts);
return this;
}


public Builder itemCount(int itemCount) {
this.defaultItemCount = itemCount;
return this;
}

public Builder footerData(Map footerPodData) {
this.footerPodData = footerPodData;
return this;
}



public Configuration build() {
// TODO consistency checks either here or in the ctor

return new Configuration(baseUrl, webDriverFactory, pages, defaultItemCount, footerPodData, texts);
}

}
}




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

public enum Environment {
STAGE("stage."),
MASTER("master."),
BRANCH("branch."),
PRODUCTION("");


private final String subdomain;

Environment(String subdomain) {
this.subdomain = subdomain;
}

public String getSubdomain() {
return subdomain;
}
}


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


public enum PageIdentifier {
Home_SZ,
Home,
HOT_8B_10SLS,
HOT_8B_MATURE,
HOT_8B_5SLS,
HOT_7S_5SLS,
HOT_10J_5SLS,
HOT_7T_5SLS,
COOL_7Y,
COOL_7Z,
COOL_8C,
COOL_8E,
COOL_8I,
SCORCHING_8N,
SCORCHING_8N_COMPACTED,
SCORCHING_9L
}



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


public class PageInfo {
public final int productlinkno;
public final int sponsorlinkno;
public final int paginationno;

public PageInfo (int productlinkno, int sponsorlinkno, int paginationno){
this.productlinkno = productlinkno;
this.sponsorlinkno = sponsorlinkno;
this.paginationno = paginationno;
}
}




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

public enum Site {
BR_GB("bizrate.co.uk"),
LW_GB("lowpriceshopper.co.uk"),
SZ_GB("shopzilla.co.uk"),
PC_FR("prixmoinscher.com"),
SZ_FR("shopzilla.fr"),
BR_DE("bizrate.de"),
SZ_DE("shopzilla.de"),
SG_DE("spardeingeld.de");

private final String baseUrl;

Site(String baseUrl) {
this.baseUrl = baseUrl;
}

public String getBaseUrl() {
return baseUrl;
}
}



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

public class SubdomainAndPath {
private final String subdomain;
private final String path;
private final PageInfo pageinfo;

public SubdomainAndPath(String path) {
this("www", path);
}

public SubdomainAndPath(String subdomain, String path) {


this.subdomain = subdomain;
this.path = path;
this.pageinfo = new PageInfo(0,0,0);
}

public SubdomainAndPath (String subdomain, String path, int numberOfProductLinks, int numberOfSponsorLinks, int numberOfPaginations){
this.subdomain = subdomain;
this.path = path;
this.pageinfo = new PageInfo(numberOfProductLinks, numberOfSponsorLinks, numberOfPaginations);
}

public SubdomainAndPath (String path, int numberOfProductLinks, int numberOfSponsorLinks, int numberOfPaginations){
this("www", path, numberOfProductLinks, numberOfSponsorLinks, numberOfPaginations);
}


public String getSubdomain() {
return subdomain;
}

public String getPath() {
return path;
}

public PageInfo getPageinfo (){
return pageinfo;
}
}



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

package uk.co.shopzilla.qa.regression.configuration;
public enum TextIdentifier {
COBRAND,
GO_TO_STORE,
MATURE_WARNING,
MORE,
NEXT,
SL_SUFFIX
}


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

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

import java.awt.*;


public class AbstractPositionedPod implements PositionedPod {
protected final WebElement webElement;

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

@Override
public final boolean isAbove(PositionedPod other) {
if (!(webElement instanceof RenderedWebElement)) {
return true;
}

return ((RenderedWebElement) webElement).getLocation().y < other.getPosition().getY(); } @Override public final boolean isBelow(PositionedPod other) { if (!(webElement instanceof RenderedWebElement)) { return true; } return ((RenderedWebElement) webElement).getLocation().y > other.getPosition().getY();
}



@Override
public final boolean isLeftOf(PositionedPod other) {
if (!(webElement instanceof RenderedWebElement)) {
return true;
}

return ((RenderedWebElement) webElement).getLocation().x < other.getPosition().getX(); } @Override public final Position getPosition() { if (!(webElement instanceof RenderedWebElement)) { return Position.UNKNOWN; } final Point location = ((RenderedWebElement) webElement).getLocation(); return new Position(location.x, location.y); } } package uk.co.shopzilla.qa.regression.dsl; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; public class BreadCrumbsPod extends AbstractPositionedPod { public BreadCrumbsPod(WebElement webElement) { super(webElement); } public int getBreadCrumbsCount() { return webElement.findElements(By.tagName("a")).size(); } } package uk.co.shopzilla.qa.regression.dsl; import org.openqa.selenium.By; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebElement; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import java.util.List; public class FooterBanner extends AbstractPositionedPod{ public FooterBanner(WebElement webElement) { super(webElement); } public int isFooterBannerExist() { // System.out.println("\n The Text in Footer banner is : " +webElement.getText() + "\n"); System.out.println("\n The name of footer banner is 'search_bar' & = ' " + webElement.getAttribute("id")+ "' Found at run time the"); // System.out.println(wbelmnt.get(0)); // System.out.println("IS : FooterBanner exist with count : " +webElement.findElements(By.id("search_bar")).size()); // Selenium.IsElementPresent(); // SystemwebElement.findElements(By.id("search_bar")); return 1; } public void isEditBoxinBanner(){ //System.out.println("\n webElement.findElements(By.tagNameinput " + webElement.findElements(By.tagName("input"))); //System.out.println("\n input type size : " + webElement.findElements(By.tagName("input")).size()); // List wbElement= webElement.findElements(By.tagName("input"));

// System.out.println("wbElement.size() is = " + wbElement.size());
int flag=0;
for(WebElement element : webElement.findElements(By.tagName("input"))) {


// System.out.println("element.getTagName()" + element.getTagName());
// System.out.println("element.getText()" + element.getText());
// System.out.println("element.getText()" + element.findElement(By.name("keyword")));
// System.out.println("element.getAttribute(name)" + element.getAttribute("name"));

if(element.getAttribute("name").equalsIgnoreCase("keyword")){

// System.out.println("\n Banner pod EditBox Exist which having search keyword in that");

System.out.println("\n Banner pod EditBox Exist which having search keyword :: \"" + element.getValue()+ "\" in that");


flag=1;
break;
}

}


if(flag==1){


System.out.println(" PASS: the edit box in banner Pod \n" );

}

else {

System.out.println(" FAIL: the edit box NOT in banner Pod \n");
}


}
}


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


public enum FooterLink {
HOME("footer_home"),
ABOUT("footer_about"),
PRIVACY_POLICY("footer_privacy_policy"),
USER_AGREEMENT("footer_user_agreement"),
SWEEPSTAKE("footer_sweepstake"),
PRESS("footer_press"),
JOBS("footer_jobs"),
SITEMAP("footer_sitemap"),
TOP_SEARCHES("footer_sitemap_topsearches"),
TOP_PRODUCTS("footer_sitemap_topproducts"),
RATINGS_GUIDE("footer_ratings_guide"),
NEWSLETTER("footer_newsletter"),
MERCHANT_LOGIN("footer_merchant_login"),
MERCHANT_LISTINGS("footer_merchant_listings"),
PRODUCT_REVIEWS("footer_product_reviews"),
RATINGS_AND_RESEARCH("footer_ratings_and_research"),
AFFILIATES("footer_affiliates"),
SZ_SOLUTIONS("footer_sz_solutions"),
;

private final String elementId;

private FooterLink(String elementId) {
this.elementId = elementId;
}

public String getElementId() {
return elementId;
}
}

Selenium 2 - Per page SZ selenium 2 Framework - with maven

Structure of the project:

Step1:
Create the following project

uk.co.shopzilla.qa.regression and create various package in it.

1. Configuration
2. Data
3. Dsl
4. 4test
5. Util
6. Verifiers

Step 2:
In configuration create classes
1. Configuration
2. Enviorment
3. Page Identifier
4. Page Info
5. Site
6. SubdomainAndPath
7. TextIdentifier

C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\configuration\Configuration.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\configuration\ConfigurationTest.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\configuration\Environment.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\configuration\PageIdentifier.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\configuration\PageInfo.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\configuration\Site.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\configuration\SubdomainAndPath.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\configuration\TextIdentifier.java

Step3:
In data put classes:
1. Configurations
2. Footer
3. Pages
4. Texts
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\data\Configurations.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\data\Footers.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\data\Pages.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\data\Texts.java


Step 4:
In DSL give other classes for link , POD specific application
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\AbstractPositionedPod.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\BreadCrumbsPod.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\FooterBanner.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\FooterLink.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\FooterPod.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\Home_page.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\Home_page_Element.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\Home_page_pod.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\HotCategoryPod.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\Item.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\Link.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\Page.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\PageRequest.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\PageRequestImpl.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\PaginationLink.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\Position.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\PositionedPod.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\ProductListPod.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\RedirectLink.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\RelatedSearchesContractedPod.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\RelatedSearchesPod.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\ScorchingProductPod.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\SponsoredLinksPod.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\dsl\With.java

Step 5
IN Test give the test class
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\test\Cool7ZTest.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\test\Cool8CTest.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\test\Cool8ETest.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\test\Cool8ITest.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\test\CoolTest.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\test\CoolTest2.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\test\Freq.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\test\Home_SZTest.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\test\Hot10JTest.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\test\Hot7STest.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\test\Hot7TTest.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\test\HotTest.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\test\MapExample.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\test\ScorchingNonCatTest.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\test\ScorchingTest.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\test\SetExample.java
C:\eu-regression-test\src\test\java\uk\co\shopzilla\qa\regression\test\SpecificTests.java

Step 6:
In Verifiers provide all the verifiers functions
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\verifiers\BreadCrumbsPodVerifier.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\verifiers\FooterBannerVerifier.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\verifiers\FooterPodVerifier.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\verifiers\HomePageVerifier.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\verifiers\HotCategoryPodVerifier.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\verifiers\MatureWarningVerifier.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\verifiers\ProductListPodVerifier.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\verifiers\RelatedSearchesContractedPodVerifier.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\verifiers\RelatedSearchesVerifier.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\verifiers\ScorchingProductPodVerifier.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\verifiers\SponsoredLinksPodVerifier.java

Step7: In framework provide the path of all Drivers
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\framework\ChromeDriverFactory.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\framework\Driver.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\framework\FirefoxWebDriverFactory.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\framework\HtmlUnitDriverFactory.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\framework\InternetExplorerDriverFactory.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\framework\WebDriverFactory.java

Step 8: Util provide interface for Page
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\util\PageTest.java
C:\eu-regression-test\src\main\java\uk\co\shopzilla\qa\regression\util\RegressionTester.java

Step 9: Library
Webdriver 2
TestNG
Maven

Step 9 POM file
Step 9 POM file replace and !!!> to >
Step 9 POM file replace !!! To and !!! to

!!!?xml version="1.0" encoding="UTF-8"?!!!
!!!project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"!!!
!!!modelVersion!!!4.0.0!!!/modelVersion!!!
!!!groupId!!!uk.co.shopzilla.qa!!!/groupId!!!
!!!artifactId!!!eu-regression-test!!!/artifactId!!!
!!!packaging!!!jar!!!/packaging!!!
!!!version!!!1.0-SNAPSHOT!!!/version!!!
!!!prerequisites!!!
!!!maven!!!2.2!!!/maven!!!
!!!/prerequisites!!!
!!!name!!!EU Regression Tests!!!/name!!!

!!!parent!!!
!!!artifactId!!!root!!!/artifactId!!!
!!!groupId!!!com.shopzilla.common!!!/groupId!!!
!!!version!!!1.12!!!/version!!!
!!!/parent!!!

!!!properties!!!
!!!webdriver.version!!!0.9.7376!!!/webdriver.version!!!
!!!/properties!!!

!!!scm!!!
!!!developerConnection!!!scm:git:ssh://git@git.shopzilla.com/qa/eu-regression-test!!!/developerConnection!!!
!!!/scm!!!

!!!dependencies!!!
!!!dependency!!!
!!!groupId!!!org.seleniumhq.webdriver!!!/groupId!!!
!!!artifactId!!!webdriver-common!!!/artifactId!!!
!!!version!!!${webdriver.version}!!!/version!!!
!!!/dependency!!!
!!!dependency!!!
!!!groupId!!!org.seleniumhq.webdriver!!!/groupId!!!
!!!artifactId!!!webdriver-htmlunit!!!/artifactId!!!
!!!version!!!${webdriver.version}!!!/version!!!
!!!/dependency!!!
!!!dependency!!!
!!!groupId!!!org.seleniumhq.webdriver!!!/groupId!!!
!!!artifactId!!!webdriver-firefox!!!/artifactId!!!
!!!version!!!${webdriver.version}!!!/version!!!
!!!/dependency!!!
!!!dependency!!!
!!!groupId!!!org.seleniumhq.webdriver!!!/groupId!!!
!!!artifactId!!!webdriver-ie!!!/artifactId!!!
!!!version!!!${webdriver.version}!!!/version!!!
!!!/dependency!!!
!!!dependency!!!
!!!groupId!!!org.seleniumhq.webdriver!!!/groupId!!!
!!!artifactId!!!webdriver-chrome!!!/artifactId!!!
!!!version!!!${webdriver.version}!!!/version!!!
!!!/dependency!!!
!!!dependency!!!
!!!groupId!!!com.google.guava!!!/groupId!!!
!!!artifactId!!!guava!!!/artifactId!!!
!!!version!!!r08!!!/version!!!
!!!/dependency!!!
!!!dependency!!!
!!!groupId!!!log4j!!!/groupId!!!
!!!artifactId!!!log4j!!!/artifactId!!!
!!!version!!!1.2.15!!!/version!!!
!!!/dependency!!!
!!!dependency!!!
!!!groupId!!!org.testng!!!/groupId!!!
!!!artifactId!!!testng!!!/artifactId!!!
!!!version!!!5.12.1!!!/version!!!
!!!/dependency!!!
!!!dependency!!!
!!!groupId!!!org.mockito!!!/groupId!!!
!!!artifactId!!!mockito-all!!!/artifactId!!!
!!!version!!!1.8.5!!!/version!!!
!!!/dependency!!!
!!!/dependencies!!!


!!!build!!!
!!!defaultGoal!!!test!!!/defaultGoal!!!
!!!pluginManagement!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!version!!!2.5!!!/version!!!
!!!configuration!!!
!!!parallel!!!true!!!/parallel!!!
!!!threadCount!!!10!!!/threadCount!!!
!!!environmentVariables!!!
!!!host.override!!!${host.override}!!!/host.override!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/pluginManagement!!!
!!!/build!!!

!!!profiles!!!
!!!profile!!!
!!!id!!!env-dev!!!/id!!!
!!!activation!!!
!!!activeByDefault!!!true!!!/activeByDefault!!!
!!!property!!!
!!!name!!!env!!!/name!!!
!!!value!!!dev!!!/value!!!
!!!/property!!!
!!!/activation!!!
!!!/profile!!!

!!!!-- site-selection profiles --!!!
!!!profile!!!
!!!id!!!BR_GB!!!/id!!!
!!!build!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!configuration!!!
!!!environmentVariables!!!
!!!BR_GB!!!true!!!/BR_GB!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/build!!!
!!!/profile!!!
!!!profile!!!
!!!id!!!LW_GB!!!/id!!!
!!!build!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!configuration!!!
!!!environmentVariables!!!
!!!LW_GB!!!true!!!/LW_GB!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/build!!!
!!!/profile!!!
!!!profile!!!
!!!id!!!SZ_GB!!!/id!!!
!!!build!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!configuration!!!
!!!environmentVariables!!!
!!!SZ_GB!!!true!!!/SZ_GB!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/build!!!
!!!/profile!!!
!!!profile!!!
!!!id!!!PC_FR!!!/id!!!
!!!build!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!configuration!!!
!!!environmentVariables!!!
!!!PC_FR!!!true!!!/PC_FR!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/build!!!
!!!/profile!!!
!!!profile!!!
!!!id!!!SZ_FR!!!/id!!!
!!!build!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!configuration!!!
!!!environmentVariables!!!
!!!SZ_FR!!!true!!!/SZ_FR!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/build!!!
!!!/profile!!!
!!!profile!!!
!!!id!!!BR_DE!!!/id!!!
!!!build!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!configuration!!!
!!!environmentVariables!!!
!!!BR_DE!!!true!!!/BR_DE!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/build!!!
!!!/profile!!!
!!!profile!!!
!!!id!!!SG_DE!!!/id!!!
!!!build!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!configuration!!!
!!!environmentVariables!!!
!!!SG_DE!!!true!!!/SG_DE!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/build!!!
!!!/profile!!!
!!!profile!!!
!!!id!!!SZ_DE!!!/id!!!
!!!build!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!configuration!!!
!!!environmentVariables!!!
!!!SZ_DE!!!true!!!/SZ_DE!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/build!!!
!!!/profile!!!
!!!profile!!!
!!!id!!!all-sites!!!/id!!!
!!!build!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!configuration!!!
!!!environmentVariables!!!
!!!BR_GB!!!true!!!/BR_GB!!!
!!!SZ_GB!!!true!!!/SZ_GB!!!
!!!LW_GB!!!true!!!/LW_GB!!!
!!!SZ_FR!!!true!!!/SZ_FR!!!
!!!PC_FR!!!true!!!/PC_FR!!!
!!!BR_DE!!!true!!!/BR_DE!!!
!!!SG_DE!!!true!!!/SG_DE!!!
!!!SZ_DE!!!true!!!/SZ_DE!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/build!!!
!!!/profile!!!

!!!!-- environment selection profiles --!!!
!!!profile!!!
!!!id!!!stage!!!/id!!!
!!!build!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!configuration!!!
!!!environmentVariables!!!
!!!environment!!!STAGE!!!/environment!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/build!!!
!!!/profile!!!
!!!profile!!!
!!!id!!!production!!!/id!!!
!!!build!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!configuration!!!
!!!environmentVariables!!!
!!!environment!!!PRODUCTION!!!/environment!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/build!!!
!!!/profile!!!
!!!profile!!!
!!!id!!!master!!!/id!!!
!!!build!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!configuration!!!
!!!environmentVariables!!!
!!!environment!!!MASTER!!!/environment!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/build!!!
!!!/profile!!!
!!!profile!!!
!!!id!!!branch!!!/id!!!
!!!build!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!configuration!!!
!!!environmentVariables!!!
!!!environment!!!BRANCH!!!/environment!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/build!!!
!!!/profile!!!
!!!profile!!!
!!!id!!!localhost!!!/id!!!
!!!properties!!!
!!!host.override!!!http://localhost:8085!!!/host.override!!!
!!!/properties!!!
!!!/profile!!!

!!!!-- driver selection profiles --!!!
!!!profile!!!
!!!id!!!htmlUnit!!!/id!!!
!!!build!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!configuration!!!
!!!environmentVariables!!!
!!!HTMLUNIT!!!true!!!/HTMLUNIT!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/build!!!
!!!/profile!!!
!!!profile!!!
!!!id!!!firefox!!!/id!!!
!!!build!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!configuration!!!
!!!environmentVariables!!!
!!!FIREFOX!!!true!!!/FIREFOX!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/build!!!
!!!/profile!!!
!!!profile!!!
!!!id!!!ie!!!/id!!!
!!!build!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!configuration!!!
!!!environmentVariables!!!
!!!IE!!!true!!!/IE!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/build!!!
!!!/profile!!!
!!!profile!!!
!!!id!!!chrome!!!/id!!!
!!!build!!!
!!!plugins!!!
!!!plugin!!!
!!!artifactId!!!maven-surefire-plugin!!!/artifactId!!!
!!!configuration!!!
!!!environmentVariables!!!
!!!CHROME!!!true!!!/CHROME!!!
!!!/environmentVariables!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/build!!!
!!!/profile!!!



!!!/profiles!!!

!!!!--
For more information on publishing project documentation for a project, visit:
http://wiki.shopzilla.com/index.php?title=Open_Source
--!!!
!!!reporting!!!
!!!plugins!!!
!!!plugin!!!
!!!groupId!!!org.apache.maven.plugins!!!/groupId!!!
!!!artifactId!!!maven-project-info-reports-plugin!!!/artifactId!!!
!!!version!!!2.2!!!/version!!!
!!!inherited!!!true!!!/inherited!!!
!!!reportSets!!!
!!!reportSet!!!
!!!reports!!!
!!!report!!!index!!!/report!!!
!!!/reports!!!
!!!/reportSet!!!
!!!reportSet!!!
!!!id!!!sunlink!!!/id!!!
!!!reports!!!
!!!report!!!javadoc!!!/report!!!
!!!/reports!!!
!!!inherited!!!true!!!/inherited!!!
!!!configuration!!!
!!!links!!!
!!!link!!!http://java.sun.com/javase/6/docs/api/!!!/link!!!
!!!/links!!!
!!!/configuration!!!
!!!/reportSet!!!
!!!/reportSets!!!
!!!/plugin!!!
!!!plugin!!!
!!!artifactId!!!maven-checkstyle-plugin!!!/artifactId!!!
!!!version!!!2.5!!!/version!!!
!!!/plugin!!!
!!!plugin!!!
!!!artifactId!!!maven-docck-plugin!!!/artifactId!!!
!!!version!!!1.0!!!/version!!!
!!!/plugin!!!
!!!plugin!!!
!!!artifactId!!!maven-javadoc-plugin!!!/artifactId!!!
!!!version!!!2.7!!!/version!!!
!!!configuration!!!
!!!bottom!!!!!!![CDATA[Copyright © {inceptionYear}-{currentYear} Shopzilla.com. All Rights Reserved.]]!!!!!!/bottom!!!
!!!links!!!
!!!link!!!http://java.sun.com/javase/6/docs/api/!!!/link!!!
!!!/links!!!
!!!linksource!!!true!!!/linksource!!!
!!!quiet!!!true!!!/quiet!!!
!!!show!!!private!!!/show!!!
!!!sourcepath!!!${basedir}/src/main/java;${basedir}/src/test/java!!!/sourcepath!!!
!!!/configuration!!!
!!!/plugin!!!
!!!plugin!!!
!!!artifactId!!!maven-jxr-plugin!!!/artifactId!!!
!!!version!!!2.2!!!/version!!!
!!!/plugin!!!
!!!plugin!!!
!!!artifactId!!!maven-pmd-plugin!!!/artifactId!!!
!!!version!!!2.5!!!/version!!!
!!!configuration!!!
!!!targetJdk!!!1.6!!!/targetJdk!!!
!!!/configuration!!!
!!!/plugin!!!
!!!plugin!!!
!!!groupId!!!org.codehaus.mojo!!!/groupId!!!
!!!artifactId!!!cobertura-maven-plugin!!!/artifactId!!!
!!!version!!!2.4!!!/version!!!
!!!/plugin!!!
!!!plugin!!!
!!!groupId!!!org.codehaus.mojo!!!/groupId!!!
!!!artifactId!!!findbugs-maven-plugin!!!/artifactId!!!
!!!version!!!2.3.1!!!/version!!!
!!!configuration!!!
!!!threshold!!!Normal!!!/threshold!!!
!!!/configuration!!!
!!!/plugin!!!
!!!/plugins!!!
!!!/reporting!!!

!!!repositories!!!
!!!repository!!!
!!!id!!!internal-releases!!!/id!!!
!!!url!!!http://jvlinux.shopzilla.com:2099/nexus/content/repositories/internal-releases!!!/url!!!
!!!releases!!!!!!enabled!!!true!!!/enabled!!!!!!/releases!!!
!!!snapshots!!!!!!enabled!!!false!!!/enabled!!!!!!/snapshots!!!
!!!/repository!!!

!!!repository!!!
!!!id!!!internal-snapshots!!!/id!!!
!!!url!!!http://jvlinux.shopzilla.com:2099/nexus/content/repositories/internal-snapshots!!!/url!!!
!!!releases!!!!!!enabled!!!false!!!/enabled!!!!!!/releases!!!
!!!snapshots!!!
!!!enabled!!!true!!!/enabled!!!
!!!/snapshots!!!
!!!/repository!!!
!!!/repositories!!!

!!!/project!!!


Code of all classes in next post !


How to run:

Objectives

The regression test pack should:

  • do functional tests with the aim of preventing money-losing functional bugs, but not aimed at finding display-type bugs.
  • be robust in the face of cosmetic change, minimising the maintenance overhead and false negatives.
  • be possible to trigger with a single click or automatically from for instance Hudson.
  • run quickly (probably < 5 minutes) so that it is not only feasible to run them as for instance nightly jobs.
  • be easy to modify for developers, although they should be owned by QA.
  • have a maven-managed dependency between the site and the tests, so that we can ensure that test versions are synched with site versions.
  • be possible to parameterise so that the same tests can be run for all EU sites and with different combinations of browser versions, operating systems, etc.

Tools Evaluation

To date, we've been using Selenium as the framework for regression testing, both in the EU and the US. There are, however, many alternatives out there. We've taken a brief look at the following:

We've also been considering which language to use for controlling the automation. Since we have at least one QA and all developers being most proficient in Java, and since most of the tools are written in Java (even though tools like Selenium can be automated via Perl, etc.), we feel Java is the most suitable language.

The most promising tool is Selenium 2, even though it is only in the alpha stage. It has a really nice API that supports creating a DSL (http://webdriver.googlecode.com/svn/wiki/WebDriver_JAX_2008_Slides.pdf). This has the advantage of making the tests very readable at a high level while at the same time forcing the details of how an element on a page is identified into a thinner, reusable layer. An early sketch of what a test class can look like is (note how nothing of the actual tool used much less the HTML format of the page is propagated to this level - if we can maintain that, we can change web testing tools if Selenium 2 turns out not to be stable enough):

@RunWith(Parameterized.class)
public class HotTest {
private final Configuration configuration;

public HotTest(Configuration configuration) {
this.configuration = configuration;
}

@Test
public void testHot8BWalkin() throws Exception {
PageRequest request = configuration.getHot8BRequest();

Page page = request.fetch(With.trafficSource("wlk"));

SponsoredLinksPodVerifier.verify(page.getSponsoredLinksPod());
}

@Test
public void testHot8BGgl() throws Exception {
PageRequest request = configuration.getHot8BRequest();

Page page = request.fetch(With.trafficSource("ggl"));

SponsoredLinksPodVerifier.verify(page.getTopSponsoredLinksPod());
SponsoredLinksPodVerifier.verify(page.getBottomSponsoredLinksPod());
}

@Test
public void testHot8BMatureWarningNotAgreed() throws Exception {
PageRequest request = configuration.getHotMature8BRequest();

Page page = request.fetch(With.matureAgreed(false));

MatureWarningVerifier.assertIsWarning(page);
}

@Test
public void testHot8BMatureWarningAgreed() throws Exception {
PageRequest request = configuration.getHotMature8BRequest();

Page page = request.fetch(With.matureAgreed(true));

// check that the page is a regular hot page
SponsoredLinksPodVerifier.verify(page.getSponsoredLinksPod());

}

@Parameterized.Parameters
public static List getConfigurations() {
return Configurations.enabledConfigurations();
}

}

Solution Outline

This section lists some principles that are probably important to get the solution to meet the goals of being robust, parameterisable and easily modifiable by developers and QA both.

  • DSL: we should create a domain-specific language layer for the tests. This layer should define entities such as SponsoredLinksPods, ProductListPods and probably also ServiceInvocations. It creates a language that test flows and assertions can be written in, but doesn't contain any assertions or verifications in itself. It is the only place where direct interaction with the DOM is allowed.
  • Reusable tests: because we often reuse pods, we will probably want to be able to reuse tests. So, for instance, we should be able to do the same checks for SponsoredLinksPods in all Hot pages. Note that this kind of reuse is different from the DSL.
  • Injecting the WebDriver into the tests in order to enable running the same set of tests with different parameters.
  • Injecting parameters for country code and brand in order to enable running the same tests for different sites - note that it should ideally be possible to disable some tests for some sites, so that sites that don't do SLs can avoid testing for those, etc.


Running the tests

To run the tests, you need to check them out from their Git repository: http://git.shopzilla.com/cgit/cgit.cgi/qa/eu-regression-test/. You will also need an installation of Maven (preferably version 3.0, 2.2 as a minimum).

Once you've checked them out, change to the root directory of the regression pack and issue the following command:

mvn -PBR_GB

The tests should be executed against www.stage.bizrate.co.uk.

The following parameters can be used (by prepending -P to the strings listed below):

  1. Sites (you can specify many of these, tests will fail if none is specified)
    1. BR_GB
    2. SZ_GB
    3. LW_GB
    4. PC_FR
    5. SZ_FR
    6. BR_DE
    7. SG_DE
    8. SZ_DE
    9. all-sites (means, surprisingly, all the above)
  2. Environments (only one of these is valid - if none is specified, then 'stage' will be used)
    1. stage (will send requests to www.stage.)
    2. master (will send requests to www.master.)
    3. branch
    4. production
  1. Browsers (you can specify many of these, htmlUnit will be used if none is specified)
    1. htmlUnit
    2. firefox
    3. ie
    4. chrome

Here's a more complicated example that tests PC FR and BR GB against the master QA environment using Firefox and IE:

mvn -PPC_FR -PBR_GB -Pmaster -Pfirefox -Pie

or

mvn -PPC_FR -PBR_GB -Pproduction -Pfirefox -Pie

You can also select that only specific test class should be executed using the -Dtest=XX parameter of the Maven Surefire plugin (see http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#test):

mvn -PBR_GB -Dtest=HotTest

If desired, it is possible to override the default mechanism of specifying an environment to run the tests against, and instead specify a particular host that you want to test against. This is done by adding the flag '-Dhost.override=YOURHOST' to the command. With this setting, you can only specify a single site, as the test framework wouldn't know how to generate URLs for multiple sites running on a single host. Here's an example of targetting a single host:

mvn -PSZ_DE -Dhost.override=http://localhost:8085

Test Reports

TestNG generates reports in the target/surefire-reports directory, there is an index.html file there that gives you a report on what worked and not.


Hudson build

There is presently a Hudson build that runs the (simple) current test pack against PC_FR, SZ_DE and SZ_GB in staging every three hours: http://hudson001.shopzilla.laxhq:8420/hudson/view/All/job/eu-regression-test/