Skip to content

Support for EventListener #54

Open
@aik099

Description

@aik099
Contributor

In Ruby's client for WebDriver protocol there is a way to place event listeners on various events on WebDriver side (see https://code.google.com/p/selenium/source/browse/rb/lib/selenium/webdriver/support/abstract_event_listener.rb, http://elementalselenium.com/tips/55-wrapper).

Is it possible to do the same in PHP WebDriver version?

Activity

robocoder

robocoder commented on Jun 19, 2014

@robocoder
Member

Theoretically, this is possible.

In lieu of aspects for cross cutting concerns, I'm not opposed to this.

aik099

aik099 commented on Jun 19, 2014

@aik099
ContributorAuthor

What I want this for is to be able to set expectations for alert/prompt/confirm dialog before they happen. Ideally knowing if executed WebDriver command resulted in alert/prompt/confirm dialog opening without extra API call would be great as well.

robocoder

robocoder commented on Jul 6, 2021

@robocoder
Member
self-assigned this
on Apr 15, 2022
robocoder

robocoder commented on Dec 9, 2023

@robocoder
Member

Brainstorming:

  • consumer calls ServiceFactory to register their event dispatcher (whatever implements PSR14)
  • AbstractWebDriver::curl() would dispatch the before/after events to the registered event dispatcher
  • listeners would not be able to modify the request/response, or interrupt flow (eg throwing exception)

As for the event object, at minimum:

  • before, url
  • after, url, status

Stumbling blocks:

  • Whether or not to include post parameters (ie can be large for upload file)
  • Whether or not to include the response value (ie can be large for page source, screenshot, and download file)
  • Parsing the url will be messy to figure out which webdriver command will be/was executed.

So, I think we should be identifying the webdriver command before calling AbstractWebDriver::curl(). This is complicated by the commands that we declare via @method and use via __call().

linked a pull request that will close this issueEvents #130on Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @robocoder@aik099

    Issue actions

      Support for EventListener · Issue #54 · instaclick/php-webdriver