Search in sources :

Example 1 with PageValidator

use of com.consol.citrus.selenium.model.PageValidator in project yaks by citrusframework.

the class SeleniumSteps method pageByType.

@Given("^(?:Browser|browser) page \"([^\"]+)\" of type ([^\\s]+)$")
public void pageByType(String id, String type) {
    try {
        Object page = Class.forName(type).newInstance();
        pages.put(id, (WebPage) page);
        if (page instanceof PageValidator) {
            validators.put(id, (PageValidator<?>) page);
        }
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        throw new CitrusRuntimeException("Failed to load page object", e);
    }
}
Also used : PageValidator(com.consol.citrus.selenium.model.PageValidator) CitrusRuntimeException(com.consol.citrus.exceptions.CitrusRuntimeException) Given(io.cucumber.java.en.Given)

Example 2 with PageValidator

use of com.consol.citrus.selenium.model.PageValidator in project yaks by citrusframework.

the class SeleniumSteps method page.

@Given("^(?:Browser|browser) page \"([^\"]+)\"$")
public void page(String id) {
    if (!citrus.getCitrusContext().getReferenceResolver().isResolvable(id, WebPage.class)) {
        throw new CitrusRuntimeException("Unable to find page for id: " + id);
    }
    WebPage page = citrus.getCitrusContext().getReferenceResolver().resolve(id, WebPage.class);
    pages.put(id, page);
    if (page instanceof PageValidator) {
        validators.put(id, (PageValidator<?>) page);
    }
}
Also used : WebPage(com.consol.citrus.selenium.model.WebPage) PageValidator(com.consol.citrus.selenium.model.PageValidator) CitrusRuntimeException(com.consol.citrus.exceptions.CitrusRuntimeException) Given(io.cucumber.java.en.Given)

Aggregations

CitrusRuntimeException (com.consol.citrus.exceptions.CitrusRuntimeException)2 PageValidator (com.consol.citrus.selenium.model.PageValidator)2 Given (io.cucumber.java.en.Given)2 WebPage (com.consol.citrus.selenium.model.WebPage)1