Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4908: Tests refactoring: Form field element #5391

Open
wants to merge 14 commits into
base: angular_rework_development
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.github.com.pages.ProgressSpinnerPage;
import io.github.com.pages.RadioButtonPage;
import io.github.com.pages.SlideTogglePage;
import io.github.com.pages.FormFieldsPage;

@JSite("https://jdi-testing.github.io/jdi-light/angular-page/#/")
public class StaticSite {
Expand Down Expand Up @@ -53,4 +54,7 @@ public class StaticSite {

@Url("slide_toggle")
public static SlideTogglePage slideTogglePage;

@Url("form_field")
public static FormFieldsPage formFieldPage;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.github.com.pages;

import com.epam.jdi.light.angular.elements.common.Checkbox;
import com.epam.jdi.light.angular.elements.complex.FormField;
import com.epam.jdi.light.angular.elements.complex.radiobuttons.RadioButton;
import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI;

public class FormFieldsPage extends NewAngularPage {

public static FormField formFieldSubscriptSizingFixed;
public static FormField formFieldSubscriptSizingDynamic;
public static FormField formFieldAppearanceInputLegacy;
public static FormField formFieldAppearanceInputStandard;
public static FormField simpleFormFieldInput;
public static FormField simpleFormFieldSelect;
public static FormField simpleFormFieldTextarea;
public static FormField formFieldWithLabelInputSimplePlaceholder;
public static FormField formFieldWithLabelInputSimplePlaceholderAndLabel;
public static FormField formFieldWithLabelSelect;
public static FormField formFieldExampleContainerInputLimited;
public static FormField formFieldExampleContainerDropdown;
public static FormField formFieldEmailInput;
public static FormField prefixSuffixFormFieldPassword;
public static FormField modifiedLayoutFormFieldColor;
public static FormField formFieldDisabled;
@UI("mat-checkbox[id*='mat-mdc-checkbox']")
public static Checkbox hideRequiredMarker;
@UI("mat-radio-button[value='always']")
public static RadioButton alwaysFloatLabel;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,132 +2,158 @@

import io.github.epam.TestsInit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

import static io.github.com.StaticSite.angularPage;
import static io.github.com.pages.sections.FormFieldsSection.*;
import static io.github.epam.site.steps.States.shouldBeLoggedIn;
import java.util.List;

import static com.jdiai.tools.Timer.waitCondition;
import static io.github.com.StaticSite.formFieldPage;
import static io.github.com.pages.FormFieldsPage.alwaysFloatLabel;
import static io.github.com.pages.FormFieldsPage.formFieldAppearanceInputLegacy;
import static io.github.com.pages.FormFieldsPage.formFieldAppearanceInputStandard;
import static io.github.com.pages.FormFieldsPage.formFieldDisabled;
import static io.github.com.pages.FormFieldsPage.formFieldEmailInput;
import static io.github.com.pages.FormFieldsPage.formFieldExampleContainerDropdown;
import static io.github.com.pages.FormFieldsPage.formFieldExampleContainerInputLimited;
import static io.github.com.pages.FormFieldsPage.formFieldSubscriptSizingDynamic;
import static io.github.com.pages.FormFieldsPage.formFieldSubscriptSizingFixed;
import static io.github.com.pages.FormFieldsPage.formFieldWithLabelInputSimplePlaceholder;
import static io.github.com.pages.FormFieldsPage.formFieldWithLabelInputSimplePlaceholderAndLabel;
import static io.github.com.pages.FormFieldsPage.formFieldWithLabelSelect;
import static io.github.com.pages.FormFieldsPage.hideRequiredMarker;
import static io.github.com.pages.FormFieldsPage.modifiedLayoutFormFieldColor;
import static io.github.com.pages.FormFieldsPage.prefixSuffixFormFieldPassword;
import static io.github.com.pages.FormFieldsPage.simpleFormFieldInput;
import static io.github.com.pages.FormFieldsPage.simpleFormFieldSelect;
import static io.github.com.pages.FormFieldsPage.simpleFormFieldTextarea;
import static org.hamcrest.Matchers.containsString;

// TODO Move to the new page
@Ignore
public class FormFieldTests extends TestsInit {
@BeforeMethod(alwaysRun = true)
public void before() {
shouldBeLoggedIn();
angularPage.shouldBeOpened();
formFieldPage.open();
waitCondition((() -> formFieldPage.isOpened()));
formFieldPage.checkOpened();
}

@Test
public void simpleFormFieldTest() {
simpleFormFieldInput.show();
simpleFormFieldInput.has().inputLabel(1, "Input");
simpleFormFieldInput.has().textAreaLabel(1, "Textarea");
simpleFormFieldInput.has().dropdownLabel(1, "Select");
simpleFormFieldInput.set(1, "Test input value");
simpleFormFieldInput.has().value(1, "Test input value");
simpleFormFieldInput.set(2, "Option");
simpleFormFieldInput.has().value(2, "Option");
simpleFormFieldInput.set(3, "Test text area value");
simpleFormFieldInput.has().value(3, "Test text area value");
simpleFormFieldInput.input(1, "Input value");
simpleFormFieldInput.has().inputText(1, "Input value");
simpleFormFieldInput.has().inputText(1, containsString("Input"));
simpleFormFieldInput.select(1, "Option");
simpleFormFieldInput.has().dropdownText(1, "Option");
simpleFormFieldInput.has().dropdownText(1, containsString("tion"));
simpleFormFieldInput.setTextArea(1, "Text area value");
simpleFormFieldInput.has().textAreaText(1, "Text area value");
simpleFormFieldInput.has().textAreaText(1, containsString(" area v"));
simpleFormFieldInput.clearTextArea(1);
simpleFormFieldInput.has().textAreaText(1, "");
simpleFormFieldInput.set(3, "Another text area value");
simpleFormFieldInput.has().value(3, "Another text area value");
simpleFormFieldInput.clear(1);
simpleFormFieldInput.has().value(1, "");
simpleFormFieldInput.clear(3);
simpleFormFieldInput.has().value(3, "");
simpleFormFieldInput.has().label("Input");
simpleFormFieldTextarea.has().label("Textarea");
simpleFormFieldSelect.has().label("Select");
simpleFormFieldInput.set("Test input value");
simpleFormFieldInput.has().value("Test input value");
simpleFormFieldInput.has().value(containsString("st inp"));
simpleFormFieldSelect.is().empty();
simpleFormFieldSelect.set("Option");
simpleFormFieldSelect.has().value("Option");
simpleFormFieldSelect.has().value(containsString("Option"));
simpleFormFieldSelect.is().notEmpty();
simpleFormFieldTextarea.set("Test text area value");
simpleFormFieldTextarea.has().value("Test text area value");
simpleFormFieldTextarea.has().value(containsString("area v"));
simpleFormFieldInput.clear();
simpleFormFieldInput.has().value("");
simpleFormFieldTextarea.clear();
simpleFormFieldTextarea.has().value("");
}

@Test
public void formFieldWithLabelTest() {
formFieldWithLabelInputSimplePlaceholder.show();
formFieldWithLabelInputSimplePlaceholder.
has().inputPlaceholder(1, "Simple placeholder");
formFieldWithLabelInputSimplePlaceholder.
has().inputPlaceholder(2, "Simple placeholder");
formFieldWithLabelInputSimplePlaceholder.
has().placeholder(1, "Simple placeholder");
formFieldWithLabelInputSimplePlaceholder.
has().placeholder(2, "Simple placeholder");
formFieldWithLabelInputSimplePlaceholder.
has().label(2, "Both a label and a placeholder");
formFieldWithLabelInputSimplePlaceholder.
has().label(3, "favorite Fancy label");
formFieldWithLabelInputSimplePlaceholder.input(1, "First input value");
formFieldWithLabelInputSimplePlaceholder.
has().value(1, containsString("t input v"));
formFieldWithLabelInputSimplePlaceholder.input(2, "Second input value");
formFieldWithLabelInputSimplePlaceholder.select(1, "Option");
formFieldWithLabelInputSimplePlaceholder.
has().value(2, "Second input value");
formFieldWithLabelInputSimplePlaceholder.
has().value(3, "Option");
formFieldWithLabelInputSimplePlaceholder.has().placeholder("Simple placeholder");
formFieldWithLabelInputSimplePlaceholderAndLabel.has().placeholder("Simple placeholder");
formFieldWithLabelInputSimplePlaceholderAndLabel.has().label("Both a label and a placeholder");
formFieldWithLabelSelect.has().label("favorite Fancy label");
formFieldWithLabelInputSimplePlaceholder.set("First input value");
formFieldWithLabelInputSimplePlaceholder.has().value(containsString("t input v"));
formFieldWithLabelInputSimplePlaceholderAndLabel.set("Second input value");
formFieldWithLabelInputSimplePlaceholderAndLabel.has().value("Second input value");
formFieldWithLabelSelect.set("Option");
formFieldWithLabelSelect.has().value("Option");
}

@Test
public void formFieldAppearanceVariantsTest() {
formFieldAppearanceInputLegacy.show();
formFieldAppearanceInputLegacy.input(1, "Input 1 value");
formFieldAppearanceInputLegacy.has().value(1, "Input 1 value");
formFieldAppearanceInputLegacy.has().fieldIcon(1, "sentiment_very_satisfied");
formFieldAppearanceInputLegacy.doubleClick();
formFieldAppearanceInputLegacy.set("Input 1 value");
formFieldAppearanceInputLegacy.has().value( "Input 1 value");
formFieldAppearanceInputLegacy.has().fieldIcon("sentiment_very_satisfied");
formFieldAppearanceInputLegacy.is().filled();
formFieldAppearanceInputStandard.is().outlined();
}

@Test
public void formFieldWithErrorMessageTest() {
formFieldEmailInput.show();
formFieldEmailInput.input(1, "test@");
formFieldEmailInput.set("test@");
formFieldEmailInput.focusOut();
formFieldEmailInput.has().inputError(1, "Not a valid email");
formFieldEmailInput.clearInput(1);
formFieldEmailInput.has().inputError(1, "You must enter a value");
formFieldEmailInput.has().error(1, "You must enter a value");
formFieldEmailInput.set(1, "[email protected]");
formFieldEmailInput.has().value(1, "[email protected]");
formFieldEmailInput.clear(1);
formFieldEmailInput.has().inputError(1, "You must enter a value");
formFieldEmailInput.has().error("Not a valid email");
formFieldEmailInput.set(" ");
formFieldEmailInput.has().error("You must enter a value");
formFieldEmailInput.set("[email protected]");
formFieldEmailInput.has().value( "[email protected]");
formFieldEmailInput.set(" ");
formFieldEmailInput.has().error("You must enter a value");
}

@Test
public void formFieldsWithHintsTest() {
formFieldExampleContainerInputLimited.show();
formFieldExampleContainerInputLimited.has().hint(1, "0/10");
formFieldExampleContainerInputLimited.has().hint(2, "Here's the dropdown arrow ^");
formFieldExampleContainerInputLimited.set(1, "12345678901");
formFieldExampleContainerInputLimited.has().hint(1, "10/10");
formFieldExampleContainerInputLimited.has().inputHint(1, "10/10");
formFieldExampleContainerInputLimited.has().value(1, "1234567890");
formFieldExampleContainerInputLimited.has().hints(List.of("Max 10 characters", "0/10"));
formFieldExampleContainerDropdown.has().hint("Here's the dropdown arrow ^");
formFieldExampleContainerInputLimited.set("12345678901");
formFieldExampleContainerInputLimited.has().hint("10/10");
formFieldExampleContainerInputLimited.has().value( "1234567890");
}

@Test
public void formFieldsPrefixSuffixTest() {
prefixSuffixFormFieldPassword.show();
prefixSuffixFormFieldPassword.input(1, "Password");
prefixSuffixFormFieldPassword.clickIcon(1);
prefixSuffixFormFieldPassword.has().value(1, "Password");
prefixSuffixFormFieldPassword.set(1, "AnotherPassword");
prefixSuffixFormFieldPassword.has().value(1, "AnotherPassword");
prefixSuffixFormFieldPassword.clickIcon(1);
prefixSuffixFormFieldPassword.has().value(1, "AnotherPassword");
prefixSuffixFormFieldPassword.set("Password");
prefixSuffixFormFieldPassword.clickIcon();
prefixSuffixFormFieldPassword.has().value( "Password");
prefixSuffixFormFieldPassword.set("AnotherPassword");
prefixSuffixFormFieldPassword.has().value( "AnotherPassword");
prefixSuffixFormFieldPassword.clickIcon();
prefixSuffixFormFieldPassword.has().value( "AnotherPassword");
}

@Test
public void formFieldsThemesTest() {
modifiedLayoutFormFieldColor.show();
modifiedLayoutFormFieldColor.set(1, "Accent");
modifiedLayoutFormFieldColor.has().color(1, "rgba(0, 0, 0, 0.87)");
modifiedLayoutFormFieldColor.set(2, "20");
modifiedLayoutFormFieldColor.has().font(2, containsString("20px"));
modifiedLayoutFormFieldColor.set("Accent");
modifiedLayoutFormFieldColor.has().color("rgba(0, 0, 0, 0.87)");
}

@Test
public void formFieldsRequiredTest() {
formFieldWithLabelSelect.show();
formFieldWithLabelSelect.is().required();
hideRequiredMarker.click();
formFieldWithLabelSelect.is().notRequired();
}

@Test
public void formFieldsFloatLabelTest() {
formFieldWithLabelSelect.show();
alwaysFloatLabel.click();
formFieldWithLabelSelect.has().alwaysFloatLabel();
}

@Test
public void formFieldsDisabledTest() {
formFieldDisabled.show();
formFieldDisabled.is().disabled();
formFieldEmailInput.is().notDisabled();
}

@Test
public void formFieldsSubscriptSizingTest() {
formFieldSubscriptSizingFixed.show();
formFieldSubscriptSizingFixed.has().notDynamicSubscriptSizing();
formFieldSubscriptSizingDynamic.has().dynamicSubscriptSizing();
}
}
Loading