All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.serenitybdd.screenplay.actions.selectactions.SelectByIndexFromBy Maven / Gradle / Ivy

There is a newer version: 4.2.8
Show newest version
package net.serenitybdd.screenplay.actions.selectactions;

import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.abilities.BrowseTheWeb;
import net.serenitybdd.screenplay.actions.ByAction;
import net.serenitybdd.annotations.Step;
import org.openqa.selenium.By;

import java.util.Collections;
import java.util.List;

public class SelectByIndexFromBy extends ByAction {
    private List indexes;

    public SelectByIndexFromBy() {}

    public SelectByIndexFromBy(Integer index, By... locators) {
        super(locators);
        this.indexes = Collections.singletonList(index);
    }

    public SelectByIndexFromBy(List indexes, By... locators) {
        super(locators);
        this.indexes = indexes;
    }

    @Step("{0} selects index #index")
    public  void performAs(T theUser) {
        indexes.forEach(
            index -> BrowseTheWeb.as(theUser).find(locators).selectByIndex(index)
        );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy