Class JavaScript<T>
java.lang.Object
net.serenitybdd.screenplay.playwright.questions.JavaScript<T>
- All Implemented Interfaces:
net.serenitybdd.screenplay.Question<T>
Evaluate JavaScript and return the result.
Playwright's evaluate method passes arguments directly to the expression. For multiple arguments, use an arrow function with array destructuring:
Sample usage:
// No arguments
String title = actor.asksFor(JavaScript.evaluate("document.title"));
// Single argument
String value = actor.asksFor(JavaScript.evaluate("arg => document.getElementById(arg).value")
.withArguments("email"));
// Multiple arguments (use array destructuring)
Object result = actor.asksFor(JavaScript.evaluate("([a, b]) => a * b")
.withArguments(6, 7));
-
Method Summary
Modifier and TypeMethodDescriptionansweredBy(net.serenitybdd.screenplay.Actor actor) static <T> JavaScript<T>Evaluate JavaScript and return the result.toString()withArguments(Object... args) Provide arguments to the script.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.serenitybdd.screenplay.Question
as, asADate, asADate, asBigDecimal, asBoolean, asCollectionOf, asDouble, asEnum, asFloat, asInteger, asListOf, asLong, asString, describedAs, getSubject, map, mapEach
-
Method Details
-
evaluate
Evaluate JavaScript and return the result. -
withArguments
Provide arguments to the script. Single argument is available directly, multiple arguments are passed as an array. -
answeredBy
- Specified by:
answeredByin interfacenet.serenitybdd.screenplay.Question<T>
-
toString
-