Skip to content

Commit

Permalink
more gui selenide tests update
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Jul 6, 2016
1 parent ea4a86b commit 319c265
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 123 deletions.
6 changes: 5 additions & 1 deletion samples/resources/csvfile/midpoint-flatfile.csv
@@ -1,3 +1,7 @@
"id","firstname","lastname","disabled","password"
"user01","Firstname","Lastname","false","secret"
"user02","Test","Lastname","false","secret"
"user02","Test","Lastname","false","secret"
"honchar","Kate","last name","false",
"csv1",,,"false",
"SuperUser",,,"false","password"
"ifarinic","Igor","Farinič","false",
30 changes: 15 additions & 15 deletions testing/selenidetest/basic-tests-suite.xml
Expand Up @@ -18,16 +18,16 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="basic-tests-suite" parallel="false">

<test name="Log in Tests" parallel="false" preserve-order="true" verbose="10">
<classes>
<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.LoginTest"/>
</classes>
</test>
<test name="Simple User Tests" parallel="false" preserve-order="true" verbose="10">
<classes>
<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.SimpleUserTests"/>
</classes>
</test>
<!--<test name="Log in Tests" parallel="false" preserve-order="true" verbose="10">-->
<!--<classes>-->
<!--<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.LoginTest"/>-->
<!--</classes>-->
<!--</test>-->
<!--<test name="Simple User Tests" parallel="false" preserve-order="true" verbose="10">-->
<!--<classes>-->
<!--<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.SimpleUserTests"/>-->
<!--</classes>-->
<!--</test>-->
<!--<test name="End User Tests" parallel="false" preserve-order="true" verbose="10">-->
<!--<classes>-->
<!--<class name="com.evolveum.midpoint.testing.selenide.tests.basictests.EndUserTests"/>-->
Expand All @@ -40,11 +40,11 @@
<!--</test>-->

<!-- TODO: bug in local OpenDJ config? -->
<!--<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>-->
<!--</test>-->
<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>
</test>
<!--<test name="Organization Structure Tests" parallel="false" preserve-order="true" verbose="10">-->
<!--<classes>-->
<!--<class name="com.evolveum.midpoint.testing.selenide.tests.organization.OrganizationStructureTests"/>-->
Expand Down
Expand Up @@ -235,7 +235,7 @@ public void openListUsersPage(){
* @param objectName the name of the object to be assigned
*/
public void assignObjectToUser(String linkText, String objectName){
$(byAttribute("class", "tab2")).shouldBe(visible).click();
openAssignmentsTab();
$(byAttribute("about", "dropdownMenu")).click();
//click Assign menu item with the specified linkText
$(By.linkText(linkText)).shouldBe(visible).click();
Expand All @@ -249,12 +249,17 @@ public void assignObjectToUser(String linkText, String objectName){
$(By.linkText("Add")).shouldBe(visible).click();
$(By.linkText("Add")).should(disappear);

//switch to main window
// switchTo().defaultContent();
//click Save button
$(By.linkText("Save")).click();
}

protected void openAssignmentsTab(){
$(byAttribute("class", "tab2")).shouldBe(visible).click();
}

protected void openProjectionsTab(){
$(byAttribute("class", "tab1")).shouldBe(visible).click();
}
/**
* opens Edit page for the specified user with userName
* @param userName
Expand Down Expand Up @@ -314,7 +319,7 @@ public void importObjectFromFile(String filePath){
$(byAttribute("about", "importFileButton")).shouldBe(visible).click();

//check if Success message appears after resource importing
$(byText("Success")).shouldBe(visible);
$(byText("Import file (Gui)")).shouldBe(visible);

}

Expand Down Expand Up @@ -373,8 +378,8 @@ protected void checkOperationStatusOk(String message) {
}

protected void checkLoginIsPerformed(){
$(byText("Personal info")).shouldBe(visible);
$(byText("System status")).shouldBe(visible);
$(By.partialLinkText("Home")).click();
$(byText("My work items")).shouldBe(visible);
}

protected SelenideElement findAttributeValueFiledByDisplayName(String displayName, String fieldTagName){
Expand Down
Expand Up @@ -9,22 +9,25 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;

import java.util.HashMap;
import java.util.Map;

import static com.codeborne.selenide.Condition.*;
import static com.codeborne.selenide.Selectors.byAttribute;
import static com.codeborne.selenide.Selectors.byText;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.$$;
import static com.codeborne.selenide.Selenide.close;
import static com.codeborne.selenide.Selenide.switchTo;

@Component
public class ResourceUserAccountTests extends AbstractSelenideTest {

public static final String USER_NAME = "UserWithOpendjAccount";
public static final String OPENDJ_RESOURCE_NAME = "Localhost OpenDJ (no extension schema)";
public static final String OPENDJ_RESOURCE_PATH = "../../samples/resources/opendj/opendj-localhost-resource-sync-no-extension-advanced.xml";
public static final String OPENDJ_RESOURCE_NAME = "Localhost OpenDJ";
public static final String OPENDJ_RESOURCE_PATH = "../../samples/resources/opendj/opendj-localhost-resource-sync-advanced.xml";
public static final String USER_ADMINISTRATOR_ROLE_NAME = "User Administrator";
public static final String AUTHORIZATION_ROLES_XML_PATH = "../../samples/roles/authorization-roles.xml";
public static final String END_USER_ROLE_NAME = "End user";
Expand All @@ -39,10 +42,7 @@ public class ResourceUserAccountTests extends AbstractSelenideTest {
public void test001importResourceTest(){
close();
login();

//check if welcome message appears after user logged in
$(byText("welcome to midPoint")).shouldBe(visible);

checkLoginIsPerformed();
//import resource xml file
importObjectFromFile(OPENDJ_RESOURCE_PATH);

Expand All @@ -62,24 +62,26 @@ public void test001importResourceTest(){
*/
@Test(priority = 1, dependsOnMethods = {"test001importResourceTest"})
public void test002checkResourceConnectionTest(){
//open Resources -> List Resources
// $(By.partialLinkText("Resources")).shouldBe(visible).click(); // clicked in previous test
close();
login();
checkLoginIsPerformed();
$(By.partialLinkText("Resources")).shouldBe(visible).click();
$(By.partialLinkText("List resources")).click();

//search for resource in resources list
searchForElement(OPENDJ_RESOURCE_NAME);
//click on resource link
$(By.partialLinkText(OPENDJ_RESOURCE_NAME)).click();
$(By.linkText(OPENDJ_RESOURCE_NAME)).click();

//click Test connection button
$(By.linkText("Test connection")).click();

//check if all statuses are succeeded
$(By.xpath("/html/body/div/div/section[2]/form/div[2]/div[2]/div/div[2]/table/tbody/tr[1]/td[2]/i")).shouldHave(hasAttribute("title", "Success"));
$(By.xpath("/html/body/div/div/section[2]/form/div[2]/div[2]/div/div[2]/table/tbody/tr[2]/td[2]/i")).shouldHave(hasAttribute("title", "Success"));
$(By.xpath("/html/body/div/div/section[2]/form/div[2]/div[2]/div/div[2]/table/tbody/tr[3]/td[2]/i")).shouldHave(hasAttribute("title", "Success"));
$(By.xpath("/html/body/div/div/section[2]/form/div[2]/div[2]/div/div[2]/table/tbody/tr[4]/td[2]/i")).shouldHave(hasAttribute("title", "Success"));
$(By.xpath("/html/body/div/div/section[2]/form/div[2]/div[2]/div/div[2]/table/tbody/tr[5]/td[2]/i")).shouldHave(hasAttribute("title", "Success"));
assertEquals(4, $$(byAttribute("class", "feedback-message box box-solid box-success")).size());
// $(byText("Configuration validation")).parent().find(byAttribute("class", "feedback-message box box-solid box-success")).find.shouldBe(visible);
// $(byText("Connector initialization")).parent().find(byAttribute("class", "feedback-message box box-solid box-success")).shouldBe(visible);
// $(byText("Connector connection test")).parent().find(byAttribute("class", "feedback-message box box-solid box-success")).shouldBe(visible);
// $(byText("Connector schema")).parent().find(byAttribute("class", "feedback-message box box-solid box-success")).shouldBe(visible);

}

Expand All @@ -91,23 +93,25 @@ public void test002checkResourceConnectionTest(){
public void test003createAccountTest() {
close();
login();
checkLoginIsPerformed();
//create user with filled user name only
createUser(USER_NAME, new HashMap<String, String>());

//open user's Edit page
openUsersEditPage(USER_NAME);

openProjectionsTab();
//click on the menu icon in the Projection section
$(By.xpath("/html/body/div[1]/div/section[2]/form/div[4]/div/div/div[7]/div[2]/div[1]/div/div[2]/ul/li/a"))
.shouldBe(visible).click();
$(byAttribute("about", "dropdownMenu")).shouldBe(visible).click();
//click on the Add projection menu item
$(By.linkText("Add projection")).shouldBe(visible).click();

//switch to the opened modal window
switchToInnerFrame();
// //switch to the opened modal window
// switchToInnerFrame();
//search for resource in resources list in the opened Select resource(s) window
$(byText(OPENDJ_RESOURCE_NAME)).shouldBe(visible).parent().parent().findElementByTagName("input").click();
// searchForElement(OPENDJ_RESOURCE_NAME);
// $(byText(OPENDJ_RESOURCE_NAME)).shouldBe(visible).parent().parent().findElementByTagName("input").click();
searchForElement(OPENDJ_RESOURCE_NAME);
$(byAttribute("about", "table")).find(By.tagName("tbody")).find(By.tagName("input")).shouldBe(visible).setSelected(true);

// //check if Localhost OpenDJ resource was found
// $(byText(OPENDJ_RESOURCE_NAME)).shouldBe(visible);
//
Expand All @@ -119,31 +123,34 @@ public void test003createAccountTest() {
// .shouldBe(selected);

//click Add resource(s) button
$(By.linkText("Add resource(s)")).shouldBe(enabled).click();
$(By.linkText("Add")).shouldBe(enabled).click();

//switch to main window
switchTo().defaultContent();
// //switch to main window
// switchTo().defaultContent();

//Fill in account fields: Common name, Surname, first and second password fields
$(By.name("tabPanel:panel:shadows:shadowList:0:shadow:body:containers:0:container:properties:3:property:values:0:value:valueContainer:input:input"))
.shouldBe(visible).setValue(ACCOUNT_COMMON_NAME_VALUE);
$(By.name("tabPanel:panel:shadows:shadowList:0:shadow:body:containers:0:container:properties:42:property:values:0:value:valueContainer:input:input"))
.shouldBe(visible).setValue(ACCOUNT_SURNAME_VALUE);
$(By.name("tabPanel:panel:shadows:shadowList:0:shadow:body:containers:6:container:properties:0:property:values:0:value:valueContainer:input:inputContainer:password1"))
.shouldBe(visible).setValue(ACCOUNT_PASSWORD_VALUE);
$(By.name("tabPanel:panel:shadows:shadowList:0:shadow:body:containers:6:container:properties:0:property:values:0:value:valueContainer:input:inputContainer:password2"))
.shouldBe(visible).setValue(ACCOUNT_PASSWORD_VALUE);
Map<String, String> fieldsMap = new HashMap<String, String>();
fieldsMap.put("Common name", ACCOUNT_COMMON_NAME_VALUE);
fieldsMap.put("Surname", ACCOUNT_SURNAME_VALUE);
fieldsMap.put(PASSWORD1_FIELD_NAME, ACCOUNT_PASSWORD_VALUE);
fieldsMap.put(PASSWORD2_FIELD_NAME, ACCOUNT_PASSWORD_VALUE);
setFieldValues(fieldsMap);
// $(By.name("tabPanel:panel:shadows:shadowList:0:shadow:body:containers:0:container:properties:3:property:values:0:value:valueContainer:input:input"))
// .shouldBe(visible).setValue(ACCOUNT_COMMON_NAME_VALUE);
// $(By.name("tabPanel:panel:shadows:shadowList:0:shadow:body:containers:0:container:properties:42:property:values:0:value:valueContainer:input:input"))
// .shouldBe(visible).setValue(ACCOUNT_SURNAME_VALUE);
// $(By.name("tabPanel:panel:shadows:shadowList:0:shadow:body:containers:6:container:properties:0:property:values:0:value:valueContainer:input:inputContainer:password1"))
// .shouldBe(visible).setValue(ACCOUNT_PASSWORD_VALUE);
// $(By.name("tabPanel:panel:shadows:shadowList:0:shadow:body:containers:6:container:properties:0:property:values:0:value:valueContainer:input:inputContainer:password2"))
// .shouldBe(visible).setValue(ACCOUNT_PASSWORD_VALUE);

//click Save button
$(By.linkText("Save")).shouldBe(visible).click();

//check if Success message appears after user saving
$(byText("Success")).shouldBe(visible);
checkOperationStatusOk("Save (GUI)");

//search for user in users list
searchForElement(USER_NAME);
$(By.linkText(USER_NAME)).shouldBe(visible).click();

openUsersEditPage(USER_NAME);
openProjectionsTab();
//check if the created account is displayed in the Accounts section
$(By.linkText(OPENDJ_RESOURCE_NAME)).shouldBe(visible);
}
Expand All @@ -155,42 +162,52 @@ public void test003createAccountTest() {
*/
@Test (priority = 4, dependsOnMethods = {"test003createAccountTest"})
public void test004updateAccountAttributesTest(){
close();
login();
checkLoginIsPerformed();
//open user's Edit page
openUsersEditPage(USER_NAME);
openProjectionsTab();

//click on the account link to expand its fields
$(By.linkText(OPENDJ_RESOURCE_NAME)).shouldBe(visible).click();

//update Common Name field
$(By.name("tabPanel:panel:shadows:shadowList:0:shadow:body:containers:0:container:properties:3:property:values:0:value:valueContainer:input:input"))
.shouldBe(visible).setValue(ACCOUNT_COMMON_NAME_VALUE + UPDATED_VALUE);
Map<String, String> fieldsMap = new HashMap<String, String>();
fieldsMap.put("Common name", ACCOUNT_COMMON_NAME_VALUE + UPDATED_VALUE);
fieldsMap.put("Surname", ACCOUNT_SURNAME_VALUE + UPDATED_VALUE);
setFieldValues(fieldsMap);

//update Surname field
$(By.name("tabPanel:panel:shadows:shadowList:0:shadow:body:containers:0:container:properties:42:property:values:0:value:valueContainer:input:input"))
.shouldBe(visible).setValue(ACCOUNT_SURNAME_VALUE + UPDATED_VALUE);

// //update Common Name field
// $(By.name("tabPanel:panel:shadows:shadowList:0:shadow:body:containers:0:container:properties:3:property:values:0:value:valueContainer:input:input"))
// .shouldBe(visible).setValue(ACCOUNT_COMMON_NAME_VALUE + UPDATED_VALUE);
//
// //update Surname field
// $(By.name("tabPanel:panel:shadows:shadowList:0:shadow:body:containers:0:container:properties:42:property:values:0:value:valueContainer:input:input"))
// .shouldBe(visible).setValue(ACCOUNT_SURNAME_VALUE + UPDATED_VALUE);
//
//click Save button
$(By.linkText("Save")).shouldBe(visible).click();

//check if Success message appears after user saving
$(byText("Success")).shouldBe(visible);

checkOperationStatusOk("Save (GUI)");
//
// //check if Success message appears after user saving
// $(byText("Success")).shouldBe(visible);
//
//search for user in users list
searchForElement(USER_NAME);

//check if users attributes were updated
$(By.xpath("/html/body/div[1]/div/section[2]/form/div[2]/div/div[2]/table/tbody/tr/td[5]/div")).shouldHave(text(ACCOUNT_SURNAME_VALUE + UPDATED_VALUE));
$(By.xpath("/html/body/div[1]/div/section[2]/form/div[2]/div/div[2]/table/tbody/tr/td[6]/div")).shouldHave(text(ACCOUNT_COMMON_NAME_VALUE + UPDATED_VALUE));
$(byText(ACCOUNT_SURNAME_VALUE + UPDATED_VALUE)).shouldBe(visible);
$(byText(ACCOUNT_COMMON_NAME_VALUE + UPDATED_VALUE)).shouldBe(visible);

//open user's Edit page
$(By.linkText(USER_NAME)).shouldBe(visible).click();
openProjectionsTab();
//click on the account link to expand its fields
$(By.linkText(OPENDJ_RESOURCE_NAME)).shouldBe(visible).click();
//check if account's attributes were updated
$(By.name("tabPanel:panel:shadows:shadowList:0:shadow:body:containers:0:container:properties:3:property:values:0:value:valueContainer:input:input"))
.shouldHave(value(ACCOUNT_COMMON_NAME_VALUE + UPDATED_VALUE));
$(By.name("tabPanel:panel:shadows:shadowList:0:shadow:body:containers:0:container:properties:42:property:values:0:value:valueContainer:input:input"))
.shouldHave(value(ACCOUNT_SURNAME_VALUE + UPDATED_VALUE));
$(byText(ACCOUNT_SURNAME_VALUE + UPDATED_VALUE)).shouldBe(visible);
$(byText(ACCOUNT_COMMON_NAME_VALUE + UPDATED_VALUE)).shouldBe(visible);
}


Expand Down

0 comments on commit 319c265

Please sign in to comment.