instaclick / php-webdriver

W3C and Selenium 2 webdriver "thin client" for php 5.3+ and namespaces.
Other
436 stars 62 forks source link

The `LegacyWindow` class doesn't work anymore #138

Open aik099 opened 6 months ago

aik099 commented 6 months ago

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 commented 6 months ago

The #139 solves all of the described problems.