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

net.serenitybdd.screenplay.actions.HoverOverBy 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.abilities.BrowseTheWeb;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import java.util.List;

import static net.serenitybdd.screenplay.targets.EnsureFieldVisible.ensureThat;

public class HoverOverBy extends Hover {

    private List locators;
    protected WebElement resolveElementFor(Actor actor) {
        return resolveFor(actor);
    }

    @Override
    protected String getTarget() {
        return locators.toString();
    }

    public HoverOverBy(List locators) {
        this.locators = locators;
    }

    protected WebElement resolveFor(Actor theActor) {
        WebElementFacade element = null;
        for(By locator : locators) {
            element = (element == null) ? BrowseTheWeb.as(theActor).find(locator) : element.find(locator);
        }
        ensureThat(theActor).canSee(element);
        return element;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy