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

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

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

import net.serenitybdd.markers.CanBeSilent;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.Performable;
import net.serenitybdd.screenplay.abilities.BrowseTheWeb;

import java.util.function.Consumer;

/**
 * Perform an action directly with the Serenity WebDriver API.
 * For example:
 * 
 *     
 *         actor.attemptsTo(
 *             InTheBrowser.perform(
 *                 browser -> browser.evaluateJavascript("window.localStorage.clear()")
 *             )
 *         );
 *     
 * 
* * You can access the Driver instance directly using browser.getDriver(). */ public class InTheBrowser implements Performable, CanBeSilent { private final Consumer action; private boolean isSilent = false; public InTheBrowser(Consumer action) { this.action = action; } public static InTheBrowser perform(Consumer action) { return new InTheBrowser(action); } @Override public void performAs(T actor) { action.accept(BrowseTheWeb.as(actor)); } @Override public boolean isSilent() { return isSilent; } public Performable withNoReporting() { this.isSilent = true; return this; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy