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

net.serenitybdd.screenplay.playwright.questions.Text Maven / Gradle / Ivy

There is a newer version: 4.2.9
Show newest version
package net.serenitybdd.screenplay.playwright.questions;

import net.serenitybdd.screenplay.Question;
import net.serenitybdd.screenplay.playwright.Target;
import net.serenitybdd.screenplay.playwright.abilities.BrowseTheWebWithPlaywright;

import java.util.List;

/**
 * Return the inner text value of an element.
 */
public class Text {
    public static Question of(Target element) {
        return of(element.asSelector());
    }

    public static Question of(String selector) {
        return Question.about("the text value of " + selector).answeredBy(
                actor -> BrowseTheWebWithPlaywright.as(actor).getCurrentPage().innerText(selector)
        );
    }

    public static Question> ofEach(Target element) {
        return ofEach(element.asSelector());
    }

    public static Question> ofEach(String selector) {
        return Question.about("the text values of " + selector).answeredBy(
                actor -> BrowseTheWebWithPlaywright.as(actor).getCurrentPage().locator(selector).allInnerTexts()
        );
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy