diff --git a/legacy/utilities/acceptance-tests/suites/AddNonPersonThings/CreateOrganization.html b/legacy/utilities/acceptance-tests/suites/AddNonPersonThings/CreateOrganization.html index 37ddb521..d07a4b9d 100644 --- a/legacy/utilities/acceptance-tests/suites/AddNonPersonThings/CreateOrganization.html +++ b/legacy/utilities/acceptance-tests/suites/AddNonPersonThings/CreateOrganization.html @@ -719,6 +719,7 @@ id=object ${KEY_DOWN} + click id=ui-active-menuitem 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 index 427d2247..ea2d4578 100644 --- a/selenium/src/test/java/org/vivoweb/vivo/selenium/tests/AbstractSeleniumTest.java +++ b/selenium/src/test/java/org/vivoweb/vivo/selenium/tests/AbstractSeleniumTest.java @@ -1,9 +1,11 @@ package org.vivoweb.vivo.selenium.tests; +import org.apache.commons.lang3.StringUtils; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.NoSuchElementException; @@ -20,6 +22,17 @@ import org.vivoweb.vivo.selenium.SeleniumUtils; public class AbstractSeleniumTest { protected WebDriver driver; + public void assertConfirmation(String text) { + WebDriverWait wait = new WebDriverWait(driver, 2); + wait.until(ExpectedConditions.alertIsPresent()); + Alert alert = driver.switchTo().alert(); + if (!StringUtils.isEmpty(text)) { + Assert.assertTrue(text.equalsIgnoreCase(alert.getText())); + } + alert.accept(); + driver.switchTo().defaultContent(); + } + protected void assertTitle(String title) { Assert.assertEquals(title, driver.getTitle()); } @@ -60,7 +73,9 @@ public class AbstractSeleniumTest { } protected void type(By by, String text) { - driver.findElement(by).sendKeys(text); + WebElement element = driver.findElement(by); + element.click(); + element.sendKeys(text); } protected void typeAutoCompleteSelect(By by, String text, Keys... keys) { @@ -77,11 +92,12 @@ public class AbstractSeleniumTest { } catch (InterruptedException e) { throw new RuntimeException(e); } catch (NoSuchElementException nse) { - for (int i = 0; i < text.length(); i++) { - element.sendKeys(Keys.BACK_SPACE); - } + element.clear(); +// for (int i = 0; i < text.length(); i++) { +// element.sendKeys(Keys.BACK_SPACE); +// } - if (count > 4) { + if (count > 10) { throw nse; } } @@ -119,7 +135,8 @@ public class AbstractSeleniumTest { } protected void verifyTextPresent(String text) { - Assert.assertNotNull(driver.findElement(xpathForTextPresent(text))); + Assert.assertTrue(driver.findElement(By.xpath("//body")).getText().contains(text)); +// Assert.assertNotNull(driver.findElement(xpathForTextPresent(text))); } protected boolean waitForElementPresent(By by) { 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 index 7db18ada..5b544f9c 100644 --- a/selenium/src/test/java/org/vivoweb/vivo/selenium/tests/CreateOrganization.java +++ b/selenium/src/test/java/org/vivoweb/vivo/selenium/tests/CreateOrganization.java @@ -330,13 +330,14 @@ public class CreateOrganization extends AbstractSeleniumTest { clickAndWait(By.id("submit")); assertTitle("Primate College of America"); - clickAndWait(By.cssSelector("li.nonSelectedGroupTab.clickable")); + clickAndWait(By.xpath("//div[@id='wrapper-content']/ul/li[14]")); clickAndWait(By.xpath("(//img[@alt='add'])[14]")); assertTitle("Edit"); type(By.id("typeSelector"), "Workshop"); type(By.id("activity"), "New Primate Students "); - type(By.id("startField-year"), "2006"); + type(By.id("startField-year"), "2003"); + type(By.id("endField-year"), "2006"); clickAndWait(By.id("submit")); assertTitle("Primate College of America"); @@ -453,14 +454,14 @@ public class CreateOrganization extends AbstractSeleniumTest { // Verify everything entered is displaying properly - clickAndWait(By.cssSelector("li.nonSelectedGroupTab.clickable")); + clickAndWait(By.xpath("//div[@id='wrapper-content']/ul/li[2]")); verifyTextPresent("PCoA"); verifyTextPresent("1959 -"); verifyElementPresent(By.linkText("B.S. Bachelor of Science")); verifyElementPresent(By.linkText("Primate Student of the Year")); verifyElementPresent(By.linkText("Best Primate College")); - clickAndWait(By.cssSelector("li.nonSelectedGroupTab.clickable")); + clickAndWait(By.xpath("//div[@id='wrapper-content']/ul/li[4]")); verifyTextPresent("faculty administrative position"); verifyElementPresent(By.linkText("Person, Polly")); verifyTextPresent("Person, Polly, Dr. 1999 -"); diff --git a/selenium/src/test/java/org/vivoweb/vivo/selenium/tests/DeleteOrganization.java b/selenium/src/test/java/org/vivoweb/vivo/selenium/tests/DeleteOrganization.java index 312249a0..23b885cc 100644 --- a/selenium/src/test/java/org/vivoweb/vivo/selenium/tests/DeleteOrganization.java +++ b/selenium/src/test/java/org/vivoweb/vivo/selenium/tests/DeleteOrganization.java @@ -13,6 +13,9 @@ public class DeleteOrganization extends AbstractSeleniumTest { logIn("testAdmin@cornell.edu", "Password"); + clickAndWait(By.linkText("Index")); + assertTitle("Index of Contents"); + clickAndWait(By.linkText("Organization")); assertTitle("Organization"); @@ -26,457 +29,130 @@ public class DeleteOrganization extends AbstractSeleniumTest { assertTitle("Individual Editing Form"); clickAndWait(By.name("_delete")); + assertConfirmation("Are you SURE you want to delete this individual? If in doubt, CANCEL."); - try { Thread.sleep(50000); } catch (Exception e) { } + assertTitle("VIVO Site Administration"); + + clickAndWait(By.linkText("Index")); + assertTitle("Index of Contents"); + + clickAndWait(By.linkText("Organization")); + assertTitle("Organization"); + + clickAndWait(By.linkText("Primate College of New York")); + assertTitle("Primate College of New York"); + + clickAndWait(By.linkText("Edit this individual")); + assertTitle("Individual Control Panel"); + + clickAndWait(By.xpath("//input[@value='Edit This Individual']")); + assertTitle("Individual Editing Form"); + + clickAndWait(By.name("_delete")); + assertConfirmation("Are you SURE you want to delete this individual? If in doubt, CANCEL."); + + assertTitle("VIVO Site Administration"); + + clickAndWait(By.linkText("Index")); + assertTitle("Index of Contents"); + + clickAndWait(By.linkText("Organization")); + assertTitle("Organization"); + + clickAndWait(By.linkText("Primate Colleges of the World")); + assertTitle("Primate Colleges of the World"); + + clickAndWait(By.linkText("Edit this individual")); + assertTitle("Individual Control Panel"); + + clickAndWait(By.xpath("//input[@value='Edit This Individual']")); + assertTitle("Individual Editing Form"); + + clickAndWait(By.name("_delete")); + assertConfirmation("Are you SURE you want to delete this individual? If in doubt, CANCEL."); + + assertTitle("VIVO Site Administration"); + + clickAndWait(By.linkText("Index")); + assertTitle("Index of Contents"); + + clickAndWait(By.linkText("Organization")); + assertTitle("Organization"); + + clickAndWait(By.linkText("Primate History Library")); + assertTitle("Primate History Library"); + + clickAndWait(By.linkText("Edit this individual")); + assertTitle("Individual Control Panel"); + + clickAndWait(By.xpath("//input[@value='Edit This Individual']")); + assertTitle("Individual Editing Form"); + + clickAndWait(By.name("_delete")); + assertConfirmation("Are you SURE you want to delete this individual? If in doubt, CANCEL."); + + assertTitle("VIVO Site Administration"); + + clickAndWait(By.linkText("Index")); + assertTitle("Index of Contents"); + + clickAndWait(By.linkText("Organization")); + assertTitle("Organization"); + + clickAndWait(By.linkText("Primate Research Laboratory")); + assertTitle("Primate Research Laboratory"); + + clickAndWait(By.linkText("Edit this individual")); + assertTitle("Individual Control Panel"); + + clickAndWait(By.xpath("//input[@value='Edit This Individual']")); + assertTitle("Individual Editing Form"); + + clickAndWait(By.name("_delete")); + assertConfirmation("Are you SURE you want to delete this individual? If in doubt, CANCEL."); + + assertTitle("VIVO Site Administration"); + + clickAndWait(By.linkText("Index")); + assertTitle("Index of Contents"); + + clickAndWait(By.linkText("Organization")); + assertTitle("Organization"); + + clickAndWait(By.linkText("Primate University of America")); + assertTitle("Primate University of America"); + + clickAndWait(By.linkText("Edit this individual")); + assertTitle("Individual Control Panel"); + + clickAndWait(By.xpath("//input[@value='Edit This Individual']")); + assertTitle("Individual Editing Form"); + + clickAndWait(By.name("_delete")); + assertConfirmation("Are you SURE you want to delete this individual? If in doubt, CANCEL."); + + assertTitle("VIVO Site Administration"); + + clickAndWait(By.linkText("Index")); + assertTitle("Index of Contents"); + + clickAndWait(By.linkText("Organization")); + assertTitle("Organization"); + + clickAndWait(By.linkText("Primates-r-us")); + assertTitle("Primates-r-us"); + + clickAndWait(By.linkText("Edit this individual")); + assertTitle("Individual Control Panel"); + + clickAndWait(By.xpath("//input[@value='Edit This Individual']")); + assertTitle("Individual Editing Form"); + + clickAndWait(By.name("_delete")); + assertConfirmation("Are you SURE you want to delete this individual? If in doubt, CANCEL."); + + assertTitle("VIVO Site Administration"); logOut(); } } -/* - - assertConfirmation - Are you SURE you want to delete this individual? If in doubt, CANCEL. - - - - waitForPageToLoad - 5000 - - - - assertTitle - VIVO Site Administration - - - - clickAndWait - link=Index - - - - assertTitle - Index of Contents - - - - clickAndWait - link=Organization - - - - assertTitle - Organization - - - - clickAndWait - link=Primate College of New York - - - - assertTitle - Primate College of New York - - - - clickAndWait - link=Edit this individual - - - - assertTitle - Individual Control Panel - - - - clickAndWait - //input[@value='Edit This Individual'] - - - - assertTitle - Individual Editing Form - - - - click - name=_delete - - - - assertConfirmation - Are you SURE you want to delete this individual? If in doubt, CANCEL. - - - - waitForPageToLoad - 5000 - - - - assertTitle - VIVO Site Administration - - - - clickAndWait - link=Index - - - - assertTitle - Index of Contents - - - - clickAndWait - link=Organization - - - - assertTitle - Organization - - - - clickAndWait - link=Primate Colleges of the World - - - - assertTitle - Primate Colleges of the World - - - - clickAndWait - link=Edit this individual - - - - assertTitle - Individual Control Panel - - - - clickAndWait - //input[@value='Edit This Individual'] - - - - assertTitle - Individual Editing Form - - - - click - name=_delete - - - - assertConfirmation - Are you SURE you want to delete this individual? If in doubt, CANCEL. - - - - waitForPageToLoad - 5000 - - - - assertTitle - VIVO Site Administration - - - - clickAndWait - link=Index - - - - assertTitle - Index of Contents - - - - clickAndWait - link=Organization - - - - assertTitle - Organization - - - - clickAndWait - link=Primate History Library - - - - assertTitle - Primate History Library - - - - clickAndWait - link=Edit this individual - - - - assertTitle - Individual Control Panel - - - - clickAndWait - //input[@value='Edit This Individual'] - - - - assertTitle - Individual Editing Form - - - - click - name=_delete - - - - assertConfirmation - Are you SURE you want to delete this individual? If in doubt, CANCEL. - - - - waitForPageToLoad - 5000 - - - - assertTitle - VIVO Site Administration - - - - clickAndWait - link=Index - - - - assertTitle - Index of Contents - - - - clickAndWait - link=Organization - - - - assertTitle - Organization - - - - clickAndWait - link=Primate Research Laboratory - - - - assertTitle - Primate Research Laboratory - - - - clickAndWait - link=Edit this individual - - - - assertTitle - Individual Control Panel - - - - clickAndWait - //input[@value='Edit This Individual'] - - - - assertTitle - Individual Editing Form - - - - click - name=_delete - - - - assertConfirmation - Are you SURE you want to delete this individual? If in doubt, CANCEL. - - - - waitForPageToLoad - 5000 - - - - assertTitle - VIVO Site Administration - - - - clickAndWait - link=Index - - - - assertTitle - Index of Contents - - - - clickAndWait - link=Organization - - - - assertTitle - Organization - - - - clickAndWait - link=Primate University of America - - - - assertTitle - Primate University of America - - - - clickAndWait - link=Edit this individual - - - - assertTitle - Individual Control Panel - - - - clickAndWait - //input[@value='Edit This Individual'] - - - - assertTitle - Individual Editing Form - - - - click - name=_delete - - - - assertConfirmation - Are you SURE you want to delete this individual? If in doubt, CANCEL. - - - - waitForPageToLoad - 5000 - - - - assertTitle - VIVO Site Administration - - - - clickAndWait - link=Index - - - - assertTitle - Index of Contents - - - - clickAndWait - link=Organization - - - - assertTitle - Organization - - - - clickAndWait - link=Primates-r-us - - - - assertTitle - Primates-r-us - - - - clickAndWait - link=Edit this individual - - - - assertTitle - Individual Control Panel - - - - clickAndWait - //input[@value='Edit This Individual'] - - - - assertTitle - Individual Editing Form - - - - click - name=_delete - - - - assertConfirmation - Are you SURE you want to delete this individual? If in doubt, CANCEL. - - - - waitForPageToLoad - 5000 - - - - assertTitle - VIVO Site Administration - - - - clickAndWait - link=Index - - - - assertTitle - Index of Contents - - - - */ \ No newline at end of file