2

I'm using Serenity v 1.0.7. I need to add hooks in my code to ensure that code coverage metrics are saved after tests are run. Also, I'd like to save code coverage numbers before the browser is closed or navigated away from the page that is instrumented (using JSCover). My base test suite class which all my test classes extend has this:

@Managed(uniqueSession = true)
private static WebDriver webDriver;

What I want to do is have my own custom WebDriver class which will intercept close(), navigateX(), and catch exceptions among other calls as well. I would then call my method to persist the code coverage data then proceed with the given driver command.

However, WebDriver is an interface so I cannot extend it. I can implement it. When I do this, I get 20 methods I need to overwrite but with what? How do I bind with a Serenity-managed driver instance?

I've looked into WebDriverFacade but when I write my own CustomWebDriverFacade and do a "drop-in" like this:

@Managed(uniqueSession = true)
private static CustomWebDriverFacade webDriver;

It reports "no tests were executed" and fails.

I've looked into WebDriverEventListener but it does not allow listening for close() which is critical for me since code coverage numbers are lost when the driver is closed.

I think the core question is this -> Can Serenity @Managed work with a custom WebDriver class?

Thanks for any pointers, Rob

user1814008
  • 201
  • 3
  • 9

0 Answers0