Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into feature/user-search
- Loading branch information
Showing
12 changed files
with
332 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 2 additions & 36 deletions
38
...ing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/BaseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,20 @@ | ||
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. | ||
* Created by Kate on 13.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(){ | ||
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(); | ||
} | ||
|
||
|
||
} |
77 changes: 76 additions & 1 deletion
77
...ng/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/LoginTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,99 @@ | ||
package com.evolveum.midpoint.testing.selenide.tests; | ||
|
||
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.*; | ||
|
||
/** | ||
* Created by Kate on 07.08.2015. | ||
*/ | ||
@Component | ||
public class LoginTest extends BaseTest{ | ||
|
||
@Autowired | ||
Util util; | ||
|
||
@Autowired | ||
BaseTest baseTest; | ||
|
||
/** | ||
* Log in to system as administrator/5ecr3t | ||
*/ | ||
@Test | ||
public void loginWithCorrectCredentialsTest(){ | ||
open(util.getSiteUrl()); | ||
//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")); | ||
|
||
close(); | ||
} | ||
|
||
/** | ||
* Log in to system with incorrect username | ||
*/ | ||
@Test | ||
public void loginWithIncorrectUsernameTest(){ | ||
open(util.getSiteUrl()); | ||
//perform login | ||
login(util.getSiteUrl(), "incorrectUserName", util.getAdminUserPassword()); | ||
|
||
//check if error message appears | ||
$(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div/div/span")).shouldHave(text("Invalid username and/or password.")); | ||
|
||
close(); | ||
} | ||
|
||
/** | ||
* Log in to system with incorrect password | ||
*/ | ||
@Test | ||
public void loginWithIncorrectPasswordTest(){ | ||
open(util.getSiteUrl()); | ||
//perform login | ||
login(util.getSiteUrl(), util.getAdminUserLogin(), "incorrectPassword"); | ||
|
||
//check if error message appears | ||
$(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div/div/span")).shouldHave(text("Invalid username and/or password.")); | ||
|
||
close(); | ||
} | ||
|
||
|
||
/** | ||
* open browser window with the specified siteUrl | ||
*/ | ||
@Test | ||
public void loginAndStay(){ | ||
open(util.getSiteUrl()); | ||
//perform login | ||
login(siteUrl, userLogin, userPassword); | ||
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 siteUrl, String username, String password) { | ||
//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(); | ||
} | ||
|
||
} |
69 changes: 69 additions & 0 deletions
69
testing/selenidetest/src/test/java/com/evolveum/midpoint/testing/selenide/tests/Util.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.evolveum.midpoint.testing.selenide.tests; | ||
|
||
import com.codeborne.selenide.SelenideElement; | ||
import org.openqa.selenium.By; | ||
import org.springframework.stereotype.Component; | ||
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; | ||
import static com.codeborne.selenide.Selenide.open; | ||
|
||
/** | ||
* Created by Kate on 13.08.2015. | ||
*/ | ||
@Component | ||
public class Util { | ||
private String siteUrl; | ||
private String adminUserLogin; | ||
private String adminUserPassword; | ||
|
||
|
||
|
||
/** | ||
*close browser window | ||
*/ | ||
@Test | ||
public void closeTest(){ | ||
close(); | ||
} | ||
/** | ||
* Looks for the element with specified searchText | ||
* and returns the first element from the search results | ||
* @param searchText | ||
* @return | ||
*/ | ||
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; | ||
} | ||
|
||
public void setSiteUrl(String siteUrl) { | ||
this.siteUrl = siteUrl; | ||
} | ||
|
||
public String getAdminUserLogin() { | ||
return adminUserLogin; | ||
} | ||
|
||
public void setAdminUserLogin(String adminUserLogin) { | ||
this.adminUserLogin = adminUserLogin; | ||
} | ||
|
||
public String getAdminUserPassword() { | ||
return adminUserPassword; | ||
} | ||
|
||
public void setAdminUserPassword(String adminUserPassword) { | ||
this.adminUserPassword = adminUserPassword; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 13 additions & 6 deletions
19
...va/com/evolveum/midpoint/testing/selenide/tests/resource/CheckResourceConnectionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.