Updates to the Selenium WebDriver tests.

This commit is contained in:
Graham Triggs 2016-01-15 20:23:27 +00:00
parent 0236f3c42d
commit 41a7ed3682
6 changed files with 235 additions and 6 deletions

View file

@ -8,8 +8,10 @@ import org.vivoweb.vivo.selenium.DriverFactory;
import org.vivoweb.vivo.selenium.VIVOSuite; import org.vivoweb.vivo.selenium.VIVOSuite;
import org.vivoweb.vivo.selenium.tests.CreateActivity; import org.vivoweb.vivo.selenium.tests.CreateActivity;
import org.vivoweb.vivo.selenium.tests.CreateCourses; import org.vivoweb.vivo.selenium.tests.CreateCourses;
import org.vivoweb.vivo.selenium.tests.CreateEquipment;
import org.vivoweb.vivo.selenium.tests.CreateEvent; import org.vivoweb.vivo.selenium.tests.CreateEvent;
import org.vivoweb.vivo.selenium.tests.CreateOrganization; import org.vivoweb.vivo.selenium.tests.CreateOrganization;
import org.vivoweb.vivo.selenium.tests.CreateTopic;
import org.vivoweb.vivo.selenium.tests.DeleteActivities; import org.vivoweb.vivo.selenium.tests.DeleteActivities;
import org.vivoweb.vivo.selenium.tests.DeleteCourses; import org.vivoweb.vivo.selenium.tests.DeleteCourses;
import org.vivoweb.vivo.selenium.tests.DeleteEquipment; import org.vivoweb.vivo.selenium.tests.DeleteEquipment;
@ -27,6 +29,8 @@ import org.vivoweb.vivo.selenium.tests.RebuildSearchIndex;
CreateCourses.class, CreateCourses.class,
CreateActivity.class, CreateActivity.class,
CreateEvent.class, CreateEvent.class,
CreateTopic.class,
CreateEquipment.class,
DeleteActivities.class, DeleteActivities.class,
DeleteCourses.class, DeleteCourses.class,
DeleteLocations.class, DeleteLocations.class,

View file

@ -28,7 +28,7 @@ public class AbstractVIVOSeleniumTest extends AbstractSeleniumTest {
element.sendKeys(text); element.sendKeys(text);
try { try {
Thread.sleep(500); Thread.sleep(1000);
autoComplete = driver.findElement(By.className("ui-autocomplete")); autoComplete = driver.findElement(By.className("ui-autocomplete"));
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
@ -42,7 +42,7 @@ public class AbstractVIVOSeleniumTest extends AbstractSeleniumTest {
if (autoComplete == null) { if (autoComplete == null) {
element.clear(); element.clear();
if (count > 10) { if (count > 5) {
throw new NoSuchElementException("Auto complete is not visible"); throw new NoSuchElementException("Auto complete is not visible");
} }

View file

@ -0,0 +1,131 @@
package org.vivoweb.vivo.selenium.tests;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
public class CreateEquipment extends AbstractVIVOSeleniumTest {
@Test
public void createEquipment() {
deleteAllVisibleCookies();
open("/");
assertTitle("VIVO");
vivoLogIn("testAdmin@cornell.edu", "Password");
clickAndWait(By.linkText("Site Admin"));
assertTitle("VIVO Site Administration");
verifyTextPresent("Data Input");
selectByLabel(By.id("VClassURI"), "Equipment (vivo)");
clickAndWait(By.xpath("//input[@value='Add individual of this class']"));
assertTitle("Edit");
verifyTextPresent("Create a new Equipment");
clickAndWait(By.linkText("Cancel"));
assertTitle("VIVO Site Administration");
verifyTextPresent("Data Input");
selectByLabel(By.id("VClassURI"), "Equipment (vivo)");
clickAndWait(By.xpath("//input[@value='Add individual of this class']"));
assertTitle("Edit");
verifyTextPresent("Create a new Equipment");
clickAndWait(By.id("submit"));
assertTitle("Edit");
verifyTextPresent("Please enter a value in the Name field.");
type(By.id("label"), "Primate Feeder");
clickAndWait(By.id("submit"));
assertTitle("Primate Feeder");
clickAndWait(By.xpath("//div[@id='wrapper-content']/ul/li[8]"));
clickAndWait(By.xpath("//h3[@id='equipmentFor']/a/img"));
assertTitle("Edit");
verifyTextPresent("If you don't find the appropriate entry on the selection list above:");
selectByLabel(By.id("objectVar"), "Primate Research Laboratory (Laboratory)");
clickAndWait(By.id("submit"));
assertTitle("Primate Feeder");
clickAndWait(By.cssSelector("a.add-RO_0001025 > img.add-individual"));
assertTitle("Edit");
verifyTextPresent("If you don't find the appropriate entry on the selection list above:");
selectByLabel(By.id("typeOfNew"), "Facility (vivo)");
clickAndWait(By.id("offerCreate"));
assertTitle("Edit");
verifyTextPresent("Create \"housed in facility\" entry for Primate Feeder");
type(By.id("label"), "Primate Research Lab Room 123");
clickAndWait(By.id("submit"));
assertTitle("Primate Feeder");
clickAndWait(By.xpath("//h3[@id='freetextKeyword']/a/img"));
assertTitle("Edit");
verifyTextPresent("Add new entry for: keywords");
typeTinyMCE("Animal Diet");
clickAndWait(By.id("submit"));
clickAndWait(By.linkText("Primate Research Lab Room 123"));
assertTitle("Primate Research Lab Room 123");
clickAndWait(By.xpath("(//img[@alt='add'])[3]"));
assertTitle("Edit");
selectByLabel(By.id("objectVar"), "Primate Heart Health (Service)");
clickAndWait(By.id("submit"));
assertTitle("Primate Research Lab Room 123");
clickAndWait(By.xpath("(//img[@alt='add'])[4]"));
assertTitle("Edit");
selectByLabel(By.id("objectVar"), "Primate University of America (University)");
clickAndWait(By.id("submit"));
assertTitle("Primate Research Lab Room 123");
clickAndWait(By.xpath("(//img[@alt='add'])[5]"));
assertTitle("Edit");
selectByLabel(By.id("objectVar"), "Primate Health Check (Event)");
clickAndWait(By.id("submit"));
assertTitle("Primate Research Lab Room 123");
clickAndWait(By.cssSelector("a.add-BFO_0000050 > img.add-individual"));
assertTitle("Edit");
vivoAutoCompleteSelect(By.id("object"), "United State", Keys.ARROW_DOWN);
clickAndWait(By.id("submit"));
assertTitle("Primate Research Lab Room 123");
verifyElementPresent(By.linkText("Primate Feeder"));
verifyElementPresent(By.linkText("Primate Heart Health"));
verifyElementPresent(By.linkText("Primate University of America"));
verifyElementPresent(By.linkText("Primate Health Check"));
verifyElementPresent(By.linkText("United States of America"));
vivoLogOut();
}
}

View file

@ -0,0 +1,94 @@
package org.vivoweb.vivo.selenium.tests;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
public class CreateTopic extends AbstractVIVOSeleniumTest {
@Test
public void createTopic() {
deleteAllVisibleCookies();
open("/");
assertTitle("VIVO");
vivoLogIn("testAdmin@cornell.edu", "Password");
clickAndWait(By.linkText("Site Admin"));
assertTitle("VIVO Site Administration");
verifyTextPresent("Data Input");
selectByLabel(By.id("VClassURI"), "Concept (skos)");
clickAndWait(By.xpath("//input[@value='Add individual of this class']"));
assertTitle("Edit");
verifyTextPresent("Create a new Concept");
clickAndWait(By.linkText("Cancel"));
assertTitle("VIVO Site Administration");
selectByLabel(By.id("VClassURI"), "Concept (skos)");
clickAndWait(By.xpath("//input[@value='Add individual of this class']"));
assertTitle("Edit");
verifyTextPresent("Create a new Concept");
clickAndWait(By.id("submit"));
assertTitle("Edit");
verifyTextPresent("Please enter a value in the Name field.");
type(By.id("label"), "Primate Health");
clickAndWait(By.id("submit"));
assertTitle("Primate Health");
clickAndWait(By.cssSelector("li.nonSelectedGroupTab.clickable"));
clickAndWait(By.xpath("//h3[@id='broader']/a/img"));
assertTitle("Edit");
verifyTextPresent("If you don't find the appropriate entry on the selection list above:");
selectByLabel(By.id("objectVar"), "Animal Health");
clickAndWait(By.id("submit"));
assertTitle("Primate Health");
clickAndWait(By.xpath("//h3[@id='narrower']/a/img"));
assertTitle("Edit");
verifyTextPresent("If you don't find the appropriate entry on the selection list above:");
clickAndWait(By.id("offerCreate"));
assertTitle("Edit");
verifyTextPresent("Create \"narrower concept\" entry for Primate Health");
type(By.id("label"), "Primate Diet");
clickAndWait(By.id("submit"));
assertTitle("Primate Health");
clickAndWait(By.xpath("//h3[@id='related']/a/img"));
assertTitle("Edit");
verifyTextPresent("If you don't find the appropriate entry on the selection list above:");
clickAndWait(By.id("offerCreate"));
assertTitle("Edit");
verifyTextPresent("Create \"related concept\" entry for Primate Health");
type(By.id("label"), "Ape Health");
clickAndWait(By.id("submit"));
assertTitle("Primate Health");
verifyElementPresent(By.linkText("Animal Health"));
verifyElementPresent(By.linkText("Primate Diet"));
verifyElementPresent(By.linkText("Ape Health"));
vivoLogOut();
}
}

View file

@ -23,7 +23,7 @@ public class DeleteEquipment extends AbstractVIVOSeleniumTest {
assertTitle("Portable Primate Habitat"); assertTitle("Portable Primate Habitat");
vivoDeleteIndividual(); vivoDeleteIndividual();
/* /* From CreateEquipment */
clickAndWait(By.linkText("Equipment")); clickAndWait(By.linkText("Equipment"));
assertTitle("Equipment"); assertTitle("Equipment");
@ -31,7 +31,7 @@ public class DeleteEquipment extends AbstractVIVOSeleniumTest {
assertTitle("Primate Feeder"); assertTitle("Primate Feeder");
vivoDeleteIndividual(); vivoDeleteIndividual();
*/ /* */
vivoLogOut(); vivoLogOut();
} }

View file

@ -57,7 +57,7 @@ public class DeleteResearch extends AbstractVIVOSeleniumTest {
vivoDeleteIndividual(); vivoDeleteIndividual();
/* */ /* */
/* /* From CreateTopic */
clickAndWait(By.linkText("Index")); clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents"); assertTitle("Index of Contents");
@ -90,7 +90,7 @@ public class DeleteResearch extends AbstractVIVOSeleniumTest {
assertTitle("Primate Health"); assertTitle("Primate Health");
vivoDeleteIndividual(); vivoDeleteIndividual();
*/ /* */
/* From CreateActivity */ /* From CreateActivity */
clickAndWait(By.linkText("Index")); clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents"); assertTitle("Index of Contents");