Skip to content

Commit

Permalink
schrodinger: cleaning up tests not to use selenide code
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Nov 4, 2020
1 parent ac44e49 commit 15a5275
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 54 deletions.
Expand Up @@ -78,8 +78,8 @@ public class AbstractLabTest extends AbstractSchrodingerTest {
protected static final String HR_RESOURCE_NAME = "ExAmPLE, Inc. HR Source";
protected static final String NOTIFICATION_FILE_NAME = "notification.txt";

protected static final String PASSWORD_ATTRIBUTE_RESOURCE_KEY = "User password attribute name";
protected static final String UNIQUE_ATTRIBUTE_RESOURCE_KEY = "Unique attribute name";
protected static final String PASSWORD_ATTRIBUTE_NAME = "User password attribute name";
protected static final String UNIQUE_ATTRIBUTE_NAME = "Unique attribute name";

protected static final String CSV_1_UNIQUE_ATTRIBUTE_NAME = "login";
protected static final String CSV_1_PASSWORD_ATTRIBUTE_NAME = "password";
Expand Down
Expand Up @@ -14,6 +14,7 @@
import com.evolveum.midpoint.schema.SchemaConstantsGenerated;
import com.evolveum.midpoint.schrodinger.MidPoint;
import com.evolveum.midpoint.schrodinger.component.common.PrismForm;
import com.evolveum.midpoint.schrodinger.component.resource.ResourceConfigurationTab;
import com.evolveum.midpoint.schrodinger.page.resource.AccountPage;
import com.evolveum.midpoint.schrodinger.page.resource.ListResourcesPage;
import com.evolveum.midpoint.schrodinger.page.resource.ResourceWizardPage;
Expand Down Expand Up @@ -59,30 +60,18 @@ public void mod03test01ViewingResources() throws Exception {

ListResourcesPage resourcesList = basicPage.listResources();

resourcesList
PrismForm<ResourceConfigurationTab> configTab = resourcesList
.table()
.clickByName(CSV_1_RESOURCE_NAME)
.clickEditResourceConfiguration();

SelenideElement uniqueAttributeField = $(Schrodinger.byDataResourceKey(UNIQUE_ATTRIBUTE_RESOURCE_KEY))
.waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S);

.clickByName(CSV_1_RESOURCE_NAME)
.clickEditResourceConfiguration()
.form();
// Unique attribute name should be login
Assert.assertTrue(uniqueAttributeField
.$(By.tagName("input"))
.waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S)
.getValue()
.equals(CSV_1_UNIQUE_ATTRIBUTE_NAME));

SelenideElement passwordAttributeField = $(Schrodinger.byDataResourceKey(PASSWORD_ATTRIBUTE_RESOURCE_KEY))
.waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S);
Assert.assertTrue(configTab
.compareInputAttributeValue(UNIQUE_ATTRIBUTE_NAME, CSV_1_UNIQUE_ATTRIBUTE_NAME));

// Password attribute name should be password
Assert.assertTrue(passwordAttributeField
.$(By.tagName("input"))
.waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S)
.getValue()
.equals(CSV_1_PASSWORD_ATTRIBUTE_NAME));
Assert.assertTrue(configTab
.compareInputAttributeValue(PASSWORD_ATTRIBUTE_NAME, CSV_1_PASSWORD_ATTRIBUTE_NAME));

ResourceWizardPage resourceWizard = basicPage.listResources()
.table()
Expand Down
Expand Up @@ -25,12 +25,15 @@ public class BulkActionsTest extends AbstractSchrodingerTest {
@Test
public void wrongBulkActionXmlExecution(){
BulkActionsPage bulkActionsPage = basicPage.bulkActions();
bulkActionsPage
Assert.assertTrue(bulkActionsPage
.insertOneLineTextIntoEditor("<objects></objects>")
.startButtonClick();
.startButtonClick()
.feedback()
.isError());

$(By.linkText(PARSING_ERROR_MESSAGE))
.shouldBe(Condition.visible);
Assert.assertTrue(bulkActionsPage
.feedback()
.doesMessageExist(PARSING_ERROR_MESSAGE));

Assert.assertTrue(bulkActionsPage.isAceEditorVisible());
}
Expand Down
Expand Up @@ -62,14 +62,15 @@ public void test020selfRegistration() throws IOException, InterruptedException {
@Test
public void test030resetPassowordMailNonce() throws IOException, InterruptedException {
basicPage.loggedUser().logoutIfUserIsLogin();

Selenide.sleep(MidPoint.TIMEOUT_DEFAULT_2_S);
FormLoginPage login = midPoint.formLogin();
open("/login");
Selenide.sleep(MidPoint.TIMEOUT_DEFAULT_2_S);
open("/");
login.forgotPassword();
$(Schrodinger.byDataId("email")).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S).setValue(MAIL_OF_ENABLED_USER);
$(Schrodinger.byDataId("submitButton")).click();
login.forgotPassword()
.setEmailValue(MAIL_OF_ENABLED_USER)
.clickSubmitButton();
TimeUnit.SECONDS.sleep(6);
String notification = readLastNotification();
String bodyTag = "body='";
Expand All @@ -89,10 +90,10 @@ public void test031resetPassowordSecurityQuestion() {
login.loginWithReloadLoginPage("administrator", "5ecr3t");
addObjectFromFile(SEC_QUES_RESET_PASS_SECURITY_POLICY);
basicPage.loggedUser().logoutIfUserIsLogin();
login.forgotPassword();
$(Schrodinger.byDataId("username")).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S).setValue(NAME_OF_ENABLED_USER);
$(Schrodinger.byDataId("email")).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S).setValue(MAIL_OF_ENABLED_USER);
$(Schrodinger.byDataId("submitButton")).click();
login.forgotPassword()
.setUsernameValue(NAME_OF_ENABLED_USER)
.setEmailValue(MAIL_OF_ENABLED_USER)
.clickSubmitButton();
$(Schrodinger.byDataId("answerTF")).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S).setValue("10");
$(Schrodinger.byDataId("send")).click();
Selenide.sleep(MidPoint.TIMEOUT_DEFAULT_2_S);
Expand Down
Expand Up @@ -39,7 +39,7 @@ public class ObjectListArchetypeTests extends AbstractSchrodingerTest {
private static final File EMPLOYEE_ARCHETYPE_FILE = new File("src/test/resources/configuration/objects/archetypes/archetype-employee.xml");
private static final String ARCHETYPE_OBJECT_NAME = "Employee";
private static final String ARCHETYPE_PLURAL_LABEL = "Employees";
private static final String ARCHETYPE_ICON_CSS_STYLE = "fa fa-male";
private static final String ARCHETYPE_ICON_CSS_STYLE = ".fa.fa-male";
private static final String EMPLOYEE_USER_NAME_VALUE = "TestEmployee";

public static final String OBJECT_LIST_ARCHETYPE_TESTS_GROUP = "ObjectListArchetypeTests";
Expand Down Expand Up @@ -118,24 +118,12 @@ public void createNewEmployeeUser(){
public void checkNewObjectButtonWithDropdown(){
Selenide.sleep(5000);
ListUsersPage userListPage = basicPage.listUsers();
Assert.assertTrue(userListPage
.table()
.getToolbarButton("fa fa-plus")
.exists());

SelenideElement newObjectButton = userListPage
Assert.assertEquals(userListPage
.table()
.getToolbarButton("fa fa-plus");

newObjectButton.waitUntil(Condition.appears, MidPoint.TIMEOUT_DEFAULT_2_S).click();

newObjectButton
.$(Schrodinger.byElementAttributeValue("i", "class", ARCHETYPE_ICON_CSS_STYLE))
.exists();

newObjectButton
.$(Schrodinger.byElementAttributeValue("i", "class", "fa fa-user")) //standard user icon
.exists();
.countDropdownButtonChildrenButtons("fa fa-plus"), 2);
userListPage
.table()
.newObjectCollectionButtonClickPerformed("fa fa-plus", ARCHETYPE_ICON_CSS_STYLE);
}

}
Expand Down
Expand Up @@ -56,9 +56,10 @@ public void createOrgWithinMenuItem(){
.addAttributeValue("name", ORG_NAME)
.and()
.and()
.clickSave();
Selenide.sleep(2000);
$(Schrodinger.byDataId("tabs-container")).find(By.linkText(ORG_NAME)).shouldBe(Condition.visible);
.clickSave()
.feedback()
.isSuccess();
Assert.assertTrue(basicPage.orgStructure().doesRootOrgExists(ORG_NAME));
}

@Test (dependsOnMethods = {"createOrgWithinMenuItem"}, priority = 2)
Expand Down
Expand Up @@ -93,6 +93,31 @@ public PD newObjectButtonClickPerformed(String iconCssClass){
return getObjectDetailsPage();
}

public PD newObjectCollectionButtonClickPerformed(String mainButtonIconCssClass, String objCollectionButtonIconCssClass){
SelenideElement mainButtonElement = getToolbarButton(mainButtonIconCssClass)
.waitUntil(Condition.appears, MidPoint.TIMEOUT_DEFAULT_2_S);
mainButtonElement.click();
mainButtonElement.parent().$(By.cssSelector(objCollectionButtonIconCssClass))
.waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S)
.click();
Selenide.sleep(2000);
return getObjectDetailsPage();
}

public int countDropdownButtonChildrenButtons(String mainButtonIconCssClass) {
SelenideElement mainButtonElement = getToolbarButton(mainButtonIconCssClass)
.waitUntil(Condition.appears, MidPoint.TIMEOUT_DEFAULT_2_S);
mainButtonElement.click();
if (mainButtonElement.exists()) {
ElementsCollection childrenButtonCollection = mainButtonElement.parent()
.$(By.cssSelector(".dropdown-menu.auto-width"))
.waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S)
.findAll(By.tagName("i"));
return childrenButtonCollection != null ? childrenButtonCollection.size() : 0;
}
return 0;
}

public abstract PD getObjectDetailsPage();

protected String getNameColumnLabel() {
Expand Down
Expand Up @@ -101,4 +101,8 @@ public Boolean isFeedbackBoxPresent() {
return getParentElement().isDisplayed();
}

public Boolean doesMessageExist(String messageText) {
return $(By.linkText(messageText)).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S).exists();
}

}
Expand Up @@ -36,4 +36,18 @@ public LoginPage changeLanguage(String countryCode) {

return this;
}

public LoginPage setUsernameValue(String emailValue) {
$(Schrodinger.byDataId("username")).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S).setValue(emailValue);
return this;
}

public LoginPage setEmailValue(String emailValue) {
$(Schrodinger.byDataId("email")).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S).setValue(emailValue);
return this;
}

public void clickSubmitButton() {
$(Schrodinger.byDataId("submitButton")).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S).click();
}
}
Expand Up @@ -16,6 +16,8 @@
import com.evolveum.midpoint.schrodinger.page.BasicPage;
import com.evolveum.midpoint.schrodinger.util.Schrodinger;

import org.openqa.selenium.By;

import static com.codeborne.selenide.Selenide.$;

/**
Expand All @@ -29,6 +31,11 @@ public OrgRootTab selectTabWithRootOrg(String rootOrgName) {
return new OrgRootTab(this, element);
}

public boolean doesRootOrgExists(String rootOrgName) {
SelenideElement element = getTabPanel().getParentElement().$(By.linkText(rootOrgName));
return element != null;
}

private TabPanel getTabPanel() {
SelenideElement tabPanelElement = $(Schrodinger.byDataId("div", "tabs"))
.waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S);
Expand Down

0 comments on commit 15a5275

Please sign in to comment.