Skip to content

Commit

Permalink
more robust tests for the support and user account pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Reed committed Nov 25, 2014
1 parent 4ae5d6d commit f015cf2
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 68 deletions.
Expand Up @@ -202,7 +202,7 @@ protected void goToMainPage() {

protected void goBack() {
LOG.warn("goBack() is not supported on Safari!");
selenium.goBack();
m_driver.navigate().back();
waitForPageToLoad();
}

Expand Down
88 changes: 42 additions & 46 deletions smoke-test/src/test/java/org/opennms/smoketest/SupportPageTest.java
Expand Up @@ -28,71 +28,67 @@

package org.opennms.smoketest;

import static org.junit.Assert.assertNotNull;

import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class SupportPageTest extends OpenNMSSeleniumTestCase {
@Before
public void setUp() throws Exception {
super.setUp();
supportPage();
super.setUp();
supportPage();
}

private void supportPage() throws Exception {
frontPage();
clickAndWait("link=Support");
m_driver.get(BASE_URL + "opennms/support/index.htm");
}

@Test
public void a_testAllTextIsPresent() throws Exception {
waitForText("Commercial Support");
waitForText("About");
waitForText("Other Support Options");
public void testAllLinksArePresent() throws InterruptedException {
for (final String text : new String[] {
"About the OpenNMS Web Console",
"Release Notes",
"Online Documentation",
"Generate a System Report",
"Open a Bug or Enhancement Request",
"Chat with Developers on IRC"
}) {
assertNotNull("Link with text '" + text + "' must exist.", m_driver.findElement(By.linkText(text)));
}
}

@Test
public void b_testAllLinksArePresent() throws InterruptedException {
waitForElement("link=About the OpenNMS Web Console");
waitForElement("link=Release Notes");
waitForElement("link=Online Documentation");
waitForElement("link=Generate a System Report");
waitForElement("link=Open a Bug or Enhancement Request");
waitForElement("link=Chat with Developers on IRC");
waitForElement("link=the OpenNMS.com support page");
public void testAllFormsArePresent() throws InterruptedException {
final WebElement form = m_driver.findElement(By.cssSelector("form[action='support/index.htm']"));
assertNotNull(form);
assertNotNull(form.findElement(By.cssSelector("input[type=text][name=username]")));
assertNotNull(form.findElement(By.cssSelector("input[type=password][name=password]")));
}

@Test
public void c_testAllFormsArePresent() throws InterruptedException {
waitForText("Username:");
waitForText("Password:");
waitForElement("css=input[type=reset]");
assertEquals("Log In", selenium.getValue("css=input[type=submit]"));
public void testAboutPage() throws Exception {
final WebElement about = m_driver.findElement(By.linkText("About the OpenNMS Web Console"));
assertNotNull(about);
about.click();
assertNotNull(m_driver.findElement(By.xpath("//h3[text()='License and Copyright']")));
assertNotNull(m_driver.findElement(By.xpath("//td[@class='standardheader' and text()='Version:']")));
}

@Test
public void d_testAllLinks() throws Exception {
clickAndWait("link=About the OpenNMS Web Console");
waitForText("OpenNMS Web Console");
waitForText("License and Copyright");
waitForText("OSI Certified Open Source Software");
waitForText("Version:");

supportPage();
waitForElement("//a[@href='http://www.opennms.org/documentation/ReleaseNotesStable.html#whats-new']");
waitForElement("//a[@href='http://www.opennms.org/wiki/']");

clickAndWait("link=Generate a System Report");
waitForText("Plugins");
waitForText("Report Type");
waitForElement("name=formatter");
assertEquals("", selenium.getValue("css=input[type=submit]"));
waitForText("Output");
waitForText("Choose which plugins to enable:");

supportPage();
waitForElement("//a[@href='http://issues.opennms.org/']");
waitForElement("//a[@href='irc://irc.freenode.net/%23opennms']");
public void testSystemReport() throws Exception {
final WebElement generate = m_driver.findElement(By.linkText("Generate a System Report"));
assertNotNull(generate);
generate.click();
// checkboxes are selected by default
final WebElement allCheckbox = m_driver.findElement(By.cssSelector("input[type=checkbox][name=all]"));
assertNotNull(allCheckbox);
assertTrue(m_driver.findElement(By.cssSelector("input[type=checkbox][name=plugins][value=Java]")).isSelected());
// deselect the "all" checkbox
allCheckbox.click();
assertFalse(m_driver.findElement(By.cssSelector("input[type=checkbox][name=plugins][value=Java]")).isSelected());
}

}
Expand Up @@ -28,38 +28,43 @@

package org.opennms.smoketest;

import org.junit.FixMethodOrder;
import static org.junit.Assert.assertNotNull;

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class UserAccountPageTest extends OpenNMSSeleniumTestCase {
@Override
public void setUp() throws Exception {
super.setUp();

selenium.open("/opennms/account/selfService/index.jsp");
waitForPageToLoad();
}

@Test
public void a_testAllTextIsPresent() throws Exception {
waitForText("User Account Self-Service");
waitForText("Account Self-Service Options");
waitForText("require further");
m_driver.get(BASE_URL + "opennms/account/selfService/index.jsp");
}

@Test
public void b_testAllLinksArePresent() throws InterruptedException {
waitForElement("link=Change Password");
@Test
public void testExpectedTextAndLinksArePresent() throws Exception {
final List<WebElement> h3s = m_driver.findElements(By.tagName("h3"));
assertEquals(2, h3s.size());
assertEquals("User Account Self-Service", h3s.get(0).getText());
assertEquals("Account Self-Service Options", h3s.get(1).getText());
}

@Test
public void c_testAllLinks() throws InterruptedException {
clickAndWait("link=Change Password");
waitForText("Please enter the old and new passwords and confirm.");
waitForText("Current Password");
waitForElement("link=Cancel");
public void testSubmitWithWrongPassword() throws InterruptedException {
m_driver.findElement(By.linkText("Change Password")).click();
m_driver.findElement(By.cssSelector("input[type=password][name=oldpass]")).sendKeys("12345");
m_driver.findElement(By.cssSelector("input[type=password][name=pass1]")).sendKeys("23456");
m_driver.findElement(By.cssSelector("input[type=password][name=pass2]")).sendKeys("34567");
m_driver.findElement(By.cssSelector("input[type=submit][value=OK]")).click();

final WebDriverWait wait = new WebDriverWait(m_driver, TimeUnit.SECONDS.convert(LOAD_TIMEOUT, TimeUnit.MILLISECONDS));
assertNotNull(wait.until(ExpectedConditions.alertIsPresent()));
m_driver.switchTo().alert().dismiss();
}

}

0 comments on commit f015cf2

Please sign in to comment.