Skip to content

Commit

Permalink
Merge pull request #186 from dickschoeller/181-dev-selenium-test
Browse files Browse the repository at this point in the history
Resolves #181 -	selenium test of development
  • Loading branch information
dickschoeller committed Feb 3, 2017
2 parents 77ea92a + 15c410b commit 0ca6d9f
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Check it out by perusing [my genealogy database](http://www.schoellerfamily.org/
| Branch | Jenkins | Travis | Coverage | Dependencies | Selenium |
| :--- | :--- | :--- | :--- | :--- | :--- |
| Master | [![Build Status](http://www.schoellerfamily.org/jenkins/buildStatus/icon?job=gedbrowser)](http://www.schoellerfamily.org/jenkins/job/gedbrowser/) | [![Build Status](https://api.travis-ci.org/dickschoeller/gedbrowser.svg?branch=master)](https://travis-ci.org/dickschoeller/gedbrowser) | [![Coverage Status](https://coveralls.io/repos/github/dickschoeller/gedbrowser/badge.svg?branch=master)](https://coveralls.io/github/dickschoeller/gedbrowser?branch=master) | [![Dependency Status](https://www.versioneye.com/user/projects/5875a8c4fff5dc0039db0d10/badge.svg)](https://www.versioneye.com/user/projects/5875a8c4fff5dc0039db0d10?child=summary#tab-dependencies) | [![Selenium Test Status](http://www.schoellerfamily.org/jenkins/buildStatus/icon?job=gedbrowser-selenium)](http://www.schoellerfamily.org/jenkins/job/gedbrowser-selenium) |
| Development | [![Build Status](http://www.schoellerfamily.org/jenkins/buildStatus/icon?job=gedbrowser-development)](http://www.schoellerfamily.org/jenkins/job/gedbrowser-development/) | [![Build Status](https://api.travis-ci.org/dickschoeller/gedbrowser.svg?branch=development)](https://travis-ci.org/dickschoeller/gedbrowser) | [![Coverage Status](https://coveralls.io/repos/github/dickschoeller/gedbrowser/badge.svg?branch=development)](https://coveralls.io/github/dickschoeller/gedbrowser?branch=development) |[![Dependency Status](https://www.versioneye.com/user/projects/5894a1e327d3c300443034fe/badge.svg)](https://www.versioneye.com/user/projects/5894a1e327d3c300443034fe?child=summary#tab-dependencies)
| Development | [![Build Status](http://www.schoellerfamily.org/jenkins/buildStatus/icon?job=gedbrowser-development)](http://www.schoellerfamily.org/jenkins/job/gedbrowser-development/) | [![Build Status](https://api.travis-ci.org/dickschoeller/gedbrowser.svg?branch=development)](https://travis-ci.org/dickschoeller/gedbrowser) | [![Coverage Status](https://coveralls.io/repos/github/dickschoeller/gedbrowser/badge.svg?branch=development)](https://coveralls.io/github/dickschoeller/gedbrowser?branch=development) |[![Dependency Status](https://www.versioneye.com/user/projects/5894a1e327d3c300443034fe/badge.svg)](https://www.versioneye.com/user/projects/5894a1e327d3c300443034fe?child=summary#tab-dependencies) | [![Selenium Test Status](http://www.schoellerfamily.org/jenkins/buildStatus/icon?job=gedbrowser-development-selenium)](http://www.schoellerfamily.org/jenkins/job/gedbrowser-development-selenium) |
| Pull Request | [![Build Status](http://www.schoellerfamily.org/jenkins/buildStatus/icon?job=gedbrowser-pull)](http://www.schoellerfamily.org/jenkins/job/gedbrowser-pull/) | [![Build Status](https://api.travis-ci.org/dickschoeller/gedbrowser.svg)](https://travis-ci.org/dickschoeller/gedbrowser) | [![Coverage Status](https://coveralls.io/repos/github/dickschoeller/gedbrowser/badge.svg)](https://coveralls.io/github/dickschoeller/gedbrowser) |

## Getting started
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ public class GedBrowserBasicTest {
/** Long timeout. */
private static final int LONG_TIMEOUT = 5;

/** */
private final String host =
System.getProperty("selenium.host", "localhost");

/** */
private final String port =
System.getProperty("selenium.port", "8080");

// FIXME IE driving, Safari driving, Mobile driving

Expand Down Expand Up @@ -199,7 +206,7 @@ private boolean childNavigationExercise(final WebDriver driver,

// Matthias
PersonPage currentPerson = new PersonPage(driver, "I180", null,
waiter);
waiter, baseUrl());
currentPerson.open();
assertEquals("Person ID mismatch", "I180", currentPerson.getId());
assertEquals("Person failed check", "", currentPerson.check());
Expand Down Expand Up @@ -239,7 +246,7 @@ private boolean fathersNavigationExercise(final WebDriver driver,

// Grandpop
PersonPage currentPerson = new PersonPage(driver, "I11", null,
waiter);
waiter, baseUrl());
currentPerson.open();
assertEquals("Person ID mismatch", "I11", currentPerson.getId());
assertEquals("Person failed check", "", currentPerson.check());
Expand All @@ -249,8 +256,8 @@ private boolean fathersNavigationExercise(final WebDriver driver,
assertEquals("Person ID mismatch", "I32", currentPerson.getId());
assertEquals("Person failed check", "", currentPerson.check());

final SourcePage currentSource =
new SourcePage(driver, "S21", currentPerson, waiter);
final SourcePage currentSource = new SourcePage(driver, "S21",
currentPerson, waiter, baseUrl());
assertTrue("Title mismatch", currentSource.titleCheck());

currentPerson = currentSource.back();
Expand Down Expand Up @@ -286,7 +293,7 @@ private boolean mothersNavigationExercise(final WebDriver driver,

// Melissa
PersonPage currentPerson = new PersonPage(driver, "I11", null,
waiter);
waiter, baseUrl());
currentPerson.open();
assertEquals("Person ID mismatch", "I11", currentPerson.getId());
assertEquals("Person failed check", "", currentPerson.check());
Expand All @@ -306,4 +313,11 @@ private boolean mothersNavigationExercise(final WebDriver driver,
}
return true;
}

/**
* @return the base url string for connecting to the server
*/
private String baseUrl() {
return "http://" + this.host + ":" + this.port + "/gedbrowser/";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@
*/
public class PageBase {

// FIXME externalize base URL
/**
* Base URL string.
*/
public static final String BASE_URL =
"http://minitokyo.schoellerfamily.org:8082/gedbrowser/";

/** Associated Selenium driver. */
private final WebDriver driver;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ public final class PersonPage extends PageBase {
private final String id;
/** Previous page. */
private final PersonPage previous;
/** */
private final String baseUrl;

/**
* This class holds the expected values for a number of different
Expand Down Expand Up @@ -303,27 +305,47 @@ private GreatGreatGrandParentIds getLeaves() {

/**
* PageObject pattern for a page representing a person.
*
* @param driver this is the basic web driver
* @param id this is the ID of the person page being tested
* @param previous where we came from. Can be null
* @param waiter handles driver specific waits
* @param baseUrl the base URL from which all others derive
*/
public PersonPage(final WebDriver driver, final String id,
final PersonPage previous, final PageWaiter waiter) {
super(driver, url(id), waiter);
final PersonPage previous, final PageWaiter waiter,
final String baseUrl) {
super(driver, url(baseUrl, id), waiter);
this.id = id;
this.previous = previous;
this.baseUrl = baseUrl;
}

/**
* Build the URL string for this page.
*
* @param baseUrl the base from which all URLs are derived
* @param id the ID of the person on the page
* @return the built url string
*/
private static String url(final String id) {
return BASE_URL + "person?db=schoeller&id=" + id;
private static String url(final String baseUrl, final String id) {
return baseUrl + "person?db=schoeller&id=" + id;
}

/**
* Build the URL string for this page.
*
* @param iD the ID of the person on the page
* @return the built url string
*/
private String url(final String iD) {
return baseUrl() + "person?db=schoeller&id=" + iD;
}

/**
* @return the base URL
*/
private String baseUrl() {
return baseUrl;
}

/**
Expand Down Expand Up @@ -374,7 +396,8 @@ private PersonPage navigate(final WebElement element) {
final String url = getCurrentUrl();
final int index = url.indexOf("id=") + "id=".length();
final String idText = url.substring(index);
return new PersonPage(getDriver(), idText, this, getPageWaiter());
return new PersonPage(getDriver(), idText, this, getPageWaiter(),
baseUrl());
}

/**
Expand Down Expand Up @@ -533,9 +556,7 @@ public boolean childOneCheck() {
try {
final WebElement childLink = getChildLink(1, 1);
final String childUrl = childLink.getAttribute("href");
return childUrl.equals(
PersonPage.BASE_URL + "person?db=schoeller&id="
+ childIdString);
return childUrl.equals(url(childIdString));
} catch (NoSuchElementException e) {
return childIdString == null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class SourcePage extends PageBase {

/** Previous page, will always be a person page. */
private final PersonPage previous;
/** */
private final String baseUrl;

/**
* Relationship between ID and validation data.
Expand All @@ -34,17 +36,19 @@ public class SourcePage extends PageBase {

/**
* PageObject pattern for a page representing a person.
*
* @param driver this is the basic web driver
* @param id this is the ID of the person page being tested
* @param previous where we came from. Can be null.
* @param waiter handles driver specific waits
* @param baseUrl the base URL from which all others derive
*/
public SourcePage(final WebDriver driver, final String id,
final PersonPage previous, final PageWaiter waiter) {
super(driver, url(id), waiter);
final PersonPage previous, final PageWaiter waiter,
final String baseUrl) {
super(driver, url(baseUrl, id), waiter);
this.id = id;
this.previous = previous;
this.baseUrl = baseUrl;
final WebElement source = driver.findElements(By.linkText(id))
.get(0);
source.click();
Expand All @@ -53,11 +57,12 @@ public SourcePage(final WebDriver driver, final String id,
/**
* Build the URL string for this page.
*
* @param id the ID of the person on the page
* @param baseUrl the base from which all URLs are derived
* @param id the ID of the source on the page
* @return the built url string
*/
private static String url(final String id) {
return BASE_URL + "/source?db=schoeller&id=" + id;
private static String url(final String baseUrl, final String id) {
return baseUrl + "source?db=schoeller&id=" + id;
}

/**
Expand All @@ -81,4 +86,21 @@ public final boolean titleCheck() {
System.out.println("Page title is: " + getTitle());
return getTitle().equals(TITLE_MAP.get(id));
}

/**
* Build the URL string for this page.
*
* @param iD the ID of the person on the page
* @return the built url string
*/
public String url(final String iD) {
return baseUrl() + "person?db=schoeller&id=" + iD;
}

/**
* @return the base URL
*/
private String baseUrl() {
return baseUrl;
}
}

0 comments on commit 0ca6d9f

Please sign in to comment.