Updates to the Selenium WebDriver tests.

This commit is contained in:
Graham Triggs 2016-01-15 16:49:33 +00:00
parent c62844c4c1
commit 98a52c1306
9 changed files with 517 additions and 111 deletions

View file

@ -6,12 +6,15 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
import org.vivoweb.vivo.selenium.DriverFactory;
import org.vivoweb.vivo.selenium.VIVOSuite;
import org.vivoweb.vivo.selenium.tests.CreateActivity;
import org.vivoweb.vivo.selenium.tests.CreateCourses;
import org.vivoweb.vivo.selenium.tests.CreateEvent;
import org.vivoweb.vivo.selenium.tests.CreateOrganization;
import org.vivoweb.vivo.selenium.tests.DeleteActivities;
import org.vivoweb.vivo.selenium.tests.DeleteCourses;
import org.vivoweb.vivo.selenium.tests.DeleteEquipment;
import org.vivoweb.vivo.selenium.tests.DeleteEvents;
import org.vivoweb.vivo.selenium.tests.DeleteLocations;
import org.vivoweb.vivo.selenium.tests.DeleteOrganization;
import org.vivoweb.vivo.selenium.tests.DeleteResearch;
import org.vivoweb.vivo.selenium.tests.RebuildSearchIndex;
@ -22,8 +25,11 @@ import org.vivoweb.vivo.selenium.tests.RebuildSearchIndex;
RebuildSearchIndex.class,
CreateOrganization.class,
CreateCourses.class,
CreateActivity.class,
CreateEvent.class,
DeleteActivities.class,
DeleteCourses.class,
DeleteLocations.class,
DeleteEvents.class,
DeleteResearch.class,
DeleteEquipment.class,

View file

@ -44,6 +44,12 @@ public class AbstractSeleniumTest {
SeleniumUtils.navigate(driver, urlPart);
}
protected void pause(long timeout) {
try {
Thread.sleep(timeout);
} catch (InterruptedException e) {
}
}
protected void selectByLabel(By by, String label) {
Select select = new Select(driver.findElement(by));
select.selectByVisibleText(label);

View file

@ -34,21 +34,21 @@ public class AbstractVIVOSeleniumTest extends AbstractSeleniumTest {
throw new RuntimeException(e);
} catch (NoSuchElementException nse) {
System.out.println("Failure number: " + count);
element.clear();
// for (int i = 0; i < text.length(); i++) {
// element.sendKeys(Keys.BACK_SPACE);
// }
if (count > 10) {
throw nse;
}
if (autoComplete != null && !autoComplete.isDisplayed()) {
autoComplete = null;
}
if (autoComplete == null) {
element.clear();
if (count > 10) {
throw new NoSuchElementException("Auto complete is not visible");
}
count++;
}
// WebDriverWait wait = new WebDriverWait(driver, 5);
// WebElement autoComplete = wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("ui-autocomplete")));
}
if (keys != null && keys.length > 0) {
for (Keys key : keys) {
@ -71,6 +71,19 @@ public class AbstractVIVOSeleniumTest extends AbstractSeleniumTest {
}
}
protected void vivoDeleteIndividual(String category, String individual) {
clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents");
clickAndWait(By.linkText(category));
assertTitle(category);
clickAndWait(By.linkText(individual));
assertTitle(individual);
vivoDeleteIndividual();
}
protected void vivoDeleteIndividual() {
clickAndWait(By.linkText("Edit this individual"));
assertTitle("Individual Control Panel");

View file

@ -0,0 +1,211 @@
package org.vivoweb.vivo.selenium.tests;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
public class CreateActivity extends AbstractVIVOSeleniumTest {
@Test
public void createActivity() {
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"), "Grant (vivo)");
clickAndWait(By.xpath("//input[@value='Add individual of this class']"));
assertTitle("Edit");
verifyTextPresent("Create a new Grant");
clickAndWait(By.linkText("Cancel"));
assertTitle("VIVO Site Administration");
selectByLabel(By.id("VClassURI"), "Grant (vivo)");
clickAndWait(By.xpath("//input[@value='Add individual of this class']"));
assertTitle("Edit");
verifyTextPresent("Create a new Grant");
clickAndWait(By.id("submit"));
assertTitle("Edit");
verifyTextPresent("Please enter a value in the Name field.");
type(By.id("label"), "Primate Elderly Care");
clickAndWait(By.id("submit"));
assertTitle("Primate Elderly Care");
clickAndWait(By.xpath("//div[@id='wrapper-content']/ul/li[@groupname='viewAll']"));
assertTitle("Primate Elderly Care");
clickAndWait(By.cssSelector("a.add-relates > img.add-individual"));
assertTitle("Edit");
vivoAutoCompleteSelect(By.id("organization"), "primate colleges of the wor", Keys.ARROW_DOWN);
clickAndWait(By.cssSelector("input.submit"));
assertTitle("Primate Elderly Care");
clickAndWait(By.cssSelector("a.add-assignedBy > img.add-individual"));
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 Elderly Care");
clickAndWait(By.xpath("//h3[@id='abstract']/a/img"));
assertTitle("Edit");
verifyTextPresent("Add new entry for: abstract");
typeTinyMCE("Purpose of grant is to determine the appropriate environment, physical activity, and diet for primates as they age.");
clickAndWait(By.id("submit"));
assertTitle("Primate Elderly Care");
clickAndWait(By.xpath("//h3[@id='grantSubcontractedThrough']/a"));
assertTitle("Edit");
selectByLabel(By.id("objectVar"), "Primate Colleges of the World (Consortium)");
clickAndWait(By.id("submit"));
assertTitle("Primate Elderly Care");
clickAndWait(By.xpath("//h3[@id='totalAwardAmount']/a/img"));
assertTitle("Edit");
verifyTextPresent("Add new entry for: total award amount");
typeTinyMCE("$1,234,567");
clickAndWait(By.id("submit"));
assertTitle("Primate Elderly Care");
clickAndWait(By.xpath("//h3[@id='grantDirectCosts']/a/img"));
assertTitle("Edit");
typeTinyMCE("$999,999");
clickAndWait(By.id("submit"));
assertTitle("Primate Elderly Care");
clickAndWait(By.xpath("//h3[@id='sponsorAwardId']/a/img"));
assertTitle("Edit");
typeTinyMCE("1234-5678");
clickAndWait(By.id("submit"));
assertTitle("Primate Elderly Care");
clickAndWait(By.xpath("//h3[@id='geographicFocus']/a/img"));
assertTitle("Edit");
vivoAutoCompleteSelect(By.id("object"), "Afri", Keys.ARROW_DOWN);
clickAndWait(By.id("submit"));
assertTitle("Primate Elderly Care");
clickAndWait(By.xpath("//h3[@id='dateTimeInterval']/a/img"));
assertTitle("Edit");
type(By.id("startField-year"), "2010");
type(By.id("startField-month"), "9");
type(By.id("startField-day"), "1");
type(By.id("endField-year"), "2012");
type(By.id("endField-month"), "8");
type(By.id("endField-day"), "31");
clickAndWait(By.id("submit"));
assertTitle("Primate Elderly Care");
clickAndWait(By.xpath("//h3[@id='localAwardId']/a/img"));
assertTitle("Edit");
verifyTextPresent("Add new entry for: local award ID");
typeTinyMCE("P999-1234");
clickAndWait(By.id("submit"));
assertTitle("Primate Elderly Care");
clickAndWait(By.cssSelector("a.add-fundingVehicleFor > img.add-individual"));
assertTitle("Edit");
vivoAutoCompleteSelect(By.id("object"), "primate health chec", Keys.ARROW_DOWN);
clickAndWait(By.id("submit"));
assertTitle("Primate Elderly Care");
clickAndWait(By.xpath("//h3[@id='hasSubjectArea']/a/img"));
assertTitle("Edit");
verifyTextPresent("Manage Concepts");
clickAndWait(By.id("showAddFormButton"));
clickAndWait(By.linkText("Select or create a VIVO-defined concept. "));
assertTitle("Edit");
type(By.id("relatedIndLabel"), "Elderly Care");
clickAndWait(By.id("submit"));
assertTitle("Edit");
clickAndWait(By.linkText("Return to Profile Page"));
assertTitle("Primate Elderly Care");
clickAndWait(By.cssSelector("a.add-BFO_0000051 > img.add-individual"));
assertTitle("Edit");
selectByLabel(By.id("objectVar"), "Primate Habitat Research Grant");
clickAndWait(By.id("submit"));
assertTitle("Primate Elderly Care");
clickAndWait(By.cssSelector("a.add-BFO_0000050 > img.add-individual"));
assertTitle("Edit");
selectByLabel(By.id("objectVar"), "Primate Survival Planning Grant");
clickAndWait(By.id("submit"));
assertTitle("Primate Elderly Care");
clickAndWait(By.cssSelector("a.add-supportedInformationResource"));
assertTitle("Edit");
selectByLabel(By.id("objectVar"), "Primate Info (Database)");
clickAndWait(By.id("submit"));
assertTitle("Primate Elderly Care");
verifyTextPresent(
"Primate Elderly Care",
"Grant",
"Purpose of grant is to determine the appropriate environment, physical activity, and diet for primates as they age.",
"September 1, 2010 - August 31, 2012",
"$1,234,567",
"$999,999",
"1234-5678",
"P999-1234"
);
verifyElementPresent(By.linkText("Elderly Care"));
verifyElementPresent(By.linkText("Primate Research Laboratory"));
verifyElementPresent(By.linkText("Primate Colleges of the World"));
verifyElementPresent(By.linkText("Africa"));
verifyElementPresent(By.linkText("Primate Habitat Research Grant"));
verifyElementPresent(By.linkText("Primate Survival Planning Grant"));
verifyElementPresent(By.linkText("Primate Info"));
vivoLogOut();
}
}

View file

@ -0,0 +1,220 @@
package org.vivoweb.vivo.selenium.tests;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
public class CreateEvent extends AbstractVIVOSeleniumTest {
@Test
public void createEvent() {
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"), "Conference (bibo)");
clickAndWait(By.xpath("//input[@value='Add individual of this class']"));
assertTitle("Edit");
verifyTextPresent("Create a new Conference");
clickAndWait(By.linkText("Cancel"));
assertTitle("VIVO Site Administration");
selectByLabel(By.id("VClassURI"), "Conference (bibo)");
clickAndWait(By.xpath("//input[@value='Add individual of this class']"));
assertTitle("Edit");
verifyTextPresent("Create a new Conference");
clickAndWait(By.id("submit"));
assertTitle("Edit");
verifyTextPresent("Please enter a value in the Name field.");
type(By.id("label"), "Primate Health Conference");
clickAndWait(By.id("submit"));
assertTitle("Primate Health Conference");
clickAndWait(By.xpath("//div[@id='wrapper-content']/ul/li[8]"));
clickAndWait(By.xpath("//h3[@id='description']/a/img"));
assertTitle("Edit");
verifyTextPresent("Add new entry for: description");
typeTinyMCE("First annual conference for those interested in the general health of primates.");
clickAndWait(By.id("submit"));
assertTitle("Primate Health Conference");
clickAndWait(By.xpath("//h3[@id='hasProceedings']/a/img"));
assertTitle("Edit");
clickAndWait(By.id("offerCreate"));
assertTitle("Edit");
type(By.id("label"), "PHC Proceedings");
clickAndWait(By.id("submit"));
assertTitle("Primate Health Conference");
// Wait for index to catch up
pause(4000);
clickAndWait(By.linkText("Index"));
clickAndWait(By.linkText("Conference"));
assertTitle("Conference");
clickAndWait(By.linkText("Primate Health Conference"));
assertTitle("Primate Health Conference");
clickAndWait(By.xpath("//h3[@id='contactInformation']/a/img"));
assertTitle("Edit");
verifyTextPresent("Add new entry for: contact information");
typeTinyMCE("info@primateconf.org");
clickAndWait(By.id("submit"));
assertTitle("Primate Health Conference");
clickAndWait(By.xpath("//h3[@id='geographicFocus']/a/img"));
assertTitle("Edit");
verifyTextPresent("If you don't find the appropriate entry on the selection list above:");
vivoAutoCompleteSelect(By.id("object"), "Kenya", Keys.ARROW_DOWN);
clickAndWait(By.id("submit"));
assertTitle("Primate Health Conference");
clickAndWait(By.xpath("(//h3[@id='RO_0001025']/a)[2]"));
assertTitle("Edit");
verifyTextPresent("If you don't find the appropriate entry on the selection list above:");
verifyTextPresent("Geographic Location Name");
vivoAutoCompleteSelect(By.id("object"), "Cong", Keys.ARROW_DOWN);
clickAndWait(By.id("submit"));
assertTitle("Primate Health Conference");
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");
type(By.id("label"), "State Fair Park");
clickAndWait(By.id("submit"));
assertTitle("Primate Health Conference");
clickAndWait(By.xpath("//h3[@id='dateTimeInterval']/a/img"));
assertTitle("Edit");
type(By.id("startField-year"), "2011");
type(By.id("startField-month"), "1");
type(By.id("startField-day"), "5");
type(By.id("endField-year"), "2011");
type(By.id("endField-month"), "1");
type(By.id("endField-day"), "9");
clickAndWait(By.id("submit"));
assertTitle("Primate Health Conference");
clickAndWait(By.xpath("//h3[@id='presents']/a/img"));
assertTitle("Edit");
clickAndWait(By.id("submit"));
assertTitle("Primate Health Conference");
clickAndWait(By.cssSelector("a.add-BFO_0000051 > img.add-individual"));
assertTitle("Edit");
verifyTextPresent("If you don't find the appropriate entry on the selection list above:");
selectByLabel(By.id("objectVar"), "Primate Health Check (Event)");
clickAndWait(By.id("submit"));
assertTitle("Primate Health Conference");
clickAndWait(By.cssSelector("a.add-hasSubjectArea > img.add-individual"));
assertTitle("Edit");
clickAndWait(By.id("showAddFormButton"));
clickAndWait(By.linkText("Select or create a VIVO-defined concept. "));
assertTitle("Edit");
vivoAutoCompleteSelect(By.id("relatedIndLabel"), "Anim", Keys.ARROW_DOWN);
clickAndWait(By.id("submit"));
assertTitle("Edit");
clickAndWait(By.linkText("Return to Profile Page"));
assertTitle("Primate Health Conference");
clickAndWait(By.xpath("//h3[@id='abbreviation']/a/img"));
assertTitle("Edit");
typeTinyMCE("PrimHConf");
clickAndWait(By.id("submit"));
assertTitle("Primate Health Conference");
clickAndWait(By.cssSelector("a.add-BFO_0000050 > img.add-individual"));
assertTitle("Edit");
selectByLabel(By.id("objectVar"), "Primate Health and Fitness (Invited Talk)");
clickAndWait(By.id("submit"));
assertTitle("Primate Health Conference");
clickAndWait(By.xpath("(//img[@alt='add'])[6]"));
assertTitle("Edit");
clickAndWait(By.id("submit"));
assertTitle("Primate Health Conference");
clickAndWait(By.cssSelector("a.add-RO_0002234 > img.add-individual"));
assertTitle("Edit");
selectByLabel(By.id("objectVar"), "Primate Happenings (Blog Posting)");
clickAndWait(By.id("submit"));
assertTitle("Primate Health Conference");
verifyTextPresent(
"Primate Health Conference",
"Conference",
"First annual conference for those interested in the general health of primates.",
"PrimHConf",
"January 5, 2011 - January 9, 2011",
"info@primateconf.org"
);
verifyElementPresent(By.linkText("Primate Health and Fitness"));
verifyElementPresent(By.linkText("Primate Health Check"));
verifyElementPresent(By.linkText("Primate Health Talks"));
verifyElementPresent(By.linkText("Animal Health"));
verifyElementPresent(By.linkText("PHC Proceedings"));
verifyElementPresent(By.linkText("Kenya"));
verifyElementPresent(By.linkText("Primate Happenings"));
verifyElementPresent(By.linkText("http://primatehealthintro.cornell.edu"));
verifyElementPresent(By.linkText("State Fair Park"));
verifyElementPresent(By.linkText("Congo"));
vivoLogOut();
}
}

View file

@ -12,7 +12,8 @@ public class DeleteCourses extends AbstractVIVOSeleniumTest {
assertTitle("VIVO");
vivoLogIn("testAdmin@cornell.edu", "Password");
/*
/* From CreateCourses */
clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents");
@ -23,7 +24,8 @@ public class DeleteCourses extends AbstractVIVOSeleniumTest {
assertTitle("Introduction to Primate Health");
vivoDeleteIndividual();
*/
/* */
clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents");

View file

@ -46,17 +46,18 @@ public class DeleteEvents extends AbstractVIVOSeleniumTest {
vivoDeleteIndividual();
/* From CreateEvent */
clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents");
clickAndWait(By.linkText("Event"));
assertTitle("Event");
/*
clickAndWait(By.linkText("Primate Health Conference"));
assertTitle("Primate Health Conference");
vivoDeleteIndividual();
*/
/* */
clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents");
@ -67,7 +68,8 @@ public class DeleteEvents extends AbstractVIVOSeleniumTest {
assertTitle("Primates in the Wild");
vivoDeleteIndividual();
/*
/* From CreateCourses */
clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents");
@ -78,7 +80,7 @@ public class DeleteEvents extends AbstractVIVOSeleniumTest {
assertTitle("Primate Health Talks");
vivoDeleteIndividual();
*/
/* */
// Where is Introduction to Primates??
vivoLogOut();

View file

@ -13,9 +13,13 @@ public class DeleteLocations extends AbstractVIVOSeleniumTest {
vivoLogIn("testAdmin@cornell.edu", "Password");
/* from CreateCourses */
clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents");
vivoDeleteIndividual("Building", "Primate Memorial Building");
/* */
vivoLogOut();
}
}
@ -86,71 +90,6 @@ public class DeleteLocations extends AbstractVIVOSeleniumTest {
<td>link=Index</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Building</td>
<td></td>
</tr>
<tr>
<td>assertTitle</td>
<td>Building</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Primate Memorial Building</td>
<td></td>
</tr>
<tr>
<td>assertTitle</td>
<td>Primate Memorial Building</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Edit this individual</td>
<td></td>
</tr>
<tr>
<td>assertTitle</td>
<td>Individual Control Panel</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//input[@value='Edit This Individual']</td>
<td></td>
</tr>
<tr>
<td>assertTitle</td>
<td>Individual Editing Form</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>name=_delete</td>
<td></td>
</tr>
<tr>
<td>assertConfirmation</td>
<td>Are you SURE you want to delete this individual? If in doubt, CANCEL.</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>5000</td>
<td></td>
</tr>
<tr>
<td>assertTitle</td>
<td>VIVO Site Administration</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Index</td>
<td></td>
</tr>
<tr>
<td>assertTitle</td>
<td>Index of Contents</td>

View file

@ -45,7 +45,7 @@ public class DeleteResearch extends AbstractVIVOSeleniumTest {
assertTitle("Primate Student of the Year");
vivoDeleteIndividual();
/*
/* From CreateEvent */
clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents");
@ -56,18 +56,8 @@ public class DeleteResearch extends AbstractVIVOSeleniumTest {
assertTitle("PHC Proceedings");
vivoDeleteIndividual();
clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents");
clickAndWait(By.linkText("Concept"));
assertTitle("Concept");
clickAndWait(By.linkText("Animal Health"));
assertTitle("Animal Health");
vivoDeleteIndividual();
/* */
/*
clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents");
@ -85,17 +75,6 @@ public class DeleteResearch extends AbstractVIVOSeleniumTest {
clickAndWait(By.linkText("Concept"));
assertTitle("Concept");
clickAndWait(By.linkText("Elderly Care"));
assertTitle("Elderly Care");
vivoDeleteIndividual();
clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents");
clickAndWait(By.linkText("Concept"));
assertTitle("Concept");
clickAndWait(By.linkText("Primate Diet"));
assertTitle("Primate Diet");
@ -112,6 +91,31 @@ public class DeleteResearch extends AbstractVIVOSeleniumTest {
vivoDeleteIndividual();
*/
/* From CreateActivity */
clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents");
clickAndWait(By.linkText("Concept"));
assertTitle("Concept");
clickAndWait(By.linkText("Elderly Care"));
assertTitle("Elderly Care");
vivoDeleteIndividual();
/* */
/* From CreateCourses */
clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents");
clickAndWait(By.linkText("Concept"));
assertTitle("Concept");
clickAndWait(By.linkText("Animal Health"));
assertTitle("Animal Health");
vivoDeleteIndividual();
/* */
clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents");
@ -122,7 +126,8 @@ public class DeleteResearch extends AbstractVIVOSeleniumTest {
assertTitle("Primate Info");
vivoDeleteIndividual();
/*
/* Delete grant from createActivity */
clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents");
@ -133,7 +138,8 @@ public class DeleteResearch extends AbstractVIVOSeleniumTest {
assertTitle("Primate Elderly Care");
vivoDeleteIndividual();
*/
/* */
clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents");
@ -166,7 +172,8 @@ public class DeleteResearch extends AbstractVIVOSeleniumTest {
assertTitle("USA222333444555");
vivoDeleteIndividual();
/*
/* From CreateCourses */
clickAndWait(By.linkText("Index"));
assertTitle("Index of Contents");
@ -177,7 +184,7 @@ public class DeleteResearch extends AbstractVIVOSeleniumTest {
assertTitle("http://primatehealthintro.cornell.edu");
vivoDeleteIndividual();
*/
/* */
vivoLogOut();
}
}