Search in sources :

Example 1 with DriverListener

use of com.qaprosoft.carina.core.foundation.webdriver.listener.DriverListener in project carina by qaprosoft.

the class DriverFactory method getEventListeners.

/**
 * Reads 'driver_event_listeners' configuration property and initializes
 * appropriate array of driver event listeners.
 *
 * @return array of driver listeners
 */
private static WebDriverEventListener[] getEventListeners() {
    List<WebDriverEventListener> listeners = new ArrayList<>();
    try {
        // explicitly add default carina com.qaprosoft.carina.core.foundation.webdriver.listener.DriverListener
        DriverListener driverListener = new DriverListener();
        listeners.add(driverListener);
        String listenerClasses = Configuration.get(Parameter.DRIVER_EVENT_LISTENERS);
        if (!StringUtils.isEmpty(listenerClasses)) {
            for (String listenerClass : listenerClasses.split(",")) {
                Class<?> clazz = Class.forName(listenerClass);
                if (WebDriverEventListener.class.isAssignableFrom(clazz)) {
                    WebDriverEventListener listener = (WebDriverEventListener) clazz.newInstance();
                    listeners.add(listener);
                    LOGGER.debug("Webdriver event listener registered: " + clazz.getName());
                }
            }
        }
    } catch (Exception e) {
        LOGGER.error("Unable to register webdriver event listeners!", e);
    }
    return listeners.toArray(new WebDriverEventListener[listeners.size()]);
}
Also used : WebDriverEventListener(org.openqa.selenium.support.events.WebDriverEventListener) ArrayList(java.util.ArrayList) DriverListener(com.qaprosoft.carina.core.foundation.webdriver.listener.DriverListener)

Aggregations

DriverListener (com.qaprosoft.carina.core.foundation.webdriver.listener.DriverListener)1 ArrayList (java.util.ArrayList)1 WebDriverEventListener (org.openqa.selenium.support.events.WebDriverEventListener)1