0

I'm implementing an EventFiringWebDriver, respectively, a WebDriverEventListener, where I need data both from before and after particular events (e.g. beforeClickOn and afterClickOn). Since I wasn't able to find anything in the docs, I would like to know if a situtation can occur where a before event isn't immediately followed by its corresponding after event? Something like:

(beforeEventA, beforeEventB, afterEventA, ...)

So, can I rely on the invocation order of before and after?

beatngu13
  • 7,201
  • 6
  • 37
  • 66

1 Answers1

0

As you are implementing WebDriverEventListeners interface this surely can happen based on how you define the implementing methods. Let me give you an example, say you are performing a click event and in beforeClickOn method you tried to perform an operation such as refesh page, so the behaviour will go like this:

beforeOnClick->beforeRefresh->afterRefresh->afterOnClick

As now you can see that the behaviour is totally dependent on how you want your driver to perform the task.

Hope this helped.

anurag0510
  • 763
  • 1
  • 8
  • 17
  • Sure, if I invoke other before/after methods from within a before/after method, this can happen. But if I don't, does it still happen in rare situations? Picking up your refresh example: [this answer](https://stackoverflow.com/a/40939076/3429133) shows five different ways to refresh a page via WebDriver, none of which uses a click action. Can you think of such a situtation? – beatngu13 Jan 06 '19 at 14:13
  • 1
    @beatngu13 WebDriverEventListener only listens to the events performed by the driver i.e if we go through the examples link shared by you and pick the very first sample where we sent F5 key in that case even though refresh action was performed the only involvement by our driver was to send keys in this case F5 there wasn't any refresh action taken by driver(i.e event). So it won't be monitored by event listener. To summarize there aren't any such cases where a before event isn't immediately followed by its corresponding after event as per my knowledge. Please let me know if you find something. – anurag0510 Jan 06 '19 at 18:04