From 0aec531ff4301a1b4034b793c61e8a5ad6512c22 Mon Sep 17 00:00:00 2001 From: Astrumas Date: Fri, 7 Sep 2012 19:45:39 -0600 Subject: [PATCH 01/75] 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 c480c94f9394f2dbaac3a46bd9c4a7dda40a8d27 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 11 Sep 2012 20:13:11 -0400 Subject: [PATCH 02/75] basic support for the color class. and by basic i mean empty. :D --- PHPWebDriver/Support/WebDriverColor.php | 30 +++++ package.xml | 3 + test/support/ColorTest.php | 159 ++++++++++++++++++++++++ 3 files changed, 192 insertions(+) create mode 100644 PHPWebDriver/Support/WebDriverColor.php create mode 100644 test/support/ColorTest.php diff --git a/PHPWebDriver/Support/WebDriverColor.php b/PHPWebDriver/Support/WebDriverColor.php new file mode 100644 index 000000000..7dd88150f --- /dev/null +++ b/PHPWebDriver/Support/WebDriverColor.php @@ -0,0 +1,30 @@ +color = $color; + return $this; + } + + public function rgb() {} + + public function rgba() {} + + public function hex() {} + +} \ No newline at end of file diff --git a/package.xml b/package.xml index 3140672e4..3a80e54cc 100644 --- a/package.xml +++ b/package.xml @@ -50,6 +50,9 @@ + + + diff --git a/test/support/ColorTest.php b/test/support/ColorTest.php new file mode 100644 index 000000000..80417e870 --- /dev/null +++ b/test/support/ColorTest.php @@ -0,0 +1,159 @@ +assertEquals($rgb, $c->rgb()); + } + + /** + * @test + * @group color + */ + public function rgbToRgba() { + $rgb = "rgb(1, 2, 3)"; + $c = new PHPWebDriver_Support_Color($rgb); + $this->assertEquals("rgba(1, 2, 3, 1)", $c->rgba()); + } + + /** + * @test + * @group color + */ + public function rgbPctToRgba() { + $rgba = "rgb(10%, 20%, 30%)"; + $c = new PHPWebDriver_Support_Color($rgba); + $this->assertEquals("rgba(25, 51, 76, 1)", $c->rgba()); + } + + /** + * @test + * @group color + */ + public function rgbAllowsWhitespace() { + $rgb = "rgb(\t1, 2 , 3)"; + $canonicalRgb = "rgb(1, 2, 3)"; + $c = new PHPWebDriver_Support_Color($rgb); + $this->assertEquals($canonicalRgb, $c->rgb()); + } + + /** + * @test + * @group color + */ + public function rgbaToRgba() { + $rgba = "rgba(1, 2, 3, 0.5)"; + $c = new PHPWebDriver_Support_Color($rgba); + $this->assertEquals($rgba, $c->rgba()); + } + + /** + * @test + * @group color + */ + public function rgbaPctToRgba() { + $rgba = "rgba(10%, 20%, 30%, 0.5)"; + $c = new PHPWebDriver_Support_Color($rgba); + $this->assertEquals("rgba(25, 51, 76, 0.5)", $c->rgba()); + } + + /** + * @test + * @group color + */ + public function hexToHex() { + $hex = "#ff00a0"; + $c = new PHPWebDriver_Support_Color($hex); + $this->assertEquals($hex, $c->hex()); + } + + /** + * @test + * @group color + */ + public function hexToRgb() { + $hex = "#01Ff03"; + $rgb = "rgb(1, 255, 3)"; + $c = new PHPWebDriver_Support_Color($hex); + $this->assertEquals($rgb, $c->hex()); + } + + /** + * @test + * @group color + */ + public function hexToRgba() { + $hex = "#01Ff03"; + $rgba = "rgba(1, 255, 3, 1)"; + $c = new PHPWebDriver_Support_Color($hex); + $this->assertEquals($rgba, $c->hex()); + + // same test data as hex3 below + $hex = "#00ff33"; + $rgba = "rgba(0, 255, 51, 1)"; + $c = new PHPWebDriver_Support_Color($hex); + $this->assertEquals($rgba, $c->hex()); + } + + /** + * @test + * @group color + */ + public function rgbToHex() { + $hex = "#01ff03"; + $rgb = "rgb(1, 255, 3)"; + $c = new PHPWebDriver_Support_Color($rgb); + $this->assertEquals($hex, $c->rgb()); + } + + /** + * @test + * @group color + */ + public function hex3ToRgba() { + $hex = "#0f3"; + $rgba = "rgba(0, 255, 51, 1)"; + $c = new PHPWebDriver_Support_Color($hex); + $this->assertEquals($rgba, $c->rgba()); + } + + /** + * @test + * @group color + */ + public function hslToRgba() { + $hsl = "hsl(120, 100%, 25%)"; + $rgba = "rgba(0, 128, 0, 1)"; + $c = new PHPWebDriver_Support_Color($hsl); + $this->assertEquals($rgba, $c->rgba()); + + $hsl = "hsl(100, 0%, 50%)"; + $rgba = "rgba(128, 128, 128, 1)"; + $c = new PHPWebDriver_Support_Color($hsl); + $this->assertEquals($rgba, $c->rgba()); + } + + /** + * @test + * @group color + */ + public function hslaToRgba() { + $hsla = "hsla(120, 100%, 25%, 1)"; + $rgba = "rgba(0, 128, 0, 1)"; + $c = new PHPWebDriver_Support_Color($hsla); + $this->assertEquals($rgba, $c->rgba()); + + $hsla = "hsla(100, 0%, 50%, 0.5)"; + $rgba = "rgba(128, 128, 128, 0.5)"; + $c = new PHPWebDriver_Support_Color($hsla); + $this->assertEquals($rgba, $c->rgba()); + } +} From 9da1bbf6a6a82b36783baf3f9b3f23cbe8b34385 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 11 Sep 2012 20:20:22 -0400 Subject: [PATCH 03/75] rgbToRgb passes --- PHPWebDriver/Support/WebDriverColor.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/PHPWebDriver/Support/WebDriverColor.php b/PHPWebDriver/Support/WebDriverColor.php index 7dd88150f..961d9bf9c 100644 --- a/PHPWebDriver/Support/WebDriverColor.php +++ b/PHPWebDriver/Support/WebDriverColor.php @@ -13,15 +13,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -include_once('WebDriverExceptions.php'); - class PHPWebDriver_Support_Color { public function __construct($color) { $this->color = $color; return $this; } - public function rgb() {} + public function rgb() { + if (substr($this->color, 0, 3) === "rgb" && substr($this->color, 3, 4) !== "a") { + return $this->color; + } + } public function rgba() {} From d30a1daa62940cf5db2f2058a918304252ea1969 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 11 Sep 2012 21:03:37 -0400 Subject: [PATCH 04/75] ok, different implementation of rgb() --- PHPWebDriver/Support/WebDriverColor.php | 31 +++++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/PHPWebDriver/Support/WebDriverColor.php b/PHPWebDriver/Support/WebDriverColor.php index 961d9bf9c..c7e442fb0 100644 --- a/PHPWebDriver/Support/WebDriverColor.php +++ b/PHPWebDriver/Support/WebDriverColor.php @@ -15,17 +15,38 @@ class PHPWebDriver_Support_Color { public function __construct($color) { - $this->color = $color; + $this->_color = $color; + + $a = '1.0'; + + // rgb + if (substr($color, 0, 3) === "rgb" && substr($color, 3, 4) !== "a") { + $pattern = '/^\s*rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)\s*$/'; + preg_match($pattern, $color, $matches); + } + + if (count($matches) != 0) { + $a = '1.0'; + if (count($matches) == 5) { + $a = $matches[4]; + } + $this->red = $matches[1]; + $this->green = $matches[2]; + $this->blue = $matches[3]; + $this->alpha = $a; + } else { + throw new InvalidArgumentException('Did not know how to convert ' . $color . ' into a color'); + } return $this; } public function rgb() { - if (substr($this->color, 0, 3) === "rgb" && substr($this->color, 3, 4) !== "a") { - return $this->color; - } + return 'rgb(' . $this->red . ', ' . $this->green . ', ' . $this->blue . ')'; } - public function rgba() {} + public function rgba() { + + } public function hex() {} From 129d2914ca76aff5d10c2c5ad664b4c74bb201e1 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 11 Sep 2012 21:17:38 -0400 Subject: [PATCH 05/75] rgbToRgba() --- PHPWebDriver/Support/WebDriverColor.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/PHPWebDriver/Support/WebDriverColor.php b/PHPWebDriver/Support/WebDriverColor.php index c7e442fb0..f5c6c9c96 100644 --- a/PHPWebDriver/Support/WebDriverColor.php +++ b/PHPWebDriver/Support/WebDriverColor.php @@ -17,16 +17,18 @@ class PHPWebDriver_Support_Color { public function __construct($color) { $this->_color = $color; - $a = '1.0'; - - // rgb + if (substr($color, 0, 3) === "rgb" && substr($color, 3, 4) !== "a") { + // rgb $pattern = '/^\s*rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)\s*$/'; - preg_match($pattern, $color, $matches); + } elseif (substr($color, 0, 4) === "rgba") { + // rgba + $pattern = '/^\s*rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0\.\d+)\s*\)\s*$/'; } + preg_match($pattern, $color, $matches); + $a = 1; if (count($matches) != 0) { - $a = '1.0'; if (count($matches) == 5) { $a = $matches[4]; } @@ -45,7 +47,7 @@ public function rgb() { } public function rgba() { - + return 'rgba(' . $this->red . ', ' . $this->green . ', ' . $this->blue . ', ' . $this->alpha . ')'; } public function hex() {} From 1192437e30a2fec563ce9e5bd81ee280e84c0fc3 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 11 Sep 2012 21:53:14 -0400 Subject: [PATCH 06/75] now iterating over the patterns rather than guess before apply a particular pattern --- PHPWebDriver/Support/WebDriverColor.php | 41 +++++++++++++------------ 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/PHPWebDriver/Support/WebDriverColor.php b/PHPWebDriver/Support/WebDriverColor.php index f5c6c9c96..a8e1a8d2e 100644 --- a/PHPWebDriver/Support/WebDriverColor.php +++ b/PHPWebDriver/Support/WebDriverColor.php @@ -15,30 +15,31 @@ class PHPWebDriver_Support_Color { public function __construct($color) { - $this->_color = $color; - - - if (substr($color, 0, 3) === "rgb" && substr($color, 3, 4) !== "a") { + $patterns = array( + // rgb % + '/^\s*rgb\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*\)\s*$/', // rgb - $pattern = '/^\s*rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)\s*$/'; - } elseif (substr($color, 0, 4) === "rgba") { + '/^\s*rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)\s*$/', + // rgba % + '/^\s*rgba\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(0|1|0\.\d+)\s*\)\s*$/', // rgba - $pattern = '/^\s*rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0\.\d+)\s*\)\s*$/'; - } - - preg_match($pattern, $color, $matches); - $a = 1; - if (count($matches) != 0) { - if (count($matches) == 5) { - $a = $matches[4]; + '/^\s*rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0\.\d+)\s*\)\s*$/' + ); + + $a = 1; + foreach($patterns as $pattern) { + preg_match($pattern, $color, $matches); + if (count($matches) != 0) { + if (count($matches) == 5) { + $a = $matches[4]; + } + $this->red = $matches[1]; + $this->green = $matches[2]; + $this->blue = $matches[3]; + $this->alpha = $a; } - $this->red = $matches[1]; - $this->green = $matches[2]; - $this->blue = $matches[3]; - $this->alpha = $a; - } else { - throw new InvalidArgumentException('Did not know how to convert ' . $color . ' into a color'); } + return $this; } From c2ab9f22f5fe84499da8e58c02c26eba28db91d8 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 11 Sep 2012 22:06:52 -0400 Subject: [PATCH 07/75] conversation of % values now works --- PHPWebDriver/Support/WebDriverColor.php | 27 ++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/PHPWebDriver/Support/WebDriverColor.php b/PHPWebDriver/Support/WebDriverColor.php index a8e1a8d2e..b0fd4a52f 100644 --- a/PHPWebDriver/Support/WebDriverColor.php +++ b/PHPWebDriver/Support/WebDriverColor.php @@ -15,20 +15,20 @@ class PHPWebDriver_Support_Color { public function __construct($color) { - $patterns = array( + $matchers = array( // rgb % - '/^\s*rgb\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*\)\s*$/', + array('/^\s*rgb\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*\)\s*$/', true), // rgb - '/^\s*rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)\s*$/', + array('/^\s*rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)\s*$/', false), // rgba % - '/^\s*rgba\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(0|1|0\.\d+)\s*\)\s*$/', + array('/^\s*rgba\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(0|1|0\.\d+)\s*\)\s*$/', true), // rgba - '/^\s*rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0\.\d+)\s*\)\s*$/' + array('/^\s*rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0\.\d+)\s*\)\s*$/', false), ); $a = 1; - foreach($patterns as $pattern) { - preg_match($pattern, $color, $matches); + foreach($matchers as $matcher) { + preg_match($matcher[0], $color, $matches); if (count($matches) != 0) { if (count($matches) == 5) { $a = $matches[4]; @@ -37,6 +37,7 @@ public function __construct($color) { $this->green = $matches[2]; $this->blue = $matches[3]; $this->alpha = $a; + $this->percent = $matcher[1]; } } @@ -44,11 +45,19 @@ public function __construct($color) { } public function rgb() { - return 'rgb(' . $this->red . ', ' . $this->green . ', ' . $this->blue . ')'; + if ($this->percent) { + return 'rgb(' . floor($this->red / 100 * 255) . ', ' . floor($this->green / 100 * 255) . ', ' . floor($this->blue / 100 * 255) . ')'; + } else { + return 'rgb(' . $this->red . ', ' . $this->green . ', ' . $this->blue . ')'; + } } public function rgba() { - return 'rgba(' . $this->red . ', ' . $this->green . ', ' . $this->blue . ', ' . $this->alpha . ')'; + if ($this->percent) { + return 'rgba(' . floor($this->red / 100 * 255) . ', ' . floor($this->green / 100 * 255) . ', ' . floor($this->blue / 100 * 255) . ', ' . $this->alpha . ')'; + } else { + return 'rgba(' . $this->red . ', ' . $this->green . ', ' . $this->blue . ', ' . $this->alpha . ')'; + } } public function hex() {} From 997532b5bae783848f1706a768ab1aee67d57ddc Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 11 Sep 2012 22:39:18 -0400 Subject: [PATCH 08/75] hexToHex() --- PHPWebDriver/Support/WebDriverColor.php | 46 +++++++++++++++---------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/PHPWebDriver/Support/WebDriverColor.php b/PHPWebDriver/Support/WebDriverColor.php index b0fd4a52f..cebc0c173 100644 --- a/PHPWebDriver/Support/WebDriverColor.php +++ b/PHPWebDriver/Support/WebDriverColor.php @@ -17,13 +17,15 @@ class PHPWebDriver_Support_Color { public function __construct($color) { $matchers = array( // rgb % - array('/^\s*rgb\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*\)\s*$/', true), + array('/^\s*rgb\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*\)\s*$/', true, false), // rgb - array('/^\s*rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)\s*$/', false), + array('/^\s*rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)\s*$/', false, false), // rgba % - array('/^\s*rgba\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(0|1|0\.\d+)\s*\)\s*$/', true), + array('/^\s*rgba\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(0|1|0\.\d+)\s*\)\s*$/', true, false), // rgba - array('/^\s*rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0\.\d+)\s*\)\s*$/', false), + array('/^\s*rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0\.\d+)\s*\)\s*$/', false, false), + // hex + array('/^#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i', false, true) ); $a = 1; @@ -33,11 +35,23 @@ public function __construct($color) { if (count($matches) == 5) { $a = $matches[4]; } - $this->red = $matches[1]; - $this->green = $matches[2]; - $this->blue = $matches[3]; + if ($matcher[1]) { + // deal with percent values + $this->red = floor($matches[1] / 100 * 255); + $this->green = floor($matches[2] / 100 * 255); + $this->blue = floor($matches[3] / 100 * 255); + } elseif ($matcher[2]) { + // deal with hex + $this->red = intval($matches[1], 16); + $this->green = intval($matches[2], 16); + $this->blue = intval($matches[3], 16); + } else { + // regular things + $this->red = $matches[1]; + $this->green = $matches[2]; + $this->blue = $matches[3]; + } $this->alpha = $a; - $this->percent = $matcher[1]; } } @@ -45,21 +59,15 @@ public function __construct($color) { } public function rgb() { - if ($this->percent) { - return 'rgb(' . floor($this->red / 100 * 255) . ', ' . floor($this->green / 100 * 255) . ', ' . floor($this->blue / 100 * 255) . ')'; - } else { - return 'rgb(' . $this->red . ', ' . $this->green . ', ' . $this->blue . ')'; - } + return 'rgb(' . $this->red . ', ' . $this->green . ', ' . $this->blue . ')'; } public function rgba() { - if ($this->percent) { - return 'rgba(' . floor($this->red / 100 * 255) . ', ' . floor($this->green / 100 * 255) . ', ' . floor($this->blue / 100 * 255) . ', ' . $this->alpha . ')'; - } else { - return 'rgba(' . $this->red . ', ' . $this->green . ', ' . $this->blue . ', ' . $this->alpha . ')'; - } + return 'rgba(' . $this->red . ', ' . $this->green . ', ' . $this->blue . ', ' . $this->alpha . ')'; } - public function hex() {} + public function hex() { + return '#' . sprintf('%02x', $this->red) . sprintf('%02x', $this->green) . sprintf('%02x', $this->blue); + } } \ No newline at end of file From 7aa9e40dd70b712b7e95d0009e79550d3b8d1802 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 11 Sep 2012 22:41:30 -0400 Subject: [PATCH 09/75] hexToRgb() works better if you call the right method. duh --- test/ElementsTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/ElementsTest.php b/test/ElementsTest.php index 928efebc2..3c5560d8d 100644 --- a/test/ElementsTest.php +++ b/test/ElementsTest.php @@ -31,5 +31,16 @@ public function testElementsDoesNotExist() { $e = $this->session->elements('css selector', '.flyingmonkey'); $this->assertEquals(count($e), 0); } + + /** + * @group elements + */ + public function testElementsChaining() { + $this->session = self::$driver->session(); // firefox + $this->session->open("https://github.com/element-34/php-webdriver"); + $tabs = $this->session->elements('css selector', '.tabs'); + $li = $tabs[0]->elements('css selector', 'li'); + $this->assertEquals(count($li), 6); + } } ?> \ No newline at end of file From 1e74820568b05d2a08b06c88949482f7c5f1df41 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 11 Sep 2012 22:43:03 -0400 Subject: [PATCH 10/75] some more improperly called methods --- test/support/ColorTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/support/ColorTest.php b/test/support/ColorTest.php index 80417e870..3f12e92c4 100644 --- a/test/support/ColorTest.php +++ b/test/support/ColorTest.php @@ -83,7 +83,7 @@ public function hexToRgb() { $hex = "#01Ff03"; $rgb = "rgb(1, 255, 3)"; $c = new PHPWebDriver_Support_Color($hex); - $this->assertEquals($rgb, $c->hex()); + $this->assertEquals($rgb, $c->rgb()); } /** @@ -94,13 +94,13 @@ public function hexToRgba() { $hex = "#01Ff03"; $rgba = "rgba(1, 255, 3, 1)"; $c = new PHPWebDriver_Support_Color($hex); - $this->assertEquals($rgba, $c->hex()); + $this->assertEquals($rgba, $c->rgba()); // same test data as hex3 below $hex = "#00ff33"; $rgba = "rgba(0, 255, 51, 1)"; $c = new PHPWebDriver_Support_Color($hex); - $this->assertEquals($rgba, $c->hex()); + $this->assertEquals($rgba, $c->rgba()); } /** @@ -111,7 +111,7 @@ public function rgbToHex() { $hex = "#01ff03"; $rgb = "rgb(1, 255, 3)"; $c = new PHPWebDriver_Support_Color($rgb); - $this->assertEquals($hex, $c->rgb()); + $this->assertEquals($hex, $c->hex()); } /** From 962dc308c1e0a23ac2bc58d1173031f166c70eb3 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 11 Sep 2012 22:55:46 -0400 Subject: [PATCH 11/75] hex3 conversions --- PHPWebDriver/Support/WebDriverColor.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/PHPWebDriver/Support/WebDriverColor.php b/PHPWebDriver/Support/WebDriverColor.php index cebc0c173..b9abfe680 100644 --- a/PHPWebDriver/Support/WebDriverColor.php +++ b/PHPWebDriver/Support/WebDriverColor.php @@ -17,15 +17,17 @@ class PHPWebDriver_Support_Color { public function __construct($color) { $matchers = array( // rgb % - array('/^\s*rgb\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*\)\s*$/', true, false), + array('/^\s*rgb\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*\)\s*$/', true, false, false), // rgb - array('/^\s*rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)\s*$/', false, false), + array('/^\s*rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)\s*$/', false, false, false), // rgba % - array('/^\s*rgba\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(0|1|0\.\d+)\s*\)\s*$/', true, false), + array('/^\s*rgba\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(0|1|0\.\d+)\s*\)\s*$/', true, false, false), // rgba - array('/^\s*rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0\.\d+)\s*\)\s*$/', false, false), + array('/^\s*rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0\.\d+)\s*\)\s*$/', false, false, false), // hex - array('/^#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i', false, true) + array('/^#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i', false, true, false), + // hex3 + array('/^#([a-f0-9]{1})([a-f0-9]{1})([a-f0-9]{1})$/i', false, true, true), ); $a = 1; @@ -40,11 +42,16 @@ public function __construct($color) { $this->red = floor($matches[1] / 100 * 255); $this->green = floor($matches[2] / 100 * 255); $this->blue = floor($matches[3] / 100 * 255); - } elseif ($matcher[2]) { + } elseif ($matcher[2] && !$matcher[3]) { // deal with hex $this->red = intval($matches[1], 16); $this->green = intval($matches[2], 16); $this->blue = intval($matches[3], 16); + } elseif ($matcher[2] && $matcher[3]) { + // deal with hex 3 + $this->red = intval($matches[1] . $matches[1], 16); + $this->green = intval($matches[2] . $matches[2], 16); + $this->blue = intval($matches[3] . $matches[3], 16); } else { // regular things $this->red = $matches[1]; From dd2e6e1200f09e19e786186cea52e7abfcd44f53 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 11 Sep 2012 23:01:00 -0400 Subject: [PATCH 12/75] getting rid of magic flags --- PHPWebDriver/Support/WebDriverColor.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/PHPWebDriver/Support/WebDriverColor.php b/PHPWebDriver/Support/WebDriverColor.php index b9abfe680..153879d51 100644 --- a/PHPWebDriver/Support/WebDriverColor.php +++ b/PHPWebDriver/Support/WebDriverColor.php @@ -17,37 +17,37 @@ class PHPWebDriver_Support_Color { public function __construct($color) { $matchers = array( // rgb % - array('/^\s*rgb\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*\)\s*$/', true, false, false), + array("pattern" => '/^\s*rgb\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*\)\s*$/', "name" => "rgb %"), // rgb - array('/^\s*rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)\s*$/', false, false, false), + array("pattern" => '/^\s*rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)\s*$/', "name" => "rgb"), // rgba % - array('/^\s*rgba\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(0|1|0\.\d+)\s*\)\s*$/', true, false, false), + array("pattern" => '/^\s*rgba\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(0|1|0\.\d+)\s*\)\s*$/', "name" => "rgba %"), // rgba - array('/^\s*rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0\.\d+)\s*\)\s*$/', false, false, false), + array("pattern" => '/^\s*rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0\.\d+)\s*\)\s*$/', "name" => "rgba"), // hex - array('/^#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i', false, true, false), - // hex3 - array('/^#([a-f0-9]{1})([a-f0-9]{1})([a-f0-9]{1})$/i', false, true, true), + array("pattern" => '/^#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i', "name" => "hex"), + // hex 3 + array("pattern" => '/^#([a-f0-9]{1})([a-f0-9]{1})([a-f0-9]{1})$/i', "name" => "hex 3"), ); $a = 1; foreach($matchers as $matcher) { - preg_match($matcher[0], $color, $matches); + preg_match($matcher["pattern"], $color, $matches); if (count($matches) != 0) { if (count($matches) == 5) { $a = $matches[4]; } - if ($matcher[1]) { + if ($matcher["name"] === "rgb %" || $matcher["name"] === "rgba %") { // deal with percent values $this->red = floor($matches[1] / 100 * 255); $this->green = floor($matches[2] / 100 * 255); $this->blue = floor($matches[3] / 100 * 255); - } elseif ($matcher[2] && !$matcher[3]) { + } elseif ($matcher["name"] === "hex") { // deal with hex $this->red = intval($matches[1], 16); $this->green = intval($matches[2], 16); $this->blue = intval($matches[3], 16); - } elseif ($matcher[2] && $matcher[3]) { + } elseif ($matcher["name"] === "hex 3") { // deal with hex 3 $this->red = intval($matches[1] . $matches[1], 16); $this->green = intval($matches[2] . $matches[2], 16); From 4782ceb7f0ca37f17212bc6bb74b534599129b56 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 11 Sep 2012 23:05:07 -0400 Subject: [PATCH 13/75] hsl and hsla patterns. no implementation mind you... --- PHPWebDriver/Support/WebDriverColor.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PHPWebDriver/Support/WebDriverColor.php b/PHPWebDriver/Support/WebDriverColor.php index 153879d51..6ae93abd8 100644 --- a/PHPWebDriver/Support/WebDriverColor.php +++ b/PHPWebDriver/Support/WebDriverColor.php @@ -28,6 +28,10 @@ public function __construct($color) { array("pattern" => '/^#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i', "name" => "hex"), // hex 3 array("pattern" => '/^#([a-f0-9]{1})([a-f0-9]{1})([a-f0-9]{1})$/i', "name" => "hex 3"), + // hsl + array("pattern" => '/^\s*hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})\%\s*,\s*(\d{1,3})\%\s*\)\s*$/', "name" => "hsl"), + // hsla + array("pattern" => '/^\s*hsla\(\s*(\d{1,3})\s*,\s*(\d{1,3})\%\s*,\s*(\d{1,3})\%\s*,\s*(0|1|0\.\d+)\s*\)\s*$/', "name" => "hsla"), ); $a = 1; From 9d0270cf3d23972ad156e20643c848557e5dece3 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Tue, 11 Sep 2012 23:44:36 -0400 Subject: [PATCH 14/75] hslToRgba() --- PHPWebDriver/Support/WebDriverColor.php | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/PHPWebDriver/Support/WebDriverColor.php b/PHPWebDriver/Support/WebDriverColor.php index 6ae93abd8..1c8d325c8 100644 --- a/PHPWebDriver/Support/WebDriverColor.php +++ b/PHPWebDriver/Support/WebDriverColor.php @@ -56,6 +56,44 @@ public function __construct($color) { $this->red = intval($matches[1] . $matches[1], 16); $this->green = intval($matches[2] . $matches[2], 16); $this->blue = intval($matches[3] . $matches[3], 16); + } elseif ($matcher["name"] === "hsl" || $matcher["name"] === "hsla") { + // deal with hsl madness; + $h = $matches[1] / 360; + $s = $matches[2] / 100; + $l = $matches[3] / 100; + if ($s == 0) { + $r = $l; + $g = $r; + $b = $r; + } else { + $hueToRgb = function($luminocity1, $luminocity2, $hue) { + if ($hue < 0.0) { + $hue += 1; + } + if ($hue > 1.0) { + $hue -= 1; + } + if ($hue < 1.0 / 6.0) { + return ($luminocity1 + ($luminocity2 - $luminocity1) * 6.0 * $hue); + } + if ($hue < 1.0 / 2.0) { + return $luminocity2; + } + if ($hue < 2.0 / 3.0) { + return ($luminocity1 + ($luminocity2 - $luminocity1) * ((2.0 / 3.0) - $hue) * 6.0); + } + return $luminocity1; + }; + $luminocity2 = ($l < 0.5) ? $l * (1 + $s) : $l + $s - $l * $s; + $luminocity1 = 2 * $l - $luminocity2; + $r = $hueToRgb($luminocity1, $luminocity2, $h + 1.0 / 3.0); + $g = $hueToRgb($luminocity1, $luminocity2, $h); + $b = $hueToRgb($luminocity1, $luminocity2, $h - 1.0 / 3.0); + } + + $this->red = $r * 256; + $this->green = $g * 256; + $this->blue = $b * 256; } else { // regular things $this->red = $matches[1]; From d0ad29bb4a4e75d9ddb5b0f2b9acd99c9ed3b820 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Wed, 12 Sep 2012 22:41:25 -0400 Subject: [PATCH 15/75] implementing doubleClick --- PHPWebDriver/WebDriverActionChains.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/PHPWebDriver/WebDriverActionChains.php b/PHPWebDriver/WebDriverActionChains.php index 02885ade2..2cc69fb9d 100644 --- a/PHPWebDriver/WebDriverActionChains.php +++ b/PHPWebDriver/WebDriverActionChains.php @@ -53,7 +53,13 @@ public function clickAndHold($onElement) {} public function contextClick($onElement) {} - public function doubleClick($onElement) {} + public function doubleClick($on_element=null, $curl_opts=array()) { + if ($on_element) { + $this->moveToElement($on_element, $curl_opts); + } + $this->actions[] = '$this->session->doubleclick(' . unwind_associated_array($curl_opts) . ');'; + return $this; + } public function dragAndDrop($source, $target) {} From 2a9a2305ea053447abefa88680001382739e63a0 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Wed, 12 Sep 2012 22:42:57 -0400 Subject: [PATCH 16/75] this test doesn't work due to bug 2700 -- i think --- test/DoubleClickTest.php | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 test/DoubleClickTest.php diff --git a/test/DoubleClickTest.php b/test/DoubleClickTest.php new file mode 100644 index 000000000..14924dd78 --- /dev/null +++ b/test/DoubleClickTest.php @@ -0,0 +1,64 @@ +session->close(); + } + + + /** + * @group doubleclick + */ + public function testDoubleClick() { + $this->session = self::$driver->session(); + $this->session->open("http://api.jquery.com/dblclick/"); + + // switch to our frame + $iframe = $this->session->element(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "iframe"); + $this->session->moveto(array("element" => $iframe->getID())); + $this->session->frame($iframe); + + // masure sure that things are in the state we want + $e = $this->session->element(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div"); + $clazz = $e->attribute('class'); + $this->assertEquals($clazz, null); + + $ac = new PHPWebDriver_WebDriverActionChains($this->session); + $ac->doubleClick($this->session->element(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div"), array(CURLOPT_VERBOSE => true)); + $ac->perform(); + + $e = $this->session->element(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div"); + $clazz = $e->attribute('class'); + var_dump($clazz); + $this->assertEquals($clazz, 'dbl'); + + $this->session->frame(); + + } + +} From 127df923f86f4cad0f74dcb7e7f72594cddd4bd1 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Wed, 12 Sep 2012 22:47:00 -0400 Subject: [PATCH 17/75] 1.2.0 --- package.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.xml b/package.xml index 3a80e54cc..273a221b4 100644 --- a/package.xml +++ b/package.xml @@ -16,10 +16,10 @@ adam@element34.ca yes - 2012-08-26 + 2012-09-13 - 1.1.0 - 1.1.0 + 1.2.0 + 1.2.0 stable From c70bb9177928e9965e30d1daac91c282c0c4906b Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Thu, 13 Sep 2012 12:09:58 -0400 Subject: [PATCH 18/75] add switch_to_frame to replace the magic frame method --- PHPWebDriver/WebDriverSession.php | 27 ++++++++++++++++++++++++++- README.md | 4 ++-- test/DoubleClickTest.php | 15 +++++++-------- test/FrameTest.php | 2 +- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/PHPWebDriver/WebDriverSession.php b/PHPWebDriver/WebDriverSession.php index 411c05d38..2e4e59473 100644 --- a/PHPWebDriver/WebDriverSession.php +++ b/PHPWebDriver/WebDriverSession.php @@ -28,10 +28,10 @@ protected function methods() { 'refresh' => 'POST', 'execute' => 'POST', 'execute_async' => 'POST', + 'frame' => 'POST', 'screenshot' => 'GET', 'window_handle' => 'GET', 'window_handles' => 'GET', - 'frame' => 'POST', 'source' => 'GET', 'title' => 'GET', 'keys' => 'POST', @@ -193,6 +193,31 @@ 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()); + } else { + throw new InvalidArgumentException('$frame needs to be a webdriver element of a frame'); + } + + $results = $this->curl('POST', + '/frame', + $frame_id, + $curl_opts); + + $value = null; + if (is_array($results) && array_key_exists('value', $results)) { + $value = $results['value']; + } + + $message = null; + if (is_array($value) && array_key_exists('message', $value)) { + $message = $value['message']; + } + + self::throwException($results['info']['http_code'], $message, $results); + } + /** * local_storage method chaining, e.g., * - $session->local_storage()->method() diff --git a/README.md b/README.md index e41f228e2..41fbd2e4e 100644 --- a/README.md +++ b/README.md @@ -293,12 +293,12 @@ What got added, what got removed and what got fixed is listed in the (Release No // find your iframe $iframe = self::$session->element(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "iframe"); // switch context to it - self::$session->frame($iframe); + self::$session->switch_to_frame($iframe); // interact $ps = self::$session->elements(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "p"); $this->assertEquals(count($ps), 6); // switch back - self::$session->frame(); + self::$session->switch_to_frame(); ## Alerts diff --git a/test/DoubleClickTest.php b/test/DoubleClickTest.php index 14924dd78..bd8bd6224 100644 --- a/test/DoubleClickTest.php +++ b/test/DoubleClickTest.php @@ -41,23 +41,22 @@ public function testDoubleClick() { // switch to our frame $iframe = $this->session->element(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "iframe"); $this->session->moveto(array("element" => $iframe->getID())); - $this->session->frame($iframe); - + $this->session->switch_to_frame($iframe); + // masure sure that things are in the state we want $e = $this->session->element(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div"); $clazz = $e->attribute('class'); - $this->assertEquals($clazz, null); - + $this->assertEquals(null, $clazz); + $ac = new PHPWebDriver_WebDriverActionChains($this->session); - $ac->doubleClick($this->session->element(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div"), array(CURLOPT_VERBOSE => true)); + $ac->doubleClick($this->session->element(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div")); $ac->perform(); $e = $this->session->element(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div"); $clazz = $e->attribute('class'); - var_dump($clazz); - $this->assertEquals($clazz, 'dbl'); + $this->assertEquals('dbl', $clazz); - $this->session->frame(); + $this->session->switch_to_frame(); } diff --git a/test/FrameTest.php b/test/FrameTest.php index 295099e4f..d3b38caf5 100644 --- a/test/FrameTest.php +++ b/test/FrameTest.php @@ -20,7 +20,7 @@ public function test_frame_stuff() { // find your iframe $iframe = self::$session->element("css selector", "iframe"); // switch context to it - self::$session->frame($iframe); + self::$session->switch_to_frame($iframe); // interact $ps = self::$session->elements("css selector", "p"); $this->assertEquals(count($ps), 6); From 4fb607bcef291a38563c9ee20c75fdfab0e6cdb8 Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Thu, 13 Sep 2012 12:11:38 -0400 Subject: [PATCH 19/75] 1.3.0 --- package.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.xml b/package.xml index 273a221b4..d064217e5 100644 --- a/package.xml +++ b/package.xml @@ -18,8 +18,8 @@ 2012-09-13 - 1.2.0 - 1.2.0 + 1.3.0 + 1.3.0 stable From 75de701cf43ecdb5851f0174e5632aa835053d7f Mon Sep 17 00:00:00 2001 From: Adam Goucher Date: Fri, 2 Nov 2012 00:11:19 -0400 Subject: [PATCH 20/75] 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 21/75] 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 22/75] 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 23/75] 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 24/75] 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 25/75] 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 26/75] 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 27/75] 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 28/75] 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 29/75] 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 30/75] 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 31/75] 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 32/75] 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