php-webdriver icon indicating copy to clipboard operation
php-webdriver copied to clipboard

The `LegacyWindow` class doesn't work anymore

Open aik099 opened this issue 1 year ago • 1 comments

The LegacyWindow class in the master branch no longer includes a window handle (or current for the current window) in the made cURL requests to the Selenium server. This results in the /session/{sessionId}/window/size URL instead of the /session/{sessionId}/window/{windowHandle}/size URL.

Constructor declaration change fixes all window commands, except for the LegacyWindow::getHandle method:

if ($windowHandle === null) {
    $windowHandle = 'current';
}

parent::__construct($url . '/' . $windowHandle);

// The "current" meta-handle isn't accepted by any other command.
if ($windowHandle !== 'current') {
    $this->windowHandle = $windowHandle;
}

With the above fix the LegacyWindow::getHandle now queries the /session/{sessionId}/window/{windowHandle}_handle URL instead of the /session/{sessionId}/window_handle.

Since the \WebDriver\AbstractWebDriver::curl method can't subtract URL parts, then the only way to fix this was actually to implement all the window manipulation methods instead of relying on the AbstractWebDriver::__call method.

P.S. Apparently, the JsonWireProtocol supports resizing of the non-active windows, which W3C does not allow.

aik099 avatar Mar 20 '24 20:03 aik099

The #139 solves all of the described problems.

aik099 avatar Mar 21 '24 06:03 aik099