From cdb9831f68b884fc26589513dfd82555f673546f Mon Sep 17 00:00:00 2001 From: honchar Date: Wed, 12 Aug 2015 23:20:39 +0200 Subject: [PATCH] Created selenidetest module for automation tests, added some tests PageResource.html and PageResource.java: changed the id of the element from basichSearch to basicSearch --- .../page/admin/resources/PageResources.html | 2 +- .../page/admin/resources/PageResources.java | 2 +- testing/selenidetest/pom.xml | 86 +++++++++ .../testing/selenide/tests/BaseTest.java | 54 ++++++ .../testing/selenide/tests/LoginTest.java | 24 +++ .../tests/account/CreateAccountTest.java | 79 ++++++++ .../resource/CheckResourceConnectionTest.java | 48 +++++ .../tests/resource/ImportResourceTest.java | 67 +++++++ .../selenide/tests/resource/ResourceUtil.java | 44 +++++ .../selenide/tests/user/CreateUserTest.java | 51 +++++ .../testing/selenide/tests/user/UserUtil.java | 49 +++++ .../src/test/resources/logback-test.xml | 30 +++ .../src/test/resources/spring-module.xml | 23 +++ testing/selenidetest/testng.xml | 50 +++++ .../testing/selenium/tests/BaseTest.java | 182 ------------------ .../testing/selenium/tests/LoginTest.java | 60 ------ .../tests/account/AddAccountTest.java | 87 --------- .../tests/resource/AddResourceTest.java | 59 ------ .../selenium/tests/user/CreateUserTest.java | 74 ------- .../selenium/tests/user/DeleteUserTest.java | 50 ----- 20 files changed, 607 insertions(+), 514 deletions(-) create mode 100644 testing/selenidetest/pom.xml create mode 100644 testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/BaseTest.java create mode 100644 testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/LoginTest.java create mode 100644 testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/account/CreateAccountTest.java create mode 100644 testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/resource/CheckResourceConnectionTest.java create mode 100644 testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/resource/ImportResourceTest.java create mode 100644 testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/resource/ResourceUtil.java create mode 100644 testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/user/CreateUserTest.java create mode 100644 testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/user/UserUtil.java create mode 100644 testing/selenidetest/src/test/resources/logback-test.xml create mode 100644 testing/selenidetest/src/test/resources/spring-module.xml create mode 100644 testing/selenidetest/testng.xml delete mode 100644 testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/BaseTest.java delete mode 100644 testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/LoginTest.java delete mode 100644 testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/account/AddAccountTest.java delete mode 100644 testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/resource/AddResourceTest.java delete mode 100644 testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/user/CreateUserTest.java delete mode 100644 testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/user/DeleteUserTest.java diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResources.html b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResources.html index bc96e71ad10..3ce5bb5e704 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResources.html +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResources.html @@ -22,7 +22,7 @@
-
+
diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResources.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResources.java index 1d267fc7949..d1076de40f2 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResources.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResources.java @@ -104,7 +104,7 @@ public class PageResources extends PageAdminResources { private static final String OPERATION_DELETE_HOSTS = DOT_CLASS + "deleteHosts"; private static final String OPERATION_CONNECTOR_DISCOVERY = DOT_CLASS + "connectorDiscovery"; - private static final String ID_BASIC_SEARCH = "basichSearch"; + private static final String ID_BASIC_SEARCH = "basicSearch"; private static final String ID_SEARCH_FORM = "searchForm"; private static final String ID_DELETE_RESOURCES_POPUP = "deleteResourcesPopup"; private static final String ID_DELETE_HOSTS_POPUP = "deleteHostsPopup"; diff --git a/testing/selenidetest/pom.xml b/testing/selenidetest/pom.xml new file mode 100644 index 00000000000..de10f95f8e6 --- /dev/null +++ b/testing/selenidetest/pom.xml @@ -0,0 +1,86 @@ + + + 4.0.0 + Selenide tests + com.evolveum.midpoint.testing + selenidetest + 3.2-SNAPSHOT + + + testing + com.evolveum.midpoint + 3.2-SNAPSHOT + + + https://github.com/Evolveum/midpoint.git + git@github.com:Evolveum/midpoint.git + https://fisheye.evolveum.com/browse/midPoint + + + Evolveum + http://www.evolveum.com + + + + Apache License v2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + Atlassian JIRA + http://jira.evolveum.com/ + + + + + maven-surefire-plugin + 2.8.1 + + pertest + classes + false + 1 + alphabetical + + + + + + + + + + + + + com.codeborne + selenide + 2.21 + test + + + org.testng + testng + test + + + + org.json + json + 20090211 + + + org.springframework + spring-context + 4.0.6.RELEASE + + + org.springframework + spring-beans + 4.0.6.RELEASE + + + \ No newline at end of file diff --git a/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/BaseTest.java b/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/BaseTest.java new file mode 100644 index 00000000000..ac0e1e752ed --- /dev/null +++ b/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/BaseTest.java @@ -0,0 +1,54 @@ +package com.evolveum.midpoint.testing.selenide.tests; + +import org.openqa.selenium.By; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.stereotype.Component; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.springframework.web.context.support.SpringBeanAutowiringSupport; +import org.testng.ITestContext; +import org.testng.annotations.BeforeClass; + +import static com.codeborne.selenide.Condition.enabled; +import static com.codeborne.selenide.Condition.visible; +import static com.codeborne.selenide.Selenide.$; +import static com.codeborne.selenide.Selenide.open; + +/** + * Created by Kate on 09.08.2015. + */ +@ContextConfiguration(locations = {"classpath:spring-module.xml"}) +public class BaseTest extends AbstractTestNGSpringContextTests { + private static final String PARAM_SITE_URL = "site.url"; + private static final String PARAM_USER_LOGIN = "user.login"; + private static final String PARAM_USER_PASSWORD = "user.password"; + + public String siteUrl; + public String userLogin; + public String userPassword; + + + public BaseTest(){ + SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this); + } + + @BeforeClass(alwaysRun = true) + public void beforeClass(ITestContext context) { + siteUrl = context.getCurrentXmlTest().getParameter(PARAM_SITE_URL); + userLogin = context.getCurrentXmlTest().getParameter(PARAM_USER_LOGIN); + userPassword = context.getCurrentXmlTest().getParameter(PARAM_USER_PASSWORD); + } + + public void login(String siteUrl, String username, String password) { + //opens login page + open(siteUrl); + //enter login value + $(By.name("username")).shouldBe(visible).setValue(username); + //enter password value + $(By.name("password")).shouldBe(visible).setValue(password); + //click Sign in button + $(By.cssSelector("html.no-js body div.mp-main-container div.row.mainContainer div.row div.col-md-offset-2.col-md-8.col-lg-offset-4.col-lg-4 div.panel.panel-default div.panel-body form#id6.form-horizontal input.btn.btn-primary.pull-right")).shouldBe(enabled).click(); + } + + +} diff --git a/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/LoginTest.java b/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/LoginTest.java new file mode 100644 index 00000000000..a42bcbc107e --- /dev/null +++ b/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/LoginTest.java @@ -0,0 +1,24 @@ + package com.evolveum.midpoint.testing.selenide.tests; + +import org.openqa.selenium.By; +import org.testng.annotations.Test; +import static com.codeborne.selenide.Selenide.*; +import static com.codeborne.selenide.Condition.*; + +/** + * Created by Kate on 07.08.2015. + */ +public class LoginTest extends BaseTest{ + + /** + * Log in to system as administrator/5ecr3t + */ + @Test + public void loginWithCorrectCredentialsTest(){ + //perform login + login(siteUrl, userLogin, userPassword); + + //check if welcome message appears after user logged in + $(By.cssSelector("html.no-js body div.mp-main-container div.row.mainContainer div.page-header h1 small")).shouldHave(text("welcome to midPoint")); + } +} diff --git a/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/account/CreateAccountTest.java b/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/account/CreateAccountTest.java new file mode 100644 index 00000000000..61615fa3dcd --- /dev/null +++ b/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/account/CreateAccountTest.java @@ -0,0 +1,79 @@ +package com.evolveum.midpoint.testing.selenide.tests.account; + +/** + * Created by Kate on 09.08.2015. + */ + +import com.evolveum.midpoint.testing.selenide.tests.BaseTest; +import com.evolveum.midpoint.testing.selenide.tests.resource.ImportResourceTest; +import com.evolveum.midpoint.testing.selenide.tests.resource.ResourceUtil; +import com.evolveum.midpoint.testing.selenide.tests.user.UserUtil; +import org.openqa.selenium.By; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.testng.annotations.Test; + +import static com.codeborne.selenide.Condition.*; +import static com.codeborne.selenide.Selenide.$; + +@Component +public class CreateAccountTest extends BaseTest{ + + @Autowired + UserUtil userUtil; + + @Autowired + ResourceUtil resourceUtil; + + @Autowired + ImportResourceTest importResourceTest; + + @Autowired + BaseTest baseTest; + + /** + * Prerequirement: Test user is to be created (see CreateUserTest.createUserTest()) + */ + @Test + public void createOpendjAccountForUser(){ + //open Users page + userUtil.openListUsersPage(); + + //search for user in users list + userUtil.searchForUser(userUtil.getTestUserName()).shouldBe(visible).click(); + + //click on the menu icon in the Accounts section + $(By.xpath("/html/body/div[4]/div/form/div[3]/div[2]/div[1]/div/div[2]/ul/li/a")).shouldBe(visible).click(); + //click on the Add account menu item + $(By.linkText("Add account")).shouldBe(visible).click(); + + //search for OpenDJ resource in resources list in the opened Select resource(s) window + resourceUtil.searchForOpendjResource(resourceUtil.getTestResourceName(), "/html/body/div[6]/form/div/div[2]/div/div/div/div[2]/div/div/div/div/div/div[2]/div/table/tbody/tr/td[2]/div"); + + //select check box in the first row for "Localhost OpenDJ (no extension schema)" resource + $(By.name("resourcePopup:content:table:table:body:rows:4:cells:1:cell:check")).shouldBe(visible).click(); + //click Add resource(s) button + $(By.linkText("Add resource(s)")).shouldBe(enabled).click(); + + //Fill in account fields: Common name, Surname, first and second password fields + $(By.name("accounts:accountList:0:account:body:containers:0:container:properties:3:property:values:0:value:valueContainer:input:input")).shouldBe(visible).setValue("Common name"); + $(By.name("accounts:accountList:0:account:body:containers:0:container:properties:42:property:values:0:value:valueContainer:input:input")).shouldBe(visible).setValue("Surname"); + $(By.name("accounts:accountList:0:account:body:containers:5:container:properties:0:property:values:0:value:valueContainer:input:password2")).shouldBe(visible).setValue("password"); + $(By.name("accounts:accountList:0:account:body:containers:5:container:properties:0:property:values:0:value:valueContainer:input:password1")).shouldBe(visible).setValue("password"); + + //click Save button + $(By.xpath("/html/body/div[4]/div/form/div[6]/a[2]")).shouldHave(text("Save")).click(); + + //check if Success message appears after user saving + $(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div[1]/div[1]/span")).shouldHave(text("Success")); + + //search for user in users list + userUtil.searchForUser(userUtil.getTestUserName()).shouldBe(visible).click(); + + //check if the created account is displayed in the Accounts section + $(By.linkText(resourceUtil.getTestResourceName())).shouldBe(visible); + + } + + +} diff --git a/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/resource/CheckResourceConnectionTest.java b/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/resource/CheckResourceConnectionTest.java new file mode 100644 index 00000000000..cb34e7b5de6 --- /dev/null +++ b/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/resource/CheckResourceConnectionTest.java @@ -0,0 +1,48 @@ +package com.evolveum.midpoint.testing.selenide.tests.resource; + +import com.evolveum.midpoint.testing.selenide.tests.BaseTest; +import org.openqa.selenium.By; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.testng.annotations.Test; + +import static com.codeborne.selenide.Condition.*; +import static com.codeborne.selenide.Selenide.$; +import static com.codeborne.selenide.Selenide.title; + +/** + * Created by Kate on 09.08.2015. + */ +@Component +public class CheckResourceConnectionTest extends BaseTest{ + + @Autowired + ImportResourceTest importResourceTest; + + @Autowired + BaseTest baseTest; + + @Autowired + ResourceUtil resourceUtil; + + @Test + public void checkOpendjResourceConnectionTest(){ + //open Resources -> List Resources + $(By.xpath("/html/body/div[3]/div/div[2]/ul[1]/li[4]/a")).shouldHave(text("Resources")).click(); + $(By.linkText("List resources")).click(); + + //search for OpenDJ resource in resources list + resourceUtil.searchForOpendjResource(resourceUtil.getTestResourceName(), "/html/body/div[4]/div/form[2]/div[2]/table/tbody/tr/td[2]/div/a/span").click(); + + //click Test connection button + $(By.xpath("/html/body/div[4]/div/form/div[4]/a[1]")).should(appear).click(); + + //check if all statuses are succeeded + $(By.xpath("/html/body/div[4]/div/form/div[2]/div[2]/div/table/tbody/tr[1]/td[2]/i")).shouldHave(hasAttribute("title", "Success")); + $(By.xpath("/html/body/div[4]/div/form/div[2]/div[2]/div/table/tbody/tr[2]/td[2]/i")).shouldHave(hasAttribute("title", "Success")); + $(By.xpath("/html/body/div[4]/div/form/div[2]/div[2]/div/table/tbody/tr[3]/td[2]/i")).shouldHave(hasAttribute("title", "Success")); + $(By.xpath("/html/body/div[4]/div/form/div[2]/div[2]/div/table/tbody/tr[4]/td[2]/i")).shouldHave(hasAttribute("title", "Success")); + $(By.xpath("/html/body/div[4]/div/form/div[2]/div[2]/div/table/tbody/tr[5]/td[2]/i")).shouldHave(hasAttribute("title", "Success")); + + } +} diff --git a/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/resource/ImportResourceTest.java b/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/resource/ImportResourceTest.java new file mode 100644 index 00000000000..809075e0507 --- /dev/null +++ b/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/resource/ImportResourceTest.java @@ -0,0 +1,67 @@ +package com.evolveum.midpoint.testing.selenide.tests.resource; + +import com.codeborne.selenide.SelenideElement; +import com.evolveum.midpoint.testing.selenide.tests.BaseTest; +import org.openqa.selenium.By; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.testng.annotations.Test; + +import java.io.File; + +import static com.codeborne.selenide.Condition.*; +import static com.codeborne.selenide.Selenide.$; + +/** + * Created by Kate on 09.08.2015. + */ +@Component +public class ImportResourceTest extends BaseTest{ + + @Autowired + BaseTest baseTest; + + @Autowired + ResourceUtil resourceUtil; + + + /** + * Import OpenDJ resource test (file "opendj-localhost-resource-sync-no-extension-advanced.xml" is used) + */ + @Test + public void importOpendjResourceTest(){ + + //click Configuration menu + $(By.xpath("/html/body/div[3]/div/div[2]/ul[1]/li[8]/a")) + .shouldHave(text("Configuration")).click(); + + //click Import object menu item + $(By.linkText("Import object")).click(); + + //select Overwrite existing object check box + $(By.name("importOptions:overwriteExistingObject")).setSelected(true); + + //Specify the file to be uploaded + File test = new File("../../samples/resources/opendj/opendj-localhost-resource-sync-no-extension-advanced.xml"); + $(By.name("input:inputFile:fileInput")).uploadFile(test); + + //click Import object button + $(By.xpath("/html/body/div[4]/div/form/div[6]/a")).shouldHave(text("Import object")).click(); + + //check if Success message appears after resource importing + $(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div[1]/div[1]/span")).shouldHave(text("Success")); + + //open Resources -> List Resources + $(By.xpath("/html/body/div[3]/div/div[2]/ul[1]/li[4]/a")).shouldHave(text("Resources")).click(); + $(By.linkText("List resources")).click(); + + //search for OpenDJ resource in resources list + resourceUtil.searchForOpendjResource(resourceUtil.getTestResourceName(), "/html/body/div[4]/div/form[2]/div[2]/table/tbody/tr/td[2]/div/a/span") + .shouldBe(visible); + + } + + + + +} diff --git a/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/resource/ResourceUtil.java b/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/resource/ResourceUtil.java new file mode 100644 index 00000000000..7bbc1648801 --- /dev/null +++ b/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/resource/ResourceUtil.java @@ -0,0 +1,44 @@ +package com.evolveum.midpoint.testing.selenide.tests.resource; + +import com.codeborne.selenide.SelenideElement; +import org.openqa.selenium.By; +import org.springframework.stereotype.Component; + +import java.util.NoSuchElementException; + +import static com.codeborne.selenide.Condition.text; +import static com.codeborne.selenide.Condition.visible; +import static com.codeborne.selenide.Selenide.$; + +/** + * Created by Kate on 12.08.2015. + */ +@Component +public class ResourceUtil { + private String testResourceName; + + /** + * searches for resource in the resource list + * with the specified name resourceName + * + * @param resourceName + * @param resourceSearchResultPath + * @return + */ + public SelenideElement searchForOpendjResource(String resourceName, String resourceSearchResultPath) { + //search for OpenDJ resource in resources list + $(By.name("basicSearch:searchText")).shouldBe(visible).setValue(resourceName); + $(By.linkText("Search")).click(); + //check if resource is found during the search + return $(By.xpath(resourceSearchResultPath)).shouldHave(text(resourceName)); + } + + public String getTestResourceName() { + return testResourceName; + } + + public void setTestResourceName(String testResourceName) { + this.testResourceName = testResourceName; + } + +} diff --git a/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/user/CreateUserTest.java b/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/user/CreateUserTest.java new file mode 100644 index 00000000000..7ccbcff0bc9 --- /dev/null +++ b/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/user/CreateUserTest.java @@ -0,0 +1,51 @@ +package com.evolveum.midpoint.testing.selenide.tests.user; + +import com.codeborne.selenide.SelenideElement; +import com.evolveum.midpoint.testing.selenide.tests.BaseTest; +import org.openqa.selenium.By; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.testng.annotations.Test; + +import static com.codeborne.selenide.Selenide.$; +import static com.codeborne.selenide.Condition.*; + +/** + * Created by Kate on 09.08.2015. + */ +@Component +public class CreateUserTest extends BaseTest{ + + @Autowired + BaseTest baseTest; + + @Autowired + UserUtil userUtil; + + /** + * Create user test. The name of the user is specified in the testng.xml, "test.user.name" parameter + */ + @Test + public void createUserTest(){ + //click Users menu + $(By.cssSelector("html.no-js body div.navbar.navbar-default.navbar-fixed-top div div.navbar-collapse.collapse ul.nav.navbar-nav li.dropdown a.dropdown-toggle")).shouldHave(text("Users")).click(); + + //click New user menu item + $(By.linkText("New user")).click(); + + //set value to Name field + $(By.name("userForm:body:containers:0:container:properties:0:property:values:0:value:valueContainer:input:input")).shouldBe(visible).setValue(userUtil.getTestUserName()); + + //click Save button + $(By.xpath("/html/body/div[4]/div/form/div[5]/a[2]")).shouldHave(text("Save")).click(); + + //check if Success message appears after user saving + + $(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div[1]/div[1]/span")).shouldHave(text("Success")); + + //search for the created in users list + userUtil.searchForUser(userUtil.getTestUserName()).shouldBe(visible); + } + + +} diff --git a/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/user/UserUtil.java b/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/user/UserUtil.java new file mode 100644 index 00000000000..08b736bf8b5 --- /dev/null +++ b/testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/user/UserUtil.java @@ -0,0 +1,49 @@ +package com.evolveum.midpoint.testing.selenide.tests.user; + +import com.codeborne.selenide.SelenideElement; +import org.openqa.selenium.By; +import org.springframework.stereotype.Component; + +import static com.codeborne.selenide.Condition.appear; +import static com.codeborne.selenide.Condition.text; +import static com.codeborne.selenide.Condition.visible; +import static com.codeborne.selenide.Selenide.$; + +/** + * Created by Kate on 12.08.2015. + */ +@Component +public class UserUtil { + private String testUserName; + + /** + * Looks for the user in the user list with userName value + * @return + */ + public SelenideElement searchForUser(String userName){ + //search for user in users list + $(By.name("basicSearch:searchText")).shouldBe(visible).setValue(userName); + $(By.xpath("/html/body/div[4]/div/div[4]/form/span/a")).shouldHave(text("Search")).click(); + //check if user is found during users search + return $(By.linkText(userName)); + } + + public void openListUsersPage(){ + //click Users menu + $(By.cssSelector("html.no-js body div.navbar.navbar-default.navbar-fixed-top div div.navbar-collapse.collapse ul.nav.navbar-nav li.dropdown a.dropdown-toggle")).shouldHave(text("Users")).click(); + + //click New user menu item + $(By.linkText("List users")).click(); + + //check if Users page is opened + $(By.cssSelector("html.no-js body div.mp-main-container div.row.mainContainer div.page-header h1")).shouldHave(text("Users in midPoint")); + + } + public void setTestUserName(String testUserName) { + this.testUserName = testUserName; + } + + public String getTestUserName() { + return testUserName; + } +} diff --git a/testing/selenidetest/src/test/resources/logback-test.xml b/testing/selenidetest/src/test/resources/logback-test.xml new file mode 100644 index 00000000000..d3649e5b2e5 --- /dev/null +++ b/testing/selenidetest/src/test/resources/logback-test.xml @@ -0,0 +1,30 @@ + + + + + + ./target/test.log + + %date [%thread] %-5level \(%logger{46}\): %message%n + + + + + + + + diff --git a/testing/selenidetest/src/test/resources/spring-module.xml b/testing/selenidetest/src/test/resources/spring-module.xml new file mode 100644 index 00000000000..3ec34d2e92e --- /dev/null +++ b/testing/selenidetest/src/test/resources/spring-module.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/testing/selenidetest/testng.xml b/testing/selenidetest/testng.xml new file mode 100644 index 00000000000..a16f762221e --- /dev/null +++ b/testing/selenidetest/testng.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/BaseTest.java b/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/BaseTest.java deleted file mode 100644 index 5d1ddbde26b..00000000000 --- a/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/BaseTest.java +++ /dev/null @@ -1,182 +0,0 @@ -package com.evolveum.midpoint.testing.selenium.tests; - - -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.google.common.base.Function; -import org.apache.commons.lang.StringUtils; -import org.openqa.selenium.*; -import org.openqa.selenium.firefox.FirefoxDriver; -import org.openqa.selenium.support.ui.*; -import org.testng.ITestContext; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; - -import java.awt.*; -import java.awt.datatransfer.StringSelection; -import java.awt.event.KeyEvent; -import java.util.concurrent.TimeUnit; - - -/** - * @author lazyman - */ -public class BaseTest { - - private static final String PARAM_SITE_URL = "site.url"; - private static final String PARAM_TIMEOUT_PAGE = "timeout.page"; - private static final String PARAM_TIMEOUT_WAIT = "timeout.wait"; - private static final String PARAM_TIMEOUT_SCRIPT = "timeout.script"; - private static final String PARAM_USER_LOGIN = "user.login"; - private static final String PARAM_USER_PASSWORD = "user.password"; - private static final String MIDPOINT_SAMPLES_FOLDER_PATH = "midpoint.samples.folder.path"; - - private static final Trace LOGGER = TraceManager.getTrace(BaseTest.class); - private String siteUrl; - protected String userLogin; - protected String userPassword; - protected String samplesFolderPath; - protected WebDriver driver; - private WebDriverWait waitDriver; - - - public String getSiteUrl() { - return siteUrl; - } - - @BeforeClass(alwaysRun = true) - public void beforeClass(ITestContext context) { - siteUrl = context.getCurrentXmlTest().getParameter(PARAM_SITE_URL); - userLogin = context.getCurrentXmlTest().getParameter(PARAM_USER_LOGIN); - userPassword = context.getCurrentXmlTest().getParameter(PARAM_USER_PASSWORD); - userPassword = context.getCurrentXmlTest().getParameter(PARAM_USER_PASSWORD); - samplesFolderPath = context.getCurrentXmlTest().getParameter(MIDPOINT_SAMPLES_FOLDER_PATH); - - int wait = getTimeoutParameter(context, PARAM_TIMEOUT_WAIT, 5); - int page = getTimeoutParameter(context, PARAM_TIMEOUT_PAGE, 5); - int script = getTimeoutParameter(context, PARAM_TIMEOUT_SCRIPT,5); - LOGGER.info("Site url: '{}'. Timeouts: implicit wait({}), page load ({}), script({})", - new Object[]{siteUrl, wait, page, script}); - - driver = new FirefoxDriver(); - - WebDriver.Timeouts timeouts = driver.manage().timeouts(); - timeouts.implicitlyWait(wait, TimeUnit.SECONDS); - timeouts.pageLoadTimeout(page, TimeUnit.SECONDS); - timeouts.setScriptTimeout(script, TimeUnit.SECONDS); - - waitDriver = new WebDriverWait(driver, 10); - } - - private int getTimeoutParameter(ITestContext context, String param, int defaultValue) { - String value = context.getCurrentXmlTest().getParameter(param); - if (StringUtils.isEmpty(value) || !value.matches("[0]*[1-9]+[0-9]*")) { - return defaultValue; - } - - return Integer.parseInt(value); - } - - @AfterClass(alwaysRun = true) - public void afterClass() { - driver.quit(); - } - - protected void performLogin(WebDriver driver) { - performLogin(driver, userLogin, userPassword); - } - - protected void performLogin(WebDriver driver, String username, String password) { - driver.get(siteUrl + "/login"); - - driver.findElement(By.name("username")).clear(); - driver.findElement(By.name("username")).sendKeys(username); - driver.findElement(By.name("password")).clear(); - driver.findElement(By.name("password")).sendKeys(password); - - driver.findElement(By.xpath("//input[@value='Sign in']")).click(); - } - - protected void performLogout(WebDriver driver) { -//todo - } - - /** - * Set parameter string to the system's clipboard. - */ - public static void setClipboardData(String string) { - //StringSelection is a class that can be used for copy and paste operations. - StringSelection stringSelection = new StringSelection(string); - Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null); - } - - /** - * Upload file from local machine - * @param fileLocation - */ - public void uploadFile(String fileLocation) { - try { - //Setting clipboard with file location - setClipboardData(fileLocation); - - //native key strokes for CTRL, V and ENTER keys - Robot robot = new Robot(); - - robot.keyPress(KeyEvent.VK_CONTROL); - robot.keyPress(KeyEvent.VK_V); - - robot.keyRelease(KeyEvent.VK_V); - robot.keyRelease(KeyEvent.VK_CONTROL); - Thread.sleep(3000); - robot.keyPress(KeyEvent.VK_ENTER); - robot.keyRelease(KeyEvent.VK_ENTER); - - - } catch (Exception e) { - LOGGER.error(e.getMessage()); - } - } - - public void implicitWait(long time){ - driver.manage().timeouts().implicitlyWait(time, TimeUnit.SECONDS); - } - - public WebElement fluentWait(final By locator) { - Wait wait = new FluentWait(driver) - .withTimeout(30, TimeUnit.SECONDS) - .pollingEvery(5, TimeUnit.SECONDS) - .ignoring(NoSuchElementException.class); - - WebElement element = wait.until( - new Function() { - public WebElement apply(WebDriver driver) { - return driver.findElement(locator); - } - } - ); - return element; - } - - /** - * Returns WebElement after it becomes clickable - */ - public WebElement waitToBeClickable(By by) { - WebElement element = waitDriver.until(ExpectedConditions.elementToBeClickable(by)); - return element; - } - - /** - * Returns WebElement after the text was entered to it - */ - public boolean waitForTextPresented(By by, String text) { - return waitDriver.until(ExpectedConditions.textToBePresentInElementLocated(by, text)); - } - - protected void logTestMethodStart(Trace LOGGER, String method) { - LOGGER.info("===[" + method + " START]==="); - } - - protected void logTestMethodFinish(Trace LOGGER, String method) { - LOGGER.info("===[" + method + " FINISH]==="); - } -} diff --git a/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/LoginTest.java b/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/LoginTest.java deleted file mode 100644 index 30b9ea92011..00000000000 --- a/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/LoginTest.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.evolveum.midpoint.testing.selenium.tests; - -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; - - -import org.openqa.selenium.*; -import org.testng.Assert; -import org.testng.annotations.Test; - -/** - * @author honchar - */ -public class LoginTest extends BaseTest { - private static final Trace LOGGER = TraceManager.getTrace(LoginTest.class); - - /** - * Logging in to midpoint administrator module with credentials administrator/5ecr3t - */ - @Test - public void loginTest() { - logTestMethodStart(LOGGER, "login"); - - performLogin(driver); - - Assert.assertEquals("welcome to midPoint", driver.findElement(By.cssSelector("html.no-js body div.mp-main-container div.row.mainContainer div.page-header h1 small")).getText()); - - logTestMethodFinish(LOGGER, "login"); - } - - /** - * Logging in to midpoint administrator module with correct login value and incorrect - * password value - */ - @Test - public void loginWithIncorrectPasswordTest() { - logTestMethodStart(LOGGER, "loginWithIncorrectPassword"); - - performLogin(driver, userLogin, "incorrectPassword"); - - Assert.assertEquals("Invalid username and/or password.", driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div/div/span")).getText()); - - logTestMethodFinish(LOGGER, "loginWithIncorrectPassword"); - } - - /** - * Logging in to midpoint administrator module with incorrect login value and correct - * password value - */ - @Test - public void loginWithIncorrectUsernameTest() { - logTestMethodStart(LOGGER, "loginWithIncorrectUsername"); - - performLogin(driver, "incorrectUsername", userPassword); - - Assert.assertEquals("Invalid username and/or password.", driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div/div/span")).getText()); - - logTestMethodFinish(LOGGER, "loginWithIncorrectUsername"); - } -} diff --git a/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/account/AddAccountTest.java b/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/account/AddAccountTest.java deleted file mode 100644 index 736eaf27011..00000000000 --- a/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/account/AddAccountTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.evolveum.midpoint.testing.selenium.tests.account; - -import com.evolveum.midpoint.testing.selenium.tests.BaseTest; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.testng.Assert; -import org.testng.annotations.Test; - -import java.awt.*; -import java.awt.event.KeyEvent; -import java.util.concurrent.TimeUnit; - -/** - * Created by honchar - */ -public class AddAccountTest extends BaseTest { - private static final Trace LOGGER = TraceManager.getTrace(AddAccountTest.class); - - @Test - public void addAccountTest() { - logTestMethodStart(LOGGER, "addAccountTest"); - //log in to system as administrator - performLogin(driver, userLogin, userPassword); - - //click Users menu item in the top vertical menu - driver.findElement(By.cssSelector("html.no-js body div.navbar.navbar-default.navbar-fixed-top div div.navbar-collapse.collapse ul.nav.navbar-nav li.dropdown a.dropdown-toggle")).click(); - - //click List Users menu item - driver.findElement(By.cssSelector("li > a > span")).click(); - - //Search for a TestUserName - driver.findElement(By.name("basicSearch:searchText")).clear(); - driver.findElement(By.name("basicSearch:searchText")).sendKeys("TestUserName"); - driver.findElement(By.xpath("/html/body/div[4]/div/div[4]/form/span/a")).click(); - - //click on the users link to open Edit user page - waitToBeClickable(By.partialLinkText("TestUserName")).click(); - implicitWait(5); - - //click on the menu icon in the right upper corner of the users list - fluentWait(By.xpath("/html/body/div[4]/div/form/div[3]/div[2]/div[1]/div/div[2]/ul/li/a/b")).click(); - - //click on the Add account menu item - driver.findElement(By.xpath("/html/body/div[4]/div/form/div[3]/div[2]/div[1]/div[1]/div[2]/ul/li/ul/li[1]/a")).click(); - - //select resource check box in the opened Select resource(s) window - fluentWait(By.xpath("/html/body/div[6]/form/div/div[2]/div/div/div/div[2]/div/div/div/div/div/div[2]/div/table/tbody/tr/td[1]/div/input")).click(); - - //Click Add resource(s) button - driver.findElement(By.xpath("/html/body/div[6]/form/div/div[2]/div/div/div/div[2]/div/div/div/div/div/p/a")).click(); - - //Fill in confirm password - fluentWait(By.xpath("/html/body/div[4]/div/form/div[3]/div[2]/div[1]/div[2]/div/div/div/div[3]/div[1]/div/div[1]/div/div[2]/div/div[1]/div[1]/input[2]")).clear(); - driver.findElement(By.xpath("/html/body/div[4]/div/form/div[3]/div[2]/div[1]/div[2]/div/div/div/div[3]/div[5]/div/div[2]/div/div[2]/div/div[1]/div[1]/input[2]")).sendKeys(userPassword); - implicitWait(5); - - - //Fill in mandatory ConnId Name field - fluentWait(By.xpath("/html/body/div[4]/div/form/div[3]/div[2]/div[1]/div[2]/div/div/div/div[3]/div[1]/div/div[1]/div/div[2]/div/div[1]/div[1]/input")).clear(); - driver.findElement(By.xpath("/html/body/div[4]/div/form/div[3]/div[2]/div[1]/div[2]/div/div/div/div[3]/div[1]/div/div[1]/div/div[2]/div/div[1]/div[1]/input")).sendKeys("Connid name"); - - //Fill in user name - fluentWait(By.xpath("/html/body/div[4]/div/form/div[3]/div[2]/div[1]/div[2]/div/div/div/div[3]/div[1]/div/div[5]/div/div[2]/div/div[1]/div[1]/input")).clear(); - driver.findElement(By.xpath("/html/body/div[4]/div/form/div[3]/div[2]/div[1]/div[2]/div/div/div/div[3]/div[1]/div/div[5]/div/div[2]/div/div[1]/div[1]/input")).sendKeys(userLogin); - - //Fill in password - fluentWait(By.xpath("/html/body/div[4]/div/form/div[3]/div[2]/div[1]/div[2]/div/div/div/div[3]/div[5]/div/div[2]/div/div[2]/div/div[1]/div[1]/input[1]")).clear(); - fluentWait(By.xpath("/html/body/div[4]/div/form/div[3]/div[2]/div[1]/div[2]/div/div/div/div[3]/div[5]/div/div[2]/div/div[2]/div/div[1]/div[1]/input[1]")).sendKeys(userPassword); - implicitWait(5); - - //Click Save button - implicitWait(5); - driver.findElement(By.xpath("/html/body/div[4]/div/form/div[6]/a[2]")).click(); - - //Check is the message appears - Assert.assertEquals("Success", fluentWait(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div[1]/div[1]/span")).getText()); - Assert.assertEquals("Save user (Gui)", driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div[1]/div[2]/ul/li/div/span")).getText()); - - logTestMethodFinish(LOGGER, "addAccountTest"); - - } -} diff --git a/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/resource/AddResourceTest.java b/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/resource/AddResourceTest.java deleted file mode 100644 index 84445aad7b5..00000000000 --- a/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/resource/AddResourceTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.evolveum.midpoint.testing.selenium.tests.resource; - -import com.evolveum.midpoint.testing.selenium.tests.BaseTest; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.remote.LocalFileDetector; -import org.openqa.selenium.remote.RemoteWebElement; -import org.testng.Assert; -import org.testng.annotations.Test; - -import java.util.concurrent.TimeUnit; - -/** - * Created by honchar - */ -public class AddResourceTest extends BaseTest { - private static final Trace LOGGER = TraceManager.getTrace(AddResourceTest.class); - - /** - * Import databasetable resource from the xml file - */ - @Test - public void importResourceTest() { - logTestMethodStart(LOGGER, "importResourceTest"); - - performLogin(driver); - - //Click Configuration menu item - driver.findElement(By.xpath("/html/body/div[3]/div/div[2]/ul[1]/li[9]/a")).click(); - - //Click Import object from the drop down menu - driver.findElement(By.xpath("//li[9]/ul/li[2]/a/span")).click(); - - //Select Overwrite existing object check box - driver.findElement(By.name("importOptions:overwriteExistingObject")).click(); - - //Select Get objects from File radio button - driver.findElement(By.name("importRadioGroup")).click(); - - //Click Browse button to select file for upload - fluentWait(By.xpath("/html/body/div[4]/div/form/div[5]/div/input")).click(); - - //upload localhost-dbtable-simple.xml file - uploadFile(samplesFolderPath + "\\resources\\databasetable\\localhost-dbtable-simple.xml"); - - //Click on Import object button - waitToBeClickable(By.xpath("/html/body/div[4]/div/form/div[6]/a")).click(); - - //Check if Success message appears - Assert.assertEquals("Success", driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div[1]/div[1]/span")).getText()); - Assert.assertEquals("Import file (Gui)", driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div[1]/div[2]/ul/li/div/span")).getText()); - - - logTestMethodFinish(LOGGER, "importResourceTest"); - - } -} diff --git a/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/user/CreateUserTest.java b/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/user/CreateUserTest.java deleted file mode 100644 index bf3e21d3e05..00000000000 --- a/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/user/CreateUserTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.evolveum.midpoint.testing.selenium.tests.user; - -import com.evolveum.midpoint.testing.selenium.tests.BaseTest; -import com.evolveum.midpoint.testing.selenium.tests.LoginTest; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import org.openqa.selenium.By; -import org.testng.Assert; -import org.testng.annotations.Test; - -/** - * Created by honchar - */ -public class CreateUserTest extends BaseTest { - private static final Trace LOGGER = TraceManager.getTrace(CreateUserTest.class); - - /** - * Creating new user in the midPoint administrator module - */ - @Test - public void addNewUserTest(){ - logTestMethodStart(LOGGER, "addNewUserTest"); - - //log in to system asadministrator - performLogin(driver, userLogin, userPassword); - - //click Users menu item in the top vertical menu - driver.findElement(By.cssSelector("html.no-js body div.navbar.navbar-default.navbar-fixed-top div div.navbar-collapse.collapse ul.nav.navbar-nav li.dropdown a.dropdown-toggle")).click(); - - //click New user menu item - driver.findElement(By.xpath("//li[2]/a/span")).click(); - - //Clear and fill in the Name mandatory field - driver.findElement(By.name("userForm:body:containers:0:container:properties:0:property:values:0:value:valueContainer:input:input")).clear(); - driver.findElement(By.name("userForm:body:containers:0:container:properties:0:property:values:0:value:valueContainer:input:input")).sendKeys("TestUserName"); - - //Click on Save button - driver.findElement(By.xpath("/html/body/div[4]/div/form/div[5]/a[2]")).click(); - - //Check is the message appears - Assert.assertEquals("Success", fluentWait(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div[1]/div[1]/span")).getText()); - Assert.assertEquals("Save user (Gui)", fluentWait(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div[1]/div[2]/ul/li/div/span")).getText()); - - logTestMethodFinish(LOGGER, "addNewUserTest"); - } - - /** - * Attemp to create user without mandatory field Name - */ - @Test - public void createUserWithoutNameTest() { - logTestMethodStart(LOGGER, "createUserWithoutNameTest"); - - //click Users menu item in the top vertical menu - driver.findElement(By.cssSelector("html.no-js body div.navbar.navbar-default.navbar-fixed-top div div.navbar-collapse.collapse ul.nav.navbar-nav li.dropdown a.dropdown-toggle")).click(); - - //click New user menu item - waitToBeClickable(By.xpath("//li[2]/a/span")).click(); - - //Clear Name mandatory field - driver.findElement(By.name("userForm:body:containers:0:container:properties:0:property:values:0:value:valueContainer:input:input")).clear(); - - //Click on Save button - driver.findElement(By.xpath("/html/body/div[4]/div/form/div[5]/a[2]")).click(); - - //check if error message appears - String errorMessage = "No name in new object null as produced by template null in iteration 0, we cannot process an object without a name: No name in new object null as produced by template null in iteration 0, we cannot process an object without a name"; - String messageXpath = "/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div[1]/div[1]/span"; - Assert.assertEquals(errorMessage, driver.findElement(By.xpath(messageXpath)).getText()); - - logTestMethodFinish(LOGGER, "createUserWithoutNameTest"); - } -} - diff --git a/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/user/DeleteUserTest.java b/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/user/DeleteUserTest.java deleted file mode 100644 index c304b71917f..00000000000 --- a/testing/selenium-tests/src/test/java/com/evolveum/midpoint/testing/selenium/tests/user/DeleteUserTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.evolveum.midpoint.testing.selenium.tests.user; - -import com.evolveum.midpoint.testing.selenium.tests.BaseTest; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import org.openqa.selenium.By; -import org.testng.Assert; -import org.testng.annotations.Test; - -/** - * Created by honchar - */ -public class DeleteUserTest extends BaseTest{ - - private static final Trace LOGGER = TraceManager.getTrace(DeleteUserTest.class); - - @Test - public void deleteUserTest() throws Exception { - logTestMethodStart(LOGGER, "deleteUserTest"); - //log in to system as administrator - performLogin(driver, userLogin, userPassword); - - //click Users menu item in the top vertical menu - driver.findElement(By.cssSelector("html.no-js body div.navbar.navbar-default.navbar-fixed-top div div.navbar-collapse.collapse ul.nav.navbar-nav li.dropdown a.dropdown-toggle")).click(); - - //click List Users menu item - driver.findElement(By.cssSelector("li > a > span")).click(); - - //Search for a TestUserName - driver.findElement(By.name("basicSearch:searchText")).clear(); - driver.findElement(By.name("basicSearch:searchText")).sendKeys("TestUserName"); - - //Select TestUserName checkbox - driver.findElement(By.name("table:table:body:rows:1:cells:1:cell:check")).click(); - - //Click drop-down menu in the upper right corner - driver.findElement(By.xpath("/html/body/div[4]/div/form/div[2]/table/thead/tr/th[9]/div/span[1]/ul/li/a")).click(); - //Click Delete menu item - driver.findElement(By.xpath("/html/body/div[4]/div/form/div[2]/table/thead/tr/th[9]/div/span[1]/ul/li/ul/li[6]/a")).click(); - //Click Yes in the confirmation window - waitToBeClickable(By.xpath("/html/body/div[6]/form/div/div[2]/div/div/div/div[2]/div/div/div/div/p[2]/a[1]")).click(); - - //Check is the message appears - Assert.assertEquals("Success", driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div[1]/div[1]/span")).getText()); - Assert.assertEquals("Delete users (Gui)", driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div[1]/div[2]/ul/li/div/span")).getText()); - - logTestMethodFinish(LOGGER, "deleteUserTest"); - } - -}