HI,
As part of the framework we are developing in our project, we want to implement a custom listener extending the AbstractWebDriverEventListner class.
Can anyone help with how to implement this for AppiumDriver?
thanks.
HI,
As part of the framework we are developing in our project, we want to implement a custom listener extending the AbstractWebDriverEventListner class.
Can anyone help with how to implement this for AppiumDriver?
thanks.
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.
I am also looking for this implementation, if we can have listener, where I can intercept onCreate()/onLoad() activity etc, will help to reduce redundancy on framework design.
Hi SergeyTichimirov,
I tried the method suggested by you. Actually my idea is to create some additional wait before every Find By operation. I have given a Console output statement in each listener method to check this. But unfortunately during the run time none of the statements are getting printed.
I am using framework with Page Object Model.
Any help is much appreciated.