Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 6 additions & 3 deletions WebDriver.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

require_once 'WebDriver/Exception.php';

class WebDriver {
public static $ImplicitWaitMS = 0;

Expand Down Expand Up @@ -68,7 +70,7 @@ public static function __callStatic($name, $arguments) {
if (isset(self::$keys[$name])) {
return json_decode('"' . self::$keys[$name] . '"');
} else {
throw new Exception("Can't type key $name");
throw new WebDriver_Exception("Can't type key $name");
}
}

Expand Down Expand Up @@ -131,7 +133,7 @@ public static function ParseLocator($locator) {
$strategy = "xpath";
$value = $locator;
} else if (substr($locator, 0, 9) === "document." || substr($locator, 0, 4) === "dom=") {
throw new Exception("DOM selectors aren't supported in WebDriver: $locator");
throw new WebDriver_Exception("DOM selectors aren't supported in WebDriver: $locator");
} else { // Fall back to id
$strategy = "id";
$value = $locator;
Expand All @@ -148,7 +150,7 @@ public static function QuoteXPath($value) {
} else if (!$contains_double_quote) {
return '"' . $value . '"';
} else {
$parts = split("'", $value);
$parts = preg_split("/'/", $value);
return "concat('" . implode("', \"'\", '", $parts) . "')";
}
}
Expand All @@ -175,6 +177,7 @@ public static function CanonicalizeCSSColor($color) {
'teal' => '008080',
'aqua' => '00FFFF',
);
$six_hex = null;
if (preg_match('/^rgb\(([0-9]+),\s*([0-9]+),\s*([0-9]+)\)$/', $color, $rgb)) {
// rgb(255, 255, 255) -> ffffff
if (0 <= $rgb[1] && $rgb[1] <= 255 && 0 <= $rgb[2] && $rgb[2] <= 255 && 0 <= $rgb[3] && $rgb[3] <= 255) {
Expand Down
5 changes: 5 additions & 0 deletions WebDriver/Exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

class WebDriver_Exception extends Exception
{
}
2 changes: 1 addition & 1 deletion WebDriverColorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function invalid_colors() {

/**
* @dataProvider invalid_colors
* @expectedException Exception
* @expectedException PHPUnit_Framework_ExpectationFailedException
*/
public function test_invalid_colors($input) {
WebDriver::CanonicalizeCSSColor($input);
Expand Down
2 changes: 1 addition & 1 deletion WebDriverSelectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function invalid_selectors() {

/**
* @dataProvider invalid_selectors
* @expectedException Exception
* @expectedException WebDriver_Exception
*/
public function test_invalid_selectors($input) {
WebDriver::ParseLocator($input);
Expand Down
2 changes: 1 addition & 1 deletion WebDriverXPathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function data() {
consecutive""""quotes
consecutive'"'"'mixedquotes
EOT;
$test_data = split("\n", $strings);
$test_data = preg_split("/\n/", $strings);
foreach ($test_data as &$data) {
$data = array($data);
}
Expand Down