Hi
The most simple way is to implement WebDriverEventListener (extend AbstractWebDriverEventListner) and use this
EventFiringWebDriver driver =
new EventFiringWebDriver(appiumDriverInstance);
driver.register(new YourWebDriverEventListener() /** new YourAbstractWebDriverEventListnerSubClass() */);
But I don't like this way because it limits your capabilities. For example you won't receive MobileElements because EventFiringWebDriver generates EventFiringWebWebElement. It wraps original element and implements WebElement + WrapsElement. You have to extend EventFiringWebDriver.
Another way is more difficult but much smarter. It is the usage of AOP.
For example, I could bit extend WebDriverEventListener and use it without EventFiringWebDriver. I use Spring and AspectJ. This is an example of the listener. So when I invoke
(RemoteWebDriver) context.getBean("webdriver",params);
I get something that extends FireFoxDriver, ChromeDrive, AndroidDriver, IOSDriver and so on. All that I get is listenable.