use of org.openqa.selenium.support.events.WebDriverEventListener 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()]);
}
Aggregations