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

net.serenitybdd.screenplay.actions.HitElement Maven / Gradle / Ivy

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

import net.serenitybdd.core.pages.WebElementFacade;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.Interaction;
import net.serenitybdd.annotations.Step;
import org.openqa.selenium.Keys;

import java.util.Arrays;

public class HitElement implements Interaction {

    private Keys[] keys;
    private String pluraliser;
    private WebElementFacade element;

    public HitElement(Keys[] keys, WebElementFacade element) {
        this.keys = Arrays.copyOf(keys,keys.length);
        this.element = element;
    }

    @Step("{0} hits the '#keys' key#pluraliser")
    public  void performAs(T theUser) {
        pluraliser = pluralSuffixOf(keys);
        element.sendKeys(keys);
    }

    private String pluralSuffixOf(Keys[] keys) {
        return keys.length > 1 ? "s" : "";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy