com.epam.jdi.bdd.stepdefs.CheckListSteps Maven / Gradle / Ivy
package com.epam.jdi.bdd.stepdefs;
import com.epam.jdi.light.elements.complex.Checklist;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import java.util.List;
import static com.epam.jdi.light.elements.init.entities.collection.EntitiesCollection.getUI;
import static com.jdiai.tools.LinqUtils.toIntArray;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasSize;
/**
* Created by Roman Iovlev on 26.09.2019
* Email: [email protected]; Skype: roman.iovlev
*/
public class CheckListSteps {
public static Checklist checklist(String name) {
return getUI(name, Checklist.class);
}
@When("^(?:I |)check element \"([^\"]*)\" in \"([^\"]*)\" checklist$")
public static void iCheckCheckBox(String value, String name) {
checklist(name).check(value);
}
@When("^(?:I |)check elements in \"([^\"]*)\" checklist:$")
public static void iCheckCheckboxes(String name, List values) {
checklist(name).check(values.toArray(new String[0]));
}
@When("^(?:I |)uncheck in \"([^\"]*)\" checklist elements:$")
public static void iUncheckElements(String name, List values) {
checklist(name).uncheck(values.toArray(new String[0]));
}
@When("^(?:I |)uncheck element \"([^\"]*)\" in \"([^\"]*)\" checklist$")
public static void iUnCheckCheckBox(String value, String name) {
checklist(name).uncheck(value);
}
@When("^(?:I |)check in \"([^\"]*)\" checklist elements by numbers:$")
public static void iCheckElementsByNumbers(String name, List values) {
checklist(name).check(toIntArray(values));
}
@When("^(?:I |)check in \"([^\"]*)\" checklist element by numbers (\\d+)$")
public static void iCheckElementByNumbers(String name, int value) {
checklist(name).check(value);
}
@When("^(?:I |)uncheck in \"([^\"]*)\" checklist elements by numbers:$")
public static void iUncheckCheckBoxesByNumbers(String name, List values) {
checklist(name).uncheck(toIntArray(values));
}
@When("^(?:I |)uncheck in \"([^\"]*)\" checklist element by numbers (\\d+)$")
public static void iUncheckCheckBoxesByNumbers(String name, int value) {
checklist(name).uncheck(value);
}
@When("^(?:I |)select elements in \"([^\"]*)\" checklist by numbers:$")
public static void iSelectCheckBoxesByNumbers(String name, List values) {
checklist(name).select(toIntArray(values));
}
@When("^(?:I |)select element in \"([^\"]*)\" checklist by number (\\d+)$")
public static void iSelectCheckBoxByNumbers(String name, int value) {
checklist(name).select(value);
}
@When("^(?:I |)check all elements in \"([^\"]*)\" checklist")
public static void iCheckAllCheckBoxes(String name) {
checklist(name).checkAll();
}
@When("^(?:I |)uncheck all elements in \"([^\"]*)\" checklist$")
public static void iUncheckAllCheckBoxes(String name) {
checklist(name).uncheckAll();
}
@Then("^in \"([^\"]*)\" checklist \"([^\"]*)\" is checked$")
public static void isCheckBoxChecked(String name, String value) {
checklist(name).is().selected(containsString(value));
}
@Then("count of selected elements in \"([^\"]*)\" checklist is (\\d+)")
public static void countOfSelectedCheckBoxes(String name, int count) {
checklist(name).is().checked(hasSize(count));
}
@Then("in the \"([^\"]*)\" checklist checked elements are:$")
public static void isCheckBoxesChecked(String name, List values) {
checklist(name).is().checked(values);
}
@Then("the \"([^\"]*)\" checklist value is \"([^\"]*)\"$")
public static void checkListTextIs(String name, String text) {
checklist(name).has().text(text);
}
@When("^(?:I |)Select fields from \"([^\"]*)\":$")
public static void multiSelect(String name, List values) {
checklist(name).select(values.toArray(new String[0]));
}
}