Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restores "LegacyWindow" class into a working state #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 55 additions & 14 deletions lib/WebDriver/LegacyWindow.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
* WebDriver\LegacyWindow class
*
* @package WebDriver
*
* @method void maximize() Maximize the window if not already maximized.
* @method array getPosition() Get position of the window.
* @method void postPosition($json) Change position of the window.
* @method array getSize() Get size of the window.
* @method void postSize($json) Change the size of the window.
*/
class LegacyWindow extends AbstractWebDriver
{
Expand All @@ -34,12 +28,7 @@ class LegacyWindow extends AbstractWebDriver
*/
protected function methods()
{
return array(
// Legacy JSON Wire Protocol
'maximize' => array('POST'),
'position' => array('GET', 'POST'),
'size' => array('GET', 'POST'),
);
return array();
}

/**
Expand All @@ -62,7 +51,59 @@ public function __construct($url, $windowHandle = null)
{
parent::__construct($url);

$this->windowHandle = $windowHandle;
$this->windowHandle = $windowHandle ?: 'current';
}

/**
* Maximize the window if not already maximized: /session/:sessionId/window/:windowHandle/maximize (POST)
*/
public function maximize()
{
$this->curl('POST', "/{$this->windowHandle}/maximize");
}

/**
* Get position of the window: /session/:sessionId/window/:windowHandle/position (GET)
*
* @return array
*/
public function getPosition()
{
$result = $this->curl('GET', "/{$this->windowHandle}/position");

return $result['value'];
}

/**
* Change position of the window: /session/:sessionId/window/:windowHandle/position (POST)
*
* @param array $json
*/
public function postPosition(array $json)
{
$this->curl('POST', "/{$this->windowHandle}/position", $json);
}

/**
* Get size of the window: /session/:sessionId/window/:windowHandle/size (GET)
*
* @return array
*/
public function getSize()
{
$result = $this->curl('GET', "/{$this->windowHandle}/size");

return $result['value'];
}

/**
* Change the size of the window: /session/:sessionId/window/:windowHandle/size (POST)
*
* @param array $json
*/
public function postSize(array $json)
{
$this->curl('POST', "/{$this->windowHandle}/size", $json);
}

/**
Expand All @@ -74,7 +115,7 @@ public function __construct($url, $windowHandle = null)
*/
public function getHandle()
{
if (! $this->windowHandle) {
if (! $this->windowHandle || $this->windowHandle === 'current') {
$result = $this->curl('GET', '_handle');

$this->windowHandle = $result['value'];
Expand Down
Loading