From 0aec531ff4301a1b4034b793c61e8a5ad6512c22 Mon Sep 17 00:00:00 2001 From: Astrumas Date: Fri, 7 Sep 2012 19:45:39 -0600 Subject: [PATCH 01/57] Implement moveToElementWithOffset Action --- PHPWebDriver/WebDriverActionChains.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PHPWebDriver/WebDriverActionChains.php b/PHPWebDriver/WebDriverActionChains.php index 02885ade2..670f08535 100644 --- a/PHPWebDriver/WebDriverActionChains.php +++ b/PHPWebDriver/WebDriverActionChains.php @@ -70,7 +70,10 @@ public function moveToElement($toElement, $curl_opts = array()) { return $this; } - public function moveToElementWithOffset($toElement, $xOffset, $yOffset) {} + public function moveToElementWithOffset($toElement, $xOffset, $yOffset) { + $this->actions[] = '$this->session->moveto(array("element" => "' . $toElement->getID() . '", "xoffset" => '.$xOffset.', "yoffset" => '.$yOffset.'));'; + return $this; + } public function release($onElement) {} From 75de701cf43ecdb5851f0174e5632aa835053d7f Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Fri, 2 Nov 2012 00:11:19 -0400 Subject: [PATCH 02/57] fixing switching of frames --- PHPWebDriver/WebDriverSession.php | 2 +- test/FrameTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/PHPWebDriver/WebDriverSession.php b/PHPWebDriver/WebDriverSession.php index 2e4e59473..9264ec978 100644 --- a/PHPWebDriver/WebDriverSession.php +++ b/PHPWebDriver/WebDriverSession.php @@ -195,7 +195,7 @@ public function touch() { public function switch_to_frame($frame = null, $curl_opts = array()) { if (is_a($frame, "PHPWebDriver_WebDriverElement")) { - $frame_id = array("id" => (int)$frame->getId()); + $frame_id = array("ELEMENT" => (int)$frame->getId()); } else { throw new InvalidArgumentException('$frame needs to be a webdriver element of a frame'); } diff --git a/test/FrameTest.php b/test/FrameTest.php index d3b38caf5..0f03addeb 100644 --- a/test/FrameTest.php +++ b/test/FrameTest.php @@ -17,6 +17,7 @@ public static function tearDownAfterClass() { } public function test_frame_stuff() { + $divs = self::$session->elements("css selector", "div"); // find your iframe $iframe = self::$session->element("css selector", "iframe"); // switch context to it From 78d417fb1fa14d992300fc0dad9d0c3c7909771f Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Fri, 2 Nov 2012 00:11:55 -0400 Subject: [PATCH 03/57] 1.4.0 --- package.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.xml b/package.xml index d064217e5..871db5304 100644 --- a/package.xml +++ b/package.xml @@ -16,10 +16,10 @@ adam@element34.ca yes - 2012-09-13 + 2012-11-02 - 1.3.0 - 1.3.0 + 1.4.0 + 1.4.0 stable From 9d603a5c01f0c6df18390100b3a45f8f3f0f4551 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Fri, 2 Nov 2012 00:52:23 -0400 Subject: [PATCH 04/57] really fixing frames --- PHPWebDriver/WebDriverSession.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/PHPWebDriver/WebDriverSession.php b/PHPWebDriver/WebDriverSession.php index 9264ec978..2ff0d91ef 100644 --- a/PHPWebDriver/WebDriverSession.php +++ b/PHPWebDriver/WebDriverSession.php @@ -195,11 +195,10 @@ public function touch() { public function switch_to_frame($frame = null, $curl_opts = array()) { if (is_a($frame, "PHPWebDriver_WebDriverElement")) { - $frame_id = array("ELEMENT" => (int)$frame->getId()); + $frame_id = array("id" => array("ELEMENT" => $frame->getId())); } else { throw new InvalidArgumentException('$frame needs to be a webdriver element of a frame'); } - $results = $this->curl('POST', '/frame', $frame_id, From 2bb4da375b9b1c91ac8c7706e85a8f3144056f7d Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Fri, 2 Nov 2012 00:53:34 -0400 Subject: [PATCH 05/57] 1.4.1 --- package.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.xml b/package.xml index 871db5304..d0a4fe663 100644 --- a/package.xml +++ b/package.xml @@ -18,8 +18,8 @@ 2012-11-02 - 1.4.0 - 1.4.0 + 1.4.1 + 1.4.1 stable From 6b9f03d766a7a9c1dff6f67c6b1ec3a0de64968d Mon Sep 17 00:00:00 2001 From: Bernard Peh Date: Thu, 8 Nov 2012 13:42:26 +1100 Subject: [PATCH 06/57] fixed switch_to_frame() function as it doesn't allow switching back to parent frame. $session->frame did but its better to standardize switch_to_frame() to do the trick. --- PHPWebDriver/WebDriverSession.php | 4 +++- test/FrameTest.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/PHPWebDriver/WebDriverSession.php b/PHPWebDriver/WebDriverSession.php index 2ff0d91ef..69d044c30 100644 --- a/PHPWebDriver/WebDriverSession.php +++ b/PHPWebDriver/WebDriverSession.php @@ -196,6 +196,8 @@ public function touch() { public function switch_to_frame($frame = null, $curl_opts = array()) { if (is_a($frame, "PHPWebDriver_WebDriverElement")) { $frame_id = array("id" => array("ELEMENT" => $frame->getId())); + } elseif ($frame == null) { + $frame_id = null; } else { throw new InvalidArgumentException('$frame needs to be a webdriver element of a frame'); } @@ -243,4 +245,4 @@ protected function getElementPath($element_id) { return sprintf('%s/element/%s', $this->url, $element_id); } } -?> \ No newline at end of file +?> diff --git a/test/FrameTest.php b/test/FrameTest.php index 0f03addeb..6781f9e92 100644 --- a/test/FrameTest.php +++ b/test/FrameTest.php @@ -26,6 +26,6 @@ public function test_frame_stuff() { $ps = self::$session->elements("css selector", "p"); $this->assertEquals(count($ps), 6); // switch back - self::$session->frame(); + self::$session->switch_to_frame(); } } From bc1dfbff83190f524f73432fa361a994422402e8 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Fri, 18 Jan 2013 21:30:03 -0500 Subject: [PATCH 07/57] making proxying ssl work --- PHPWebDriver/WebDriverProxy.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/PHPWebDriver/WebDriverProxy.php b/PHPWebDriver/WebDriverProxy.php index cb0483120..6d7f793ab 100644 --- a/PHPWebDriver/WebDriverProxy.php +++ b/PHPWebDriver/WebDriverProxy.php @@ -41,6 +41,7 @@ function __set($property, $value) { break; case "ftpProxy": case "httpProxy": + case "sslProxy": case "noProxy": $this->proxyType = PHPWebDriver_ProxyType::$MANUAL; $this->$property = $value; @@ -49,10 +50,6 @@ function __set($property, $value) { $this->proxyType = PHPWebDriver_ProxyType::$PAC; $this->$property = $value; break; - case "sslProxy": - $this->proxyType = $value; - $this->$property = $value; - break; default: $this->$property = $value; } From 99d9dc89b1bdae6bc133c71b45eec7853613aca0 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Fri, 18 Jan 2013 21:32:42 -0500 Subject: [PATCH 08/57] 1.5.0 release --- package.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.xml b/package.xml index d0a4fe663..3f531f44f 100644 --- a/package.xml +++ b/package.xml @@ -16,10 +16,10 @@ adam@element34.ca yes - 2012-11-02 + 2013-01-18 - 1.4.1 - 1.4.1 + 1.5.0 + 1.5.0 stable From 7d89d20e8e34f15621d7117971fc6e5efa6c0862 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 22 Jan 2013 14:41:42 -0500 Subject: [PATCH 09/57] updating the readme to have a note about 404ing with old pear --- README.md | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 41fbd2e4e..5691ce620 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,16 @@ What got added, what got removed and what got fixed is listed in the (Release No * This driver has been packaged for distribution via PEAR. So... - pear channel-discover element-34.github.com/pear - pear install -f element-34/PHPWebDriver +```php +pear channel-discover element-34.github.com/pear +pear install -f element-34/PHPWebDriver +``` + + Note: if you recieve a 404 during the channel-discover set, check that you are using the current version of PEAR. If not you need to + +```php +pear upgrade pear +``` * All you need as the server for this client is the selenium-server-standalone-#.jar file provided here: http://code.google.com/p/selenium/downloads/list @@ -35,15 +43,17 @@ What got added, what got removed and what got fixed is listed in the (Release No * Then when you create a session, be sure to pass the url to where your server is running. - // This would be the url of the host running the server-standalone.jar - $wd_host = 'http://localhost:4444/wd/hub'; - $web_driver = new PHPWebDriver_WebDriver($wd_host); +```php +// This would be the url of the host running the server-standalone.jar +$wd_host = 'http://localhost:4444/wd/hub'; +$web_driver = new PHPWebDriver_WebDriver($wd_host); - // First param to session() is the 'browserName' (default = 'firefox') - // Second param is a JSON object of additional 'desiredCapabilities' +// First param to session() is the 'browserName' (default = 'firefox') +// Second param is a JSON object of additional 'desiredCapabilities' - // POST /session - $session = $web_driver->session('firefox'); +// POST /session +$session = $web_driver->session('firefox'); +``` * Valid browser strings * firefox From f821825c62d107723125601105e8ec378ea6a73e Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 22 Jan 2013 14:45:59 -0500 Subject: [PATCH 10/57] formatting... --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5691ce620..36c3b4374 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ pear channel-discover element-34.github.com/pear pear install -f element-34/PHPWebDriver ``` - Note: if you recieve a 404 during the channel-discover set, check that you are using the current version of PEAR. If not you need to +Note: if you recieve a 404 during the channel-discover set, check that you are using the current version of PEAR. If not you need to ```php pear upgrade pear From 2c714dd4974bcfa8255ddc2b8cd8195b119a9e12 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 22 Jan 2013 16:53:35 -0500 Subject: [PATCH 11/57] possibly clearing up a bit around finding elements --- README.md | 67 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 36c3b4374..8e1f953da 100644 --- a/README.md +++ b/README.md @@ -67,17 +67,6 @@ $session = $web_driver->session('firefox'); * ipad * android -* You can either refer to a location method by its string value, or by a const defined in WebDriverBy.php. The - advantage to this is that you will know much faster (as in compile time) whether you have fat-fingered something. - * ID - * XPATH - * LINK_TEXT - * PARTIAL_LINK_TEXT - * NAME - * TAG_NAME - * CLASS_NAME - * CSS_SELECTOR - ## SIMPLE EXAMPLES ### Note that all of these match the Protocol exactly @@ -155,17 +144,57 @@ $session = $web_driver->session('firefox'); * To find elements - // POST /session/:sessionId/element - $element = $session->element($using, $value); +```php +// POST /session/:sessionId/element +$element = $session->element($using, $value); +``` + +```php +// POST /session/:sessionId/elements +$session->elements($using, $value); +``` + +```php +// POST /session/:sessionId/element/:id/element +$element->element($using, $value); +``` - // POST /session/:sessionId/elements - $session->elements($using, $value); +```php +// POST /session/:sessionId/element/:id/elements +$element->elements($using, $value); +``` - // POST /session/:sessionId/element/:id/element - $element->element($using, $value); + $using its the location method either as a string value + * id + * xpath + * link text + * partial link text + * name + * tag name + * class name + * css selector + + or by a const defined in WebDriverBy.php. The advantage to this is that you will know much faster (as in compile time) whether you have fat-fingered something. + * ID + * XPATH + * LINK_TEXT + * PARTIAL_LINK_TEXT + * NAME + * TAG_NAME + * CLASS_NAME + * CSS_SELECTOR + + In other words, the following are equivilant - // POST /session/:sessionId/element/:id/elements - $element->elements($using, $value); +```php +// POST /session/:sessionId/element +$element = $session->element("id", $value); +`` + +```php +// POST /session/:sessionId/element +$element = $session->element(PHPWebDriver_WebDriverBy::ID, $value); +`` * To get the active element From 2622887587ef9200730fcdd5697ecb459c7c0e3e Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 22 Jan 2013 16:54:58 -0500 Subject: [PATCH 12/57] readme formatting --- README.md | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 8e1f953da..534bee814 100644 --- a/README.md +++ b/README.md @@ -164,27 +164,27 @@ $element->element($using, $value); $element->elements($using, $value); ``` - $using its the location method either as a string value - * id - * xpath - * link text - * partial link text - * name - * tag name - * class name - * css selector - - or by a const defined in WebDriverBy.php. The advantage to this is that you will know much faster (as in compile time) whether you have fat-fingered something. - * ID - * XPATH - * LINK_TEXT - * PARTIAL_LINK_TEXT - * NAME - * TAG_NAME - * CLASS_NAME - * CSS_SELECTOR - - In other words, the following are equivilant +$using its the location method either as a string value + * id + * xpath + * link text + * partial link text + * name + * tag name + * class name + * css selector + +or by a const defined in WebDriverBy.php. The advantage to this is that you will know much faster (as in compile time) whether you have fat-fingered something. + * ID + * XPATH + * LINK_TEXT + * PARTIAL_LINK_TEXT + * NAME + * TAG_NAME + * CLASS_NAME + * CSS_SELECTOR + +In other words, the following are equivilant ```php // POST /session/:sessionId/element From efcc34bcdf9b26cfe9431f3275dc8616e287952c Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 22 Jan 2013 16:57:23 -0500 Subject: [PATCH 13/57] missing some`'s --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 534bee814..d5e7e536a 100644 --- a/README.md +++ b/README.md @@ -164,7 +164,7 @@ $element->element($using, $value); $element->elements($using, $value); ``` -$using its the location method either as a string value +$using is the the location method either as a string value * id * xpath * link text @@ -189,12 +189,12 @@ In other words, the following are equivilant ```php // POST /session/:sessionId/element $element = $session->element("id", $value); -`` +``` ```php // POST /session/:sessionId/element $element = $session->element(PHPWebDriver_WebDriverBy::ID, $value); -`` +``` * To get the active element From b97a99dc58b5f0c1a0ce93fa1cd7a4f9a727d2a5 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Wed, 23 Jan 2013 22:25:22 -0500 Subject: [PATCH 14/57] PHPWebDriver_Support_WebDriverSelect --- PHPWebDriver/Support/WebDriverSelect.php | 215 +++++++++++++++++++++++ package.xml | 3 + test/support/SelectTest.php | 190 ++++++++++++++++++++ 3 files changed, 408 insertions(+) create mode 100644 PHPWebDriver/Support/WebDriverSelect.php create mode 100644 test/support/SelectTest.php diff --git a/PHPWebDriver/Support/WebDriverSelect.php b/PHPWebDriver/Support/WebDriverSelect.php new file mode 100644 index 000000000..64f32bf84 --- /dev/null +++ b/PHPWebDriver/Support/WebDriverSelect.php @@ -0,0 +1,215 @@ +name(); + if (strtolower($name) != 'select') { + throw new PHPWebDriver_UnexpectedTagNameException("Select only works on