minkphp / Mink

PHP web browser emulator abstraction
https://mink.behat.org/
MIT License
1.6k stars 278 forks source link

Switching windows by name or handle? #868

Open aik099 opened 6 months ago

aik099 commented 6 months ago

Technical limitations

Switching windows by a handle

Switching windows by a name

Current implementation

Proposed implementation

See https://github.com/minkphp/MinkSelenium2Driver/pull/384 .

The downside of the proposed implementation

  1. All windows need to be iterated to retrieve their name, which:
    • can be slow when lots of windows are opened (these websites exist?);
    • when the website has a JavaScript code that closes a window upon focus loss, then iteration can be very bad.
  2. When the window is renamed after opening, then window name obtained by the getWindowName or getWindowNames would produce NoSuchWindow exception, when given to the switchToWindow method

Comments from contributors

In the https://github.com/minkphp/MinkSelenium2Driver/pull/384/files#r1501886088 @uuf6429 proposed to replace window name support with window handle support Mink-wise. Considering, that Selenium-based drivers are the only ones that support window operations now.

In the https://github.com/minkphp/MinkSelenium2Driver/pull/384/files#r1501840465 @mvorisek explained window handle workflow like this:

  1. user opens a window
  2. user store the handle
  3. user uses the handle to switch to that window

I personally like the proposed implementation, because:

stof commented 6 months ago

Please keep any discussion about the changing the Mink API in the main Mink repo rather than in drivers please.

aik099 commented 6 months ago

Please keep any discussion about the changing the Mink API in the main Mink repo rather than in drivers please.

Understood. Moved the issue to the main repo.