Skip to content

Commit

Permalink
New GUI automation tests are added to selenidetest module
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Aug 18, 2015
1 parent c0fb7c7 commit 7fbde90
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 24 deletions.
Expand Up @@ -78,6 +78,7 @@ public void login(String username, String password){
login(util.SITE_URL, username, password);
}


public void login(String siteUrl, String username, String password) {
open(siteUrl);
//enter login value
Expand Down
@@ -1,7 +1,6 @@
package com.evolveum.midpoint.testing.selenide.tests;

import com.codeborne.selenide.SelenideElement;
import com.evolveum.midpoint.testing.selenide.tests.resource.ResourceUtil;
import org.openqa.selenium.By;
import org.springframework.stereotype.Component;
import org.testng.annotations.Test;
Expand Down
Expand Up @@ -155,7 +155,7 @@ public void createAccountTest() {
* also updated
*/
@Test (priority = 4, dependsOnMethods = {"createAccountTest"})
public void updateAccountAttributes(){
public void updateAccountAttributesTest(){
close();
loginTest.login();
//open user's Edit page
Expand Down
Expand Up @@ -3,11 +3,13 @@
import com.evolveum.midpoint.testing.selenide.tests.BaseTest;
import com.evolveum.midpoint.testing.selenide.tests.LoginTest;
import com.evolveum.midpoint.testing.selenide.tests.Util;
import com.evolveum.midpoint.testing.selenide.tests.user.UserUtil;
import org.openqa.selenium.By;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.Test;

import static com.codeborne.selenide.Condition.text;
import static com.codeborne.selenide.Condition.visible;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.close;

Expand All @@ -18,17 +20,23 @@ public class OrganizationStructureTests extends BaseTest{
@Autowired
LoginTest loginTest;

@Autowired
UserUtil userUtil;

@Autowired
Util util;

public static final String ORG_FILE_PATH = "../../samples/org/org-monkey-island-simple.xml";
public static final String ASSIGN_ORG_UNIT_LINKTEXT = "Assign org. unit";
public static final String USER_NAME = "OrgTestUser";
public static final String ORG_UNIT_NAME = "F0002";

/**
* Import organization structure from org-monkey-island-simple.xml
* sample file. Check if organization tree was created in MP
*/
@Test
public void importOrganizationStructureFromFile(){
@Test(priority = 0)
public void importOrganizationStructureFromFileTest(){
close();
loginTest.login();

Expand All @@ -51,5 +59,35 @@ public void importOrganizationStructureFromFile(){
$(By.xpath("/html/body/div[4]/div/div[3]/ul/li[2]/a")).shouldHave(text("Projects"));
}

@Test(priority = 1, dependsOnMethods = {"importOrganizationStructureFromFileTest"})
public void assignOrgUnit(){
//create test user
userUtil.createUser(USER_NAME);
//open user's Edit page
userUtil.openUsersEditPage(USER_NAME);
//assign F0002 org unit (Ministry of Defense) to the user
userUtil.assignObjectToUser(ASSIGN_ORG_UNIT_LINKTEXT, ORG_UNIT_NAME,
"/html/body/div[6]/form/div/div[2]/div/div/div/div[2]/div/div/div/div/div/div/div/div/div/div/div[1]/form/span/a",
"/html/body/div[6]/form/div/div[2]/div/div/div/div[2]/div/div/div/div/div/div/div/div/div/div/div[3]/form/div[2]/div[2]/table/tbody/tr/td[1]/div/input");
//open user's Edit page
userUtil.openUsersEditPage(USER_NAME);
//check if assigned org. unit is displayed in the Assignments section
$(By.xpath("/html/body/div[4]/div/form/div[3]/div[2]/div[2]/div[2]/div/div[1]/div[1]/a/span")).shouldBe(visible)
.shouldHave(text(" F0002, Ministry of Defense"));
//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 Organization tree menu item
$(By.linkText("Organization tree")).click();
//click on Ministry of Defense
$(By.xpath("/html/body/div[4]/div/div[3]/div/div/div[4]/div[2]/div[2]/div/table/tbody/tr[2]/td/div/div/div/div/span/a/span"))
.shouldBe(visible).click();
//search for the user in the opened organization
util.searchForElement(USER_NAME, "/html/body/div[4]/div/div[3]/div/div/div[4]/div[1]/form/span/a");
//check if user was found in the organization
$(By.xpath("/html/body/div[4]/div/div[3]/div/div/div[4]/div[3]/form/div[4]/div[2]/table/tbody/tr/td[3]/div/a/span"))
.shouldHave(text(USER_NAME));

}


}
Expand Up @@ -187,7 +187,7 @@ public void cancelUserUpdateTest() {
* Attempt to create user with all empty fields
*/
@Test(alwaysRun = true, priority = 4)
public void createUserWithEmptyFields() {
public void createUserWithEmptyFieldsTest() {
close();
loginTest.login();
//create user with all empty fields
Expand All @@ -202,7 +202,7 @@ public void createUserWithEmptyFields() {
* Attempt to create user with existing name
*/
@Test(alwaysRun = true, priority = 5)
public void createUserWithExistingName() {
public void createUserWithExistingNameTest() {
close();
loginTest.login();
//check if welcome message appears after user logged in
Expand All @@ -224,7 +224,7 @@ public void createUserWithExistingName() {
}

@Test(alwaysRun = true, priority = 6)
public void deleteUser() {
public void deleteUserTest() {
close();
loginTest.login();
//check if welcome message appears after user logged in
Expand Down
Expand Up @@ -31,6 +31,7 @@ public class SuperUserTests extends BaseTest {
public static final String SUPER_ROLE_NAME = "Superuser";
public static final String USER_PASSWORD = "password";
public static final String SUPER_USER_NAME = "SuperUser";
public static final String ASSIGN_ROLE_LINKTEXT = "Assign role";

/**
* Create user with assigned Superuser role.
Expand Down Expand Up @@ -62,7 +63,9 @@ public void createSuperUserTest() {
.shouldBe(visible).setValue(USER_PASSWORD);

//assign Superuser role to user
userUtil.assignRoleToUser(SUPER_ROLE_NAME);
userUtil.assignObjectToUser(ASSIGN_ROLE_LINKTEXT, SUPER_ROLE_NAME,
"/html/body/div[6]/form/div/div[2]/div/div/div/div[2]/div/div/div/div/div/div[1]/form[2]/span/a",
"/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");

//search for the user in users list
util.searchForElement(SUPER_USER_NAME, "/html/body/div[4]/div/div[4]/form/span/a");
Expand All @@ -88,7 +91,7 @@ public void loginAsSuperuserTest() {
}

@Test(dependsOnMethods = {"createSuperUserTest"}, priority = 2)
public void disableSuperuserAndLogin() {
public void disableSuperuserAndLoginTest() {
close();
loginTest.login();
//check if welcome message appears after user logged in
Expand Down Expand Up @@ -126,7 +129,7 @@ public void disableSuperuserAndLogin() {
}

@Test(dependsOnMethods = {"createSuperUserTest"}, priority = 3)
public void enableSuperuserAndLogin() {
public void enableSuperuserAndLoginTest() {
close();
loginTest.login();
//check if welcome message appears after user logged in
Expand Down
Expand Up @@ -55,21 +55,21 @@ public void openListUsersPage(){

/**
* Prerequirement: user's Edit page is to be opened
* @param roleName
* Assign the specified roleName role to user
* @param linkText the text of the menu item from the Assignments section menu
* @param objectName the name of the object to be assigned
* @param searchButtonXpath xpath of the Search button from Search panel
* @param checkboxXpath xpath of the checkbox which is to be selected
*/
public void assignRoleToUser(String roleName){
public void assignObjectToUser(String linkText, String objectName, String searchButtonXpath, String checkboxXpath){
//click on the menu icon next to Assignments section
$(By.xpath("/html/body/div[4]/div/form/div[3]/div[2]/div[2]/div[1]/div[2]/ul/li/a")).shouldBe(visible).click();
//click Assign role menu item
$(By.linkText("Assign role")).shouldBe(visible).click();
//search for role in the opened Select object(s) window
util.searchForElement(roleName, "/html/body/div[6]/form/div/div[2]/div/div/div/div[2]/div/div/div/div/div/div[1]/form[2]/span/a");
//check if role is found during the search
$(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"))
.shouldBe(visible).shouldHave(text(roleName));
//select checkbox for the Superuser role
$(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"))
.shouldBe(visible).click();
//click Assign menu item with the specified linkText
$(By.linkText(linkText)).shouldBe(visible).click();
//search for object by objectName in the opened Select object(s) window
util.searchForElement(objectName, searchButtonXpath);
//select checkbox for the found object
$(By.xpath(checkboxXpath)).shouldBe(visible).click();
//click Assign button
$(By.xpath("/html/body/div[6]/form/div/div[2]/div/div/div/div[2]/div/div/div/div/div/p/a"))
.shouldBe(visible).click();
Expand All @@ -79,7 +79,6 @@ public void assignRoleToUser(String roleName){

//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"));

}

/**
Expand Down
2 changes: 1 addition & 1 deletion testing/selenidetest/testng.xml
Expand Up @@ -34,7 +34,7 @@
</classes>
</test>

<test name="Account Tests" parallel="false" preserve-order="true" verbose="10">
<test name="Resource-User-Account Tests" parallel="false" preserve-order="true" verbose="10">
<classes>
<class name="com.evolveum.midpoint.testing.selenide.tests.account.ResourceUserAccountTests"/>
</classes>
Expand Down

0 comments on commit 7fbde90

Please sign in to comment.