Jacobvu84 / screenplay-cucumber-webdriver

The demo shows the integration of Serenity BDD, Screenplay and Cucumber JVM.
1 stars 1 forks source link

Getting the list text on UI and convert to List<String> #6

Open Jacobvu84 opened 5 years ago

Jacobvu84 commented 5 years ago
package pageobject.pages;

import net.serenitybdd.core.pages.PageObject;
import net.serenitybdd.core.pages.WebElementFacade;
import net.thucydides.core.annotations.DefaultUrl;
import org.openqa.selenium.By;

import java.util.List;
import java.util.stream.Collectors;

@DefaultUrl("http://blazedemo.com/reserve.php")
public class FlightsPage extends PageObject {
    /*
        SELECTORS
     */
    private static final String FLIGHT_NUMBERS = ".table tbody tr td:nth-of-type(2)";

    /*
        ACTIONS
     */
    public List<String> getFlights(){
        return findAll(By.cssSelector(FLIGHT_NUMBERS)).stream()
                .map(WebElementFacade::getText)
                .collect(Collectors.toList());
    }
}
Jacobvu84 commented 5 years ago

Return a list of all the elements matching the TODO_ITEMS target:

return Text.of(ToDoList.TODO_ITEMS)
           .viewedBy(actor)
           .asList();
Jacobvu84 commented 5 years ago
public List<String> getJobTabs() {
        List<WebElementFacade> tabs = findAll("//div[@id='tabs']//a");
        return extract(tabs, on(WebElement.class).getText());
    }