Skip to content

Commit

Permalink
Selenide tests code refactoring, new automation tests (tests for user…
Browse files Browse the repository at this point in the history
… with assigned Superuser role)
  • Loading branch information
KaterynaHonchar committed Aug 17, 2015
1 parent 72292b2 commit c5c4cb7
Show file tree
Hide file tree
Showing 10 changed files with 506 additions and 163 deletions.
2 changes: 1 addition & 1 deletion testing/selenidetest/pom.xml
Expand Up @@ -43,7 +43,7 @@
<parallel>classes</parallel>
<perCoreThreadCount>false</perCoreThreadCount>
<threadCount>1</threadCount>
<runOrder>alphabetical</runOrder>
<runOrder>filesystem</runOrder>
</configuration>
</plugin>
</plugins>
Expand Down
Expand Up @@ -3,8 +3,6 @@
import org.openqa.selenium.By;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import org.testng.annotations.Test;
import static com.codeborne.selenide.Selenide.*;
import static com.codeborne.selenide.Condition.*;
Expand Down Expand Up @@ -68,32 +66,27 @@ public void loginWithIncorrectPasswordTest(){


/**
* open browser window with the specified siteUrl
* Log in to MidPoint as administrator
*/
@Test
public void loginAndStay(){
open(util.getSiteUrl());
public void login(){
//perform login
login(util.getSiteUrl(), util.getAdminUserLogin(), util.getAdminUserPassword());

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

/**
* Log in to MidPoint as administrator
*/
public void loginAsAdmin(){
login(util.getSiteUrl(), util.getAdminUserLogin(), util.getAdminUserPassword());
public void login(String username, String password){
//perform login
login(util.getSiteUrl(), username, password);
}

public void login(String siteUrl, String username, String password) {
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();
$(By.xpath("/html/body/div[4]/div/div[3]/div/div/div/form/input")).shouldBe(enabled).click();

}

}
Expand Up @@ -39,9 +39,8 @@ public void searchForElement(String searchText, String searchButtonXpath){
//search for element in search form
$(By.name("basicSearch:searchText")).shouldBe(visible).setValue(searchText);
$(By.xpath(searchButtonXpath)).shouldHave(text("Search")).click();
// $(By.xpath("/html/body/div[4]/div/form[1]/span/a")).shouldHave(text("Search")).click();
// /html/body/div[4]/div/div[4]/form/span/a
}

public String getSiteUrl() {
return siteUrl;
}
Expand Down
Expand Up @@ -9,6 +9,7 @@
import com.evolveum.midpoint.testing.selenide.tests.Util;
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.SimpleUserTests;
import com.evolveum.midpoint.testing.selenide.tests.user.UserUtil;
import org.openqa.selenium.By;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -24,6 +25,9 @@ public class CreateAccountTest extends BaseTest {
@Autowired
LoginTest loginTest;

@Autowired
SimpleUserTests simpleUserTests;

@Autowired
UserUtil userUtil;

Expand All @@ -45,7 +49,7 @@ public void createAccountForUserTest(){
userUtil.openListUsersPage();

//search for user in users list
util.searchForElement(userUtil.getSimpleTestUserName(), "/html/body/div[4]/div/div[4]/form/span/a");
util.searchForElement(simpleUserTests.SIMPLE_USER_NAME, "/html/body/div[4]/div/div[4]/form/span/a");
$(By.xpath("/html/body/div[4]/div/form/div[2]/table/tbody/tr/td[3]/div/a/span"))
.shouldBe(visible).click();

Expand Down Expand Up @@ -78,7 +82,7 @@ public void createAccountForUserTest(){
$(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
util.searchForElement(userUtil.getSimpleTestUserName(), "/html/body/div[4]/div/div[4]/form/span/a");
util.searchForElement(simpleUserTests.SIMPLE_USER_NAME, "/html/body/div[4]/div/div[4]/form/span/a");
$(By.xpath("/html/body/div[4]/div/form/div[2]/table/tbody/tr/td[3]/div/a/span"))
.shouldBe(visible).click();

Expand Down

This file was deleted.

0 comments on commit c5c4cb7

Please sign in to comment.