From d582317a05c4d938241a63abae6036892d5ebc89 Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Wed, 16 Dec 2015 22:49:32 +0000 Subject: [PATCH] Initial WebDriver tests (work in progress) --- selenium/pom.xml | 41 + .../vivoweb/vivo/selenium/DriverFactory.java | 37 + .../vivoweb/vivo/selenium/SeleniumUtils.java | 27 + .../org/vivoweb/vivo/selenium/VIVOSuite.java | 40 + .../selenium/suites/AddNonPersonThings.java | 29 + .../selenium/tests/AbstractSeleniumTest.java | 109 ++ .../selenium/tests/CreateOrganization.java | 1680 +++++++++++++++++ .../selenium/tests/RebuildSearchIndex.java | 39 + selenium/test-user-model.owl | 58 + 9 files changed, 2060 insertions(+) create mode 100644 selenium/pom.xml create mode 100644 selenium/src/test/java/org/vivoweb/vivo/selenium/DriverFactory.java create mode 100644 selenium/src/test/java/org/vivoweb/vivo/selenium/SeleniumUtils.java create mode 100644 selenium/src/test/java/org/vivoweb/vivo/selenium/VIVOSuite.java create mode 100644 selenium/src/test/java/org/vivoweb/vivo/selenium/suites/AddNonPersonThings.java create mode 100644 selenium/src/test/java/org/vivoweb/vivo/selenium/tests/AbstractSeleniumTest.java create mode 100644 selenium/src/test/java/org/vivoweb/vivo/selenium/tests/CreateOrganization.java create mode 100644 selenium/src/test/java/org/vivoweb/vivo/selenium/tests/RebuildSearchIndex.java create mode 100644 selenium/test-user-model.owl diff --git a/selenium/pom.xml b/selenium/pom.xml new file mode 100644 index 00000000..2e5e9ae1 --- /dev/null +++ b/selenium/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + org.vivoweb + vivo-selenium + 1.9.0-SNAPSHOT + pom + + VIVO Selenium Tests + + + + + maven-install-plugin + 2.5.2 + + true + + + + + + + + org.seleniumhq.selenium + selenium-java + 2.48.2 + test + + + junit + junit + 4.12 + test + + + diff --git a/selenium/src/test/java/org/vivoweb/vivo/selenium/DriverFactory.java b/selenium/src/test/java/org/vivoweb/vivo/selenium/DriverFactory.java new file mode 100644 index 00000000..1e24e282 --- /dev/null +++ b/selenium/src/test/java/org/vivoweb/vivo/selenium/DriverFactory.java @@ -0,0 +1,37 @@ +package org.vivoweb.vivo.selenium; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.firefox.FirefoxDriver; + +public final class DriverFactory { + private static WebDriver driver = null; + private static Object closeToken = null; + + public static WebDriver getDriver() { + if (driver == null) { + driver = new FirefoxDriver(); + } + + return driver; + } + + public static void close() { + if (closeToken == null && driver != null) { + driver.quit(); + driver = null; + } + } + + public static void close(Object token) { + if (closeToken == token || (closeToken != null && closeToken.equals(token))) { + if (driver != null) { + driver.quit(); + driver = null; + } + } + } + + public static void setCloseToken(Object token) { + closeToken = token; + } +} diff --git a/selenium/src/test/java/org/vivoweb/vivo/selenium/SeleniumUtils.java b/selenium/src/test/java/org/vivoweb/vivo/selenium/SeleniumUtils.java new file mode 100644 index 00000000..e1ff5474 --- /dev/null +++ b/selenium/src/test/java/org/vivoweb/vivo/selenium/SeleniumUtils.java @@ -0,0 +1,27 @@ +package org.vivoweb.vivo.selenium; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +public final class SeleniumUtils { + private static String baseUrl = "http://localhost:8080/vivo"; + + public static void setBaseUrl(String baseUrl) { + SeleniumUtils.baseUrl = baseUrl; + } + + public static String makeUrl(String urlPart) { + if (urlPart.startsWith("/")) { + return baseUrl + urlPart; + } else { + return baseUrl + "/" + urlPart; + } + } + + public static void navigate(WebDriver driver, String urlPart) { + driver.navigate().to(makeUrl(urlPart)); + } +} diff --git a/selenium/src/test/java/org/vivoweb/vivo/selenium/VIVOSuite.java b/selenium/src/test/java/org/vivoweb/vivo/selenium/VIVOSuite.java new file mode 100644 index 00000000..c16cd3f9 --- /dev/null +++ b/selenium/src/test/java/org/vivoweb/vivo/selenium/VIVOSuite.java @@ -0,0 +1,40 @@ +package org.vivoweb.vivo.selenium; + +import org.junit.runner.Runner; +import org.junit.runner.notification.RunNotifier; +import org.junit.runners.Suite; +import org.junit.runners.model.InitializationError; +import org.junit.runners.model.RunnerBuilder; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.firefox.FirefoxDriver; + +import java.util.List; + +public class VIVOSuite extends Suite { + public VIVOSuite(Class klass, RunnerBuilder builder) throws InitializationError { + super(klass, builder); + } + + public VIVOSuite(RunnerBuilder builder, Class[] classes) throws InitializationError { + super(builder, classes); + } + + protected VIVOSuite(Class klass, Class[] suiteClasses) throws InitializationError { + super(klass, suiteClasses); + } + + protected VIVOSuite(RunnerBuilder builder, Class klass, Class[] suiteClasses) throws InitializationError { + super(builder, klass, suiteClasses); + } + + protected VIVOSuite(Class klass, List runners) throws InitializationError { + super(klass, runners); + } + + @Override + protected void runChild(Runner runner, RunNotifier notifier) { + // Set Driver factory, can run multiple times + super.runChild(runner, notifier); + } + +} diff --git a/selenium/src/test/java/org/vivoweb/vivo/selenium/suites/AddNonPersonThings.java b/selenium/src/test/java/org/vivoweb/vivo/selenium/suites/AddNonPersonThings.java new file mode 100644 index 00000000..114f3386 --- /dev/null +++ b/selenium/src/test/java/org/vivoweb/vivo/selenium/suites/AddNonPersonThings.java @@ -0,0 +1,29 @@ +package org.vivoweb.vivo.selenium.suites; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +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.CreateOrganization; +import org.vivoweb.vivo.selenium.tests.RebuildSearchIndex; + +@RunWith(VIVOSuite.class) +@SuiteClasses( + { + RebuildSearchIndex.class, + CreateOrganization.class + } +) +public class AddNonPersonThings { + @BeforeClass + public static void setup() { + DriverFactory.setCloseToken(AddNonPersonThings.class); + } + + @AfterClass + public static void shutdown() { + DriverFactory.close(AddNonPersonThings.class); + } +} diff --git a/selenium/src/test/java/org/vivoweb/vivo/selenium/tests/AbstractSeleniumTest.java b/selenium/src/test/java/org/vivoweb/vivo/selenium/tests/AbstractSeleniumTest.java new file mode 100644 index 00000000..2b803c5f --- /dev/null +++ b/selenium/src/test/java/org/vivoweb/vivo/selenium/tests/AbstractSeleniumTest.java @@ -0,0 +1,109 @@ +package org.vivoweb.vivo.selenium.tests; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.Select; +import org.openqa.selenium.support.ui.WebDriverWait; +import org.vivoweb.vivo.selenium.DriverFactory; +import org.vivoweb.vivo.selenium.SeleniumUtils; + +public class AbstractSeleniumTest { + protected WebDriver driver; + + protected void assertTitle(String title) { + Assert.assertEquals(title, driver.getTitle()); + } + + protected void clickAndWait(By by) { + driver.findElement(by).click(); + } + + protected void deleteAllVisibleCookies() { + driver.manage().deleteAllCookies(); + } + + protected void logIn(String email, String password) { + clickAndWait(By.linkText("Log in")); // clickAndWait,link=Log in + assertTitle("Log in to VIVO"); // aseertTitle,Log in to VIVO + + type(By.id("loginName"), email); // type,id=loginName,testAdmin@cornell.edu + type(By.id("loginPassword"), password); // type,id=loginPassword,Password + + clickAndWait(By.name("loginForm")); // clickAndWait,name=loginForm + assertTitle("VIVO"); // assertTitle,VIVO + } + + protected void logOut() { + Actions actions = new Actions(driver); + actions.moveToElement( driver.findElement(By.id("user-menu")) ).perform(); + driver.findElement(By.linkText("Log out")).click(); + } + + protected void open(String urlPart) { + SeleniumUtils.navigate(driver, urlPart); + } + + protected void selectByLabel(By by, String label) { + Select select = new Select(driver.findElement(by)); + select.selectByVisibleText(label); + + } + + protected void type(By by, String text) { + driver.findElement(by).sendKeys(text); + } + + protected void typeTinyMCE(String text) { +// tinyMCE.activeEditor.setContent('The Primate College of America is a privately-funded college for the study of primates.') + + driver.switchTo().frame("literal_ifr"); + WebElement element = driver.findElement(By.cssSelector("body")); + element.click(); + element.sendKeys(text); + driver.switchTo().defaultContent(); + } + + protected void verifyTextPresent(String text) { + Assert.assertNotNull(driver.findElement(xpathForTextPresent(text))); + } + + protected boolean waitForElementPresent(By by) { + return waitForElementPresent(by, 30); + } + + protected boolean waitForElementPresent(By by, int timeout) { + WebDriverWait wait = new WebDriverWait(driver, timeout); + return wait.until(ExpectedConditions.presenceOfElementLocated(by)) != null; + } + + protected boolean waitForTextPresent(String text) { + return waitForTextPresent(text, 30); + } + + protected boolean waitForTextPresent(String text, int timeout) { + WebDriverWait wait = new WebDriverWait(driver, timeout); + return wait.until(ExpectedConditions.presenceOfElementLocated(xpathForTextPresent(text))) != null; + } + + protected By xpathForTextPresent(String text) { + return By.xpath("//*[text()[contains(.,'" + text + "')]]"); + } + + @Before + public void setup() { + driver = DriverFactory.getDriver(); + } + + @After + public void cleanup() { + DriverFactory.close(); + } +} diff --git a/selenium/src/test/java/org/vivoweb/vivo/selenium/tests/CreateOrganization.java b/selenium/src/test/java/org/vivoweb/vivo/selenium/tests/CreateOrganization.java new file mode 100644 index 00000000..96eac167 --- /dev/null +++ b/selenium/src/test/java/org/vivoweb/vivo/selenium/tests/CreateOrganization.java @@ -0,0 +1,1680 @@ +package org.vivoweb.vivo.selenium.tests; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; + +public class CreateOrganization extends AbstractSeleniumTest { + @Test + public void createOrganization() { + deleteAllVisibleCookies(); + + open("/"); + assertTitle("VIVO"); + + logIn("testAdmin@cornell.edu", "Password"); + + clickAndWait(By.linkText("Site Admin")); + assertTitle("VIVO Site Administration"); + + verifyTextPresent("Data Input"); + + selectByLabel(By.id("VClassURI"), "College (vivo)"); + + clickAndWait(By.xpath("//input[@value='Add individual of this class']")); + assertTitle("Edit"); + verifyTextPresent("Create a new College"); + verifyTextPresent("Name"); + + clickAndWait(By.linkText("Cancel")); + + assertTitle("VIVO Site Administration"); + + selectByLabel(By.id("VClassURI"), "College (vivo)"); + + clickAndWait(By.xpath("//input[@value='Add individual of this class']")); + assertTitle("Edit"); + verifyTextPresent("Create a new College"); + verifyTextPresent("Name"); + + clickAndWait(By.id("submit")); + assertTitle("Edit"); + verifyTextPresent("Please enter a value in the Name field."); + + type(By.id("label"), "Primate College of America"); + + clickAndWait(By.id("submit")); + assertTitle("Primate College of America"); + + clickAndWait(By.xpath("//h2[@id='overview']/a/img")); + assertTitle("Edit"); + + typeTinyMCE("The Primate College of America is a privately-funded college for the study of primates."); + + clickAndWait(By.id("submit")); + assertTitle("Primate College of America"); + + clickAndWait(By.cssSelector("a.add-offers > img.add-individual")); + assertTitle("Edit"); + + selectByLabel(By.id("objectVar"), "B.S. Bachelor of Science (Academic Degree)"); + + clickAndWait(By.id("submit")); + assertTitle("Primate College of America"); + + clickAndWait(By.xpath("//div[@id='wrapper-content']/ul/li[12]")); + clickAndWait(By.cssSelector("a.add-hasPredecessorOrganization > img.add-individual")); + assertTitle("Edit"); + + selectByLabel(By.id("typeOfNew"), "College (vivo)"); + clickAndWait(By.id("offerCreate")); + + assertTitle("Edit"); + type(By.id("label"), "Primate College of New York"); + + clickAndWait(By.id("submit")); + assertTitle("Primate College of America"); + + clickAndWait(By.xpath("//div[@id='wrapper-content']/ul/li[8]")); + clickAndWait(By.cssSelector("a.add-assigns > img.add-individual")); + + assertTitle("Edit"); + clickAndWait(By.id("offerCreate")); + + assertTitle("Edit"); + type(By.id("label"), "Primate Habitat Research Grant"); + + clickAndWait(By.id("submit")); + assertTitle("Primate College of America"); + + clickAndWait(By.cssSelector("li.nonSelectedGroupTab.clickable")); + clickAndWait(By.cssSelector("a.add-sponsors > img.add-individual")); + + assertTitle("Edit"); + clickAndWait(By.id("offerCreate")); + + assertTitle("Edit"); + type(By.id("label"), "Primate Student of the Year"); + + clickAndWait(By.id("submit")); + assertTitle("Primate College of America"); + + clickAndWait(By.cssSelector("a.add-relatedBy > img.add-individual")); + + assertTitle("Edit"); + type(By.id("award"), "Best Primate College"); + clickAndWait(By.xpath("//input[@value='Create Entry']")); + + assertTitle("Primate College of America"); + clickAndWait(By.xpath("//div[@id='wrapper-content']/ul/li[14]")); + + clickAndWait(By.cssSelector("a.add-hasEquipment > img.add-individual")); + + assertTitle("Edit"); + clickAndWait(By.id("offerCreate")); + + assertTitle("Edit"); + type(By.id("label"), "Portable Primate Habitat"); + + clickAndWait(By.id("submit")); + assertTitle("Primate College of America"); + + clickAndWait(By.xpath("//div[@id='wrapper-content']/ul/li[8]")); + clickAndWait(By.cssSelector("a.add-subcontractsGrant > img.add-individual")); + + assertTitle("Edit"); + clickAndWait(By.id("offerCreate")); + + assertTitle("Edit"); + type(By.id("label"), "Primate Survival Planning Grant"); + + clickAndWait(By.id("submit")); + assertTitle("Primate College of America"); + + clickAndWait(By.xpath("//div[@id='wrapper-content']/ul/li[4]")); + clickAndWait(By.cssSelector("a.add-BFO_0000051 > img.add-individual")); + + assertTitle("Edit"); + selectByLabel(By.id("typeOfNew"), "Laboratory (vivo)"); + + clickAndWait(By.id("offerCreate")); + + assertTitle("Edit"); + type(By.id("label"), "Primate Research Laboratory"); + + clickAndWait(By.id("submit")); + assertTitle("Primate College of America"); + + clickAndWait(By.cssSelector("a.add-BFO_0000051 > img.add-individual")); + + assertTitle("Edit"); + selectByLabel(By.id("typeOfNew"), "Library (vivo)"); + + clickAndWait(By.id("offerCreate")); + + assertTitle("Edit"); + type(By.id("label"), "Primate History Library"); + + clickAndWait(By.id("submit")); + assertTitle("Primate College of America"); + + clickAndWait(By.cssSelector("#relatedBy-Position > a.add-relatedBy > img.add-individual")); + + assertTitle("Edit"); + type(By.id("positionTitle"), "Dr."); + + selectByLabel(By.id("positionType"), "Faculty Administrative Position"); + + type(By.id("person"), "Person"); + type(By.id("firstName"), "Polly"); + type(By.id("startField-year"), "1999"); + + clickAndWait(By.id("submit")); + assertTitle("Primate College of America"); + + clickAndWait(By.cssSelector("a.add-RO_0000053 > img.add-individual")); + + assertTitle("Edit"); + type(By.id("typeSelector"), "Company"); + type(By.id("activity"), "Primates-r-us"); + type(By.id("roleLabel"), "Founder"); + type(By.id("startField-year"), "2010"); + + clickAndWait(By.id("submit")); + assertTitle("Primate College of America"); + + clickAndWait(By.cssSelector("a.add-affiliatedOrganization > img.add-individual")); + + assertTitle("Edit"); + selectByLabel(By.id("objectVar"), "Primates-r-us (Company)"); + + clickAndWait(By.id("submit")); + assertTitle("Primate College of America"); + + clickAndWait(By.xpath("(//img[@alt='add'])[13]")); + + assertTitle("Edit"); + + selectByLabel(By.id("typeSelector"), "Consortium"); + type(By.id("activity"), "Primate Colleges of the World"); + type(By.id("roleLabel"), "Member"); + type(By.id("startField-year"), "2009"); + + clickAndWait(By.id("submit")); + assertTitle("Primate College of America"); + + clickAndWait(By.cssSelector("a.add-hasCollaborator > img.add-individual")); + + assertTitle("Edit"); + + type(By.id("object"), "Primate His"); +// WebElement element; +// element.sendKeys(Keys.ARROW_DOWN); +// element.click(); + +// try {Thread.sleep(100000); } catch (Exception e) { } + } +} +/* + + +*/ + + +/* + +click +id=ui-active-menuitem + + + +clickAndWait +submit + + + +assertTitle +Primate College of America + + + +clickAndWait +xpath=(//img[@alt='add'])[14] + + + +assertTitle +Edit + + + +select +typeSelector +label=Service + + +type +id=activity +Primate Heart Health + + +type +roleLabel +Founder + + +type +startField-year +2010 + + +clickAndWait +submit + + + +assertTitle +Primate College of America + + + + +click +//div[@id='wrapper-content']/ul/li[6] + + + +clickAndWait +css=a.add-publisherOf > img.add-individual + + + +assertTitle +Edit + + + +select +id=typeOfNew +label=Database (vivo) + + +clickAndWait +id=offerCreate + + + +assertTitle +Edit + + + +type +id=label +Primate Info + + +clickAndWait +id=submit + + + +assertTitle +Primate College of America + + + +clickAndWait +css=#publicationsGroup > article.property > #RO_0000053 > a.add-RO_0000053 > img.add-individual + + + +assertTitle +Edit + + + +select +typeSelector +label=Invited Talk + + +type +id=presentation +Primate Health and Fitness + + +type +roleLabel +Organizer + + +type +startField-year +2008 + + +clickAndWait +css=input.submit + + + +assertTitle +Primate College of America + + + + +click +//div[@id='wrapper-content']/ul/li[10] + + + +clickAndWait +css=#serviceGroup > article.property > #RO_0000053 > a.add-RO_0000053 > img.add-individual + + + +assertTitle +Edit + + + +select +typeSelector +label=Event + + +type +id=activity +Primate Health Check + + +type +roleLabel +Sponsor + + +type +startField-year +2008 + + +type +endField-year +2010 + + +clickAndWait +submit + + + +assertTitle +Primate College of America + + + + +click +//div[@id='wrapper-content']/ul/li[12] + + + +clickAndWait +css=a.add-RO_0001025 > img.add-individual + + + +assertTitle +Edit + + + +type +id=object + + + +sendKeys +id=object +northern Afr + + +pause +5000 + + + +sendKeys +id=object +${KEY_DOWN} + + +click +id=ui-active-menuitem + + + +clickAndWait +submit + + + +assertTitle +Primate College of America + + + + +clickAndWait +xpath=(//img[@alt='add'])[34] + + + +assertTitle +Edit + + + +type +id=emailAddress +info@primates.edu + + +clickAndWait +id=submit + + + +assertTitle +Primate College of America + + + +clickAndWait +css=article.property > #ARG_2000028 > a.add-ARG_2000028 > img.add-individual + + + +assertTitle +Edit + + + +type +id=telephoneNumber +555-555-5555 + + +clickAndWait +id=submit + + + +assertTitle +Primate College of America + + + +clickAndWait +xpath=(//h3[@id='ARG_2000028']/a)[2] + + + +assertTitle +Edit + + + +type +id=telephoneNumber +555-555-5554 + + +clickAndWait +id=submit + + + +assertTitle +Primate College of America + + + +clickAndWait +xpath=(//img[@alt='add'])[35] + + + +assertTitle +Edit + + + +type +id=streetAddressOne +1234 Northern African Nation + + +type +id=city +Morocco City + + +type +id=postalCode +1234567890 + + +type +id=countryEditMode +Morocco + + +clickAndWait +id=submit + + + +assertTitle +Primate College of America + + + + +click +css=li.nonSelectedGroupTab.clickable + + + +clickAndWait +css=a.add-dateTimeInterval > img.add-individual + + + +assertTitle +Edit + + + +type +startField-year +1959 + + +clickAndWait +submit + + + +assertTitle +Primate College of America + + + + +clickAndWait +//h3[@id='abbreviation']/a/img + + + +assertTitle +Edit + + + +waitForElementPresent +tinymce + + + +runScript +tinyMCE.activeEditor.setContent('PCoA') + + + +clickAndWait +submit + + + +assertTitle +Primate College of America + + + +click +//div[@id='wrapper-content']/ul/li[8] + + + +clickAndWait +//h3[@id='freetextKeyword']/a/img + + + +assertTitle +Edit + + + +waitForElementPresent +tinymce + + + +runScript +tinyMCE.activeEditor.setContent('Gorillas') + + + +clickAndWait +submit + + + +assertTitle +Primate College of America + + + + +click +css=li.nonSelectedGroupTab.clickable + + + +clickAndWait +xpath=(//img[@alt='add'])[14] + + + +assertTitle +Edit + + + +select +id=typeSelector +label=Workshop + + +type +id=activity +New Primate Students + + +type +id=startField-year +2003 + + +type +id=endField-year +2006 + + +clickAndWait +id=submit + + + +assertTitle +Primate College of America + + + +clickAndWait +xpath=(//img[@alt='add'])[15] + + + +assertTitle +Edit + + + +select +id=typeSelector +label=Performance + + +type +id=activity +Primates in the Wild + + +type +id=startField-year +1997 + + +clickAndWait +id=submit + + + +assertTitle +Primate College of America + + + +click +//div[@id='wrapper-content']/ul/li[6] + + + +clickAndWait +css=a.add-featuredIn > img.add-individual + + + +assertTitle +Edit + + + +select +id=typeOfNew +label=Blog Posting (vivo) + + +clickAndWait +id=offerCreate + + + +assertTitle +Edit + + + +type +id=label +Primate Happenings + + +clickAndWait +id=submit + + + +assertTitle +Primate College of America + + + +clickAndWait +css=a.add-assigneeFor > img.add-individual + + + +assertTitle +Edit + + + +clickAndWait +id=offerCreate + + + +assertTitle +Edit + + + +type +id=label +USA222333444555 + + +clickAndWait +id=submit + + + +assertTitle +Primate College of America + + + +clickAndWait +css=a.add-translatorOf > img.add-individual + + + +assertTitle +Edit + + + +select +id=objectVar +label=Primate Happenings (Blog Posting) + + +clickAndWait +id=submit + + + +assertTitle +Primate College of America + + + +click +//div[@id='wrapper-content']/ul/li[8] + + + +clickAndWait +css=#researchGroup > article.property > #RO_0000053 > a.add-RO_0000053 > img.add-individual + + + +assertTitle +Edit + + + +type +id=grant + + + +sendKeys +id=grant +primate hab + + +pause +5000 + + + +sendKeys +id=grant +${KEY_DOWN} + + +click +id=ui-active-menuitem + + + +clickAndWait +css=input.submit + + + +assertTitle +Primate College of America + + + +clickAndWait +css=a.add-ERO_0001520 > img.add-individual + + + +assertTitle +Edit + + + +clickAndWait +id=offerCreate + + + +assertTitle +Edit + + + +type +id=label +Human and Ape Brain Comparison + + +clickAndWait +id=submit + + + +assertTitle +Primate College of America + + + +click +//div[@id='wrapper-content']/ul/li[10] + + + +clickAndWait +css=a.add-ERO_0000037 > img.add-individual + + + +assertTitle +Edit + + + +select +id=typeOfNew +label=Transport Service (obo) + + +clickAndWait +id=offerCreate + + + +assertTitle +Edit + + + +type +id=label +Gorilla Moving Company + + +clickAndWait +id=submit + + + +assertTitle +Primate College of America + + + +clickAndWait +css=#serviceGroup > article.property > #offers > a.add-offers > img.add-individual + + + +assertTitle +Edit + + + +clickAndWait +id=offerCreate + + + +assertTitle +Edit + + + +type +id=label +Introduction to Primates + + +clickAndWait +id=submit + + + +assertTitle +Primate College of America + + + +click +//div[@id='wrapper-content']/ul/li[12] + + + +clickAndWait +css=a.add-hasSuccessorOrganization > img.add-individual + + + +assertTitle +Edit + + + +select +id=typeOfNew +label=University (vivo) + + +clickAndWait +id=offerCreate + + + +assertTitle +Edit + + + +type +id=label +Primate University of America + + +clickAndWait +id=submit + + + +assertTitle +Primate College of America + + + +clickAndWait +css=a.add-governingAuthorityFor > img.add-individual + + + +assertTitle +Edit + + + +type +id=object + + + +sendKeys +id=object +primate colleges of the wor + + +pause +5000 + + + +sendKeys +id=object +${KEY_DOWN} + + +click +id=ui-active-menuitem + + + +clickAndWait +id=submit + + + +assertTitle +Primate College of America + + + + + +click +css=li.nonSelectedGroupTab.clickable + + + +verifyTextPresent +PCoA + + + +verifyTextPresent +1959 - + + + +verifyElementPresent +link=B.S. Bachelor of Science + + + +verifyElementPresent +link=Primate Student of the Year + + + +verifyElementPresent +link=Best Primate College + + + + +click +css=li.nonSelectedGroupTab.clickable + + + +verifyTextPresent +faculty administrative position + + + +verifyElementPresent +link=Person, Polly + + + +verifyTextPresent +Person, Polly, Dr. 1999 - + + + +verifyElementPresent +link=Primate History Library + + + +verifyElementPresent +link=Primate Research Laboratory + + + +verifyElementPresent +link=Primates-r-us + + + +verifyTextPresent +Primates-r-us Founder 2010 - + + + +verifyElementPresent +link=Primate History Library + + + +verifyElementPresent +link=Primates-r-us + + + +verifyElementPresent +link=Primate Colleges of the World + + + +verifyTextPresent +Primate Colleges of the World Member 2009 - + + + +verifyElementPresent +link=Primate Heart Health + + + +verifyTextPresent +Primate Heart Health Founder 2010 - + + + +verifyElementPresent +link=New Primate Students + + + +verifyTextPresent +New Primate Students 2003 - 2006 + + + +verifyElementPresent +link=Primates in the Wild + + + +verifyTextPresent +Primates in the Wild 1997 - + + + + +click +//div[@id='wrapper-content']/ul/li[6] + + + +verifyElementPresent +link=Primate Info + + + +verifyTextPresent +invited talk + + + +verifyElementPresent +link=Primate Health and Fitness + + + +verifyTextPresent +Primate Health and Fitness, Organizer 2008 + + + +verifyElementPresent +link=Primate Happenings + + + +verifyElementPresent +link=USA222333444555 + + + + +click +//div[@id='wrapper-content']/ul/li[8] + + + +verifyElementPresent +link=Primate Habitat Research Grant + + + +verifyElementPresent +link=Primate Habitat Research Grant + + + +verifyElementPresent +link=Primate Survival Planning Grant + + + +verifyElementPresent +link=Human and Ape Brain Comparison + + + +verifyTextPresent +Gorillas + + + + +click +//div[@id='wrapper-content']/ul/li[10] + + + +verifyElementPresent +link=Gorilla Moving Company + + + +verifyElementPresent +link=Primate Health Check + + + +verifyTextPresent +Primate Health Check Sponsor 2008 - 2010 + + + +verifyElementPresent +link=Portable Primate Habitat + + + +verifyElementPresent +link=Introduction to Primates + + + + +click +//div[@id='wrapper-content']/ul/li[12] + + + +verifyTextPresent +555-555-5555 + + + +verifyTextPresent +555-555-5554 + + + +verifyTextPresent +info@primates.edu + + + +verifyTextPresent +1234 Northern African Nation + + + +verifyTextPresent +Morocco City + + + +verifyTextPresent +1234567890 + + + +verifyTextPresent +Morocco + + + +verifyElementPresent +link=northern Africa + + + +verifyElementPresent +link=Primate College of New York + + + +verifyElementPresent +link=Primate University of America + + + +verifyElementPresent +link=Primate Colleges of the World + + + + +click +//div[@id='wrapper-content']/ul/li[14] + + + +verifyTextPresent +PCoA + + + +verifyTextPresent +1959 - + + + +verifyElementPresent +link=B.S. Bachelor of Science + + + +verifyElementPresent +link=Primate Student of the Year + + + +verifyElementPresent +link=Best Primate College + + + +verifyTextPresent +faculty administrative position + + + +verifyElementPresent +link=Person, Polly + + + +verifyTextPresent +Person, Polly, Dr. 1999 - + + + +verifyElementPresent +link=Primate History Library + + + +verifyElementPresent +link=Primate Research Laboratory + + + +verifyElementPresent +link=Primates-r-us + + + +verifyTextPresent +Primates-r-us Founder 2010 - + + + +verifyElementPresent +link=Primate History Library + + + +verifyElementPresent +link=Primates-r-us + + + +verifyElementPresent +link=Primate Colleges of the World + + + +verifyTextPresent +Primate Colleges of the World Member 2009 - + + + +verifyElementPresent +link=Primate Heart Health + + + +verifyTextPresent +Primate Heart Health Founder 2010 - + + + +verifyElementPresent +link=New Primate Students + + + +verifyTextPresent +New Primate Students 2003 - 2006 + + + +verifyElementPresent +link=Primates in the Wild + + + +verifyTextPresent +Primates in the Wild 1997 - + + + +verifyElementPresent +link=Primate Info + + + +verifyTextPresent +invited talk + + + +verifyElementPresent +link=Primate Health and Fitness + + + +verifyTextPresent +Primate Health and Fitness, Organizer 2008 + + + +verifyElementPresent +link=Primate Happenings + + + +verifyElementPresent +link=USA222333444555 + + + +verifyElementPresent +link=Primate Happenings + + + +verifyElementPresent +link=Primate Habitat Research Grant + + + +verifyElementPresent +link=Primate Habitat Research Grant + + + +verifyElementPresent +link=Primate Survival Planning Grant + + + +verifyElementPresent +link=Human and Ape Brain Comparison + + + +verifyTextPresent +Gorillas + + + +verifyElementPresent +link=Gorilla Moving Company + + + +verifyElementPresent +link=Primate Health Check + + + +verifyTextPresent +Primate Health Check Sponsor 2008 - 2010 + + + +verifyElementPresent +link=Portable Primate Habitat + + + +verifyElementPresent +link=Introduction to Primates + + + +verifyTextPresent +555-555-5555 + + + +verifyTextPresent +555-555-5554 + + + +verifyTextPresent +info@primates.edu + + + +verifyTextPresent +1234 Northern African Nation + + + +verifyTextPresent +Morocco City + + + +verifyTextPresent +1234567890 + + + +verifyTextPresent +Morocco + + + +verifyElementPresent +link=northern Africa + + + +verifyElementPresent +link=Primate College of New York + + + +verifyElementPresent +link=Primate University of America + + + +verifyElementPresent +link=Primate Colleges of the World + + + + +clickAndWait +link=Home + + + +clickAndWait +link=Log out + + + +assertTitle +VIVO + + + + + +*/ \ No newline at end of file diff --git a/selenium/src/test/java/org/vivoweb/vivo/selenium/tests/RebuildSearchIndex.java b/selenium/src/test/java/org/vivoweb/vivo/selenium/tests/RebuildSearchIndex.java new file mode 100644 index 00000000..ce4ece4c --- /dev/null +++ b/selenium/src/test/java/org/vivoweb/vivo/selenium/tests/RebuildSearchIndex.java @@ -0,0 +1,39 @@ +package org.vivoweb.vivo.selenium.tests; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; +import org.vivoweb.vivo.selenium.DriverFactory; +import org.vivoweb.vivo.selenium.SeleniumUtils; + +public class RebuildSearchIndex extends AbstractSeleniumTest { + @Test + public void rebuildSearchIndexTest() { + deleteAllVisibleCookies(); + + open("/"); + assertTitle("VIVO"); // assertTitle,VIVO + + logIn("testAdmin@cornell.edu", "Password"); + + clickAndWait(By.linkText("Site Admin")); // clickAndWait,link=Site Admin + assertTitle("VIVO Site Administration"); // assertTitle,VIVO Site Administration + + clickAndWait(By.linkText("Rebuild search index")); // clickAndWait,link=Rebuild search index + assertTitle("Rebuild Search Index"); // assertTitle,Rebuild Search Index + + clickAndWait(By.name("rebuild")); // clickAndWait,name=rebuild + assertTitle("Rebuild Search Index"); // assertTitle, Rebuild Search Index + + waitForTextPresent("Reset the search index and re-populate it."); // waitForTextPresent,Reset the search index and re-populate it. + + logOut(); // clickAndWait,Log out + } +} diff --git a/selenium/test-user-model.owl b/selenium/test-user-model.owl new file mode 100644 index 00000000..a84b1370 --- /dev/null +++ b/selenium/test-user-model.owl @@ -0,0 +1,58 @@ + + + + + testAdmin@cornell.edu + testAdmin + Test + Admin + DC647EB65E6711E155375218212B3964 + ACTIVE + 1 + 0 + + + + + johnCurator@cornell.edu + johnCurator + John + Curator + DC647EB65E6711E155375218212B3964 + ACTIVE + 1 + 0 + + + + + sallyEditor@cornell.edu + sallyEditor + Sally + Editor + DC647EB65E6711E155375218212B3964 + ACTIVE + 1 + 0 + + + + + joeUser@cornell.edu + joeUser + Joe + User + DC647EB65E6711E155375218212B3964 + ACTIVE + 1 + 0 + + + +