From e3acd5f3a03aec23a25e78102716d8bd0a8c3cce Mon Sep 17 00:00:00 2001 From: Lee Breisacher Date: Mon, 24 Jun 2013 20:52:24 -0700 Subject: [PATCH] add a check that all modules are running --- .../openmrs/reference/page/ModulesPage.java | 17 +++++++ .../org/openmrs/reference/CheckModules.java | 44 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 ui-tests/src/main/java/org/openmrs/reference/page/ModulesPage.java create mode 100644 ui-tests/src/test/java/org/openmrs/reference/CheckModules.java diff --git a/ui-tests/src/main/java/org/openmrs/reference/page/ModulesPage.java b/ui-tests/src/main/java/org/openmrs/reference/page/ModulesPage.java new file mode 100644 index 000000000..f819d6ad2 --- /dev/null +++ b/ui-tests/src/main/java/org/openmrs/reference/page/ModulesPage.java @@ -0,0 +1,17 @@ +package org.openmrs.reference.page; + + +import org.openqa.selenium.WebDriver; + +public class ModulesPage extends AbstractBasePage { + + public ModulesPage(WebDriver driver) { + super(driver); + } + + @Override + public String expectedUrlPath() { + return "/openmrs/admin/modules/module.list"; + } +} + diff --git a/ui-tests/src/test/java/org/openmrs/reference/CheckModules.java b/ui-tests/src/test/java/org/openmrs/reference/CheckModules.java new file mode 100644 index 000000000..9fc1017ec --- /dev/null +++ b/ui-tests/src/test/java/org/openmrs/reference/CheckModules.java @@ -0,0 +1,44 @@ +package org.openmrs.reference; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.openmrs.reference.page.HomePage; +import org.openmrs.reference.page.LoginPage; +import org.openmrs.reference.page.ModulesPage; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +public class CheckModules extends TestBase { + private LoginPage loginPage; + private HomePage homePage; + private ModulesPage modulesPage; + + @Before + public void setUp() { + loginPage = new LoginPage(driver); + homePage = new HomePage(driver); + modulesPage = new ModulesPage(driver); + } + + @Test + public void checkModules() throws Exception { + assertPage(loginPage); + loginPage.loginAsAdmin(); + assertPage(homePage); + homePage.gotoPage("/admin/modules/module.list"); + assertPage(modulesPage); + // Get the modulesListing
, which contains the table of modules. + WebElement moduleListing = modulesPage.getElementById("moduleListing"); + // Grab all the elements from the first column of the table. + List firstColumn = moduleListing.findElements(By.xpath("table/tbody/tr/td[1]/input")); + for (WebElement eachModule : firstColumn) { + // The name attr on the elements should all be "stop" which indicates the module is correctly started. + // If not, then grab the text from the 3rd column to show which module is not started. + Assert.assertEquals("module not ready: " + eachModule.findElement(By.xpath("../../td[3]")).getText(), "stop", eachModule.getAttribute("name")); + } + } + +}