Search in sources :

Example 1 with AbstractPage

use of org.keycloak.testsuite.pages.AbstractPage in project keycloak by keycloak.

the class AbstractX509AuthenticationTest method replaceDefaultWebDriver.

public void replaceDefaultWebDriver(WebDriver driver) {
    this.driver = driver;
    DroneUtils.addWebDriver(driver);
    List<Field> allFields = new ArrayList<>();
    // Add all fields of this class and superclasses
    Class<?> testClass = this.getClass();
    while (AbstractX509AuthenticationTest.class.isAssignableFrom(testClass)) {
        allFields.addAll(Arrays.asList(testClass.getDeclaredFields()));
        allFields.addAll(Arrays.asList(testClass.getFields()));
        testClass = testClass.getSuperclass();
    }
    for (Field f : allFields) {
        if (f.getAnnotation(Page.class) != null) {
            try {
                AbstractPage page = (AbstractPage) f.get(this);
                page.setDriver(driver);
            } catch (IllegalAccessException e) {
                throw new IllegalStateException("Could not replace the driver in " + f, e);
            }
        }
    }
}
Also used : Field(java.lang.reflect.Field) AbstractPage(org.keycloak.testsuite.pages.AbstractPage) ArrayList(java.util.ArrayList) Page(org.jboss.arquillian.graphene.page.Page) LoginPage(org.keycloak.testsuite.pages.LoginPage) X509IdentityConfirmationPage(org.keycloak.testsuite.pages.x509.X509IdentityConfirmationPage) AppPage(org.keycloak.testsuite.pages.AppPage) AbstractPage(org.keycloak.testsuite.pages.AbstractPage)

Aggregations

Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 Page (org.jboss.arquillian.graphene.page.Page)1 AbstractPage (org.keycloak.testsuite.pages.AbstractPage)1 AppPage (org.keycloak.testsuite.pages.AppPage)1 LoginPage (org.keycloak.testsuite.pages.LoginPage)1 X509IdentityConfirmationPage (org.keycloak.testsuite.pages.x509.X509IdentityConfirmationPage)1