Skip to content

Commit 6d19838

Browse files
author
Polo
committed
Autoloading exception classes
1 parent bf014a6 commit 6d19838

37 files changed

+253
-250
lines changed

SeleniumClient/Commands/Command.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ class Command
2929
private $_polling;
3030
private $_response;
3131

32-
3332
public function __construct($driver, $name, $params = null, $urlParams = null)
3433
{
3534
$this->_driver = $driver;
3635
$this->_name = $name;
3736
$this->_params = $params;
3837
$this->_urlParams = $urlParams;
3938

39+
$this->setUrl();
40+
$this->setHttpMethod();
41+
4042
return $this;
4143
}
4244

@@ -72,9 +74,6 @@ public function setPolling($value)
7274

7375
public function execute($trace = false)
7476
{
75-
$this->setUrl();
76-
$this->setHttpMethod();
77-
7877
$httpClient = $this->_driver->getHttpClient();
7978

8079
$this->_response = $httpClient->execute($this, $trace);

SeleniumClient/DesiredCapabilities.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
use SeleniumClient\CapabilityType;
1919

20-
require_once __DIR__ . '/Exceptions.php';
21-
2220
class DesiredCapabilities {
2321

2422
private $_capabilities = null;
@@ -135,16 +133,16 @@ private function isValidCapabilityAndValue($capabilityType,$value)
135133
switch($capabilityType)
136134
{
137135
case CapabilityType::BROWSER_NAME:
138-
if(!BrowserType::isValidBrowserType($value)) { throw new InvalidBrowserTypeException("'{$value}' is not a valid browser type"); }
136+
if(!BrowserType::isValidBrowserType($value)) { throw new Exception("'{$value}' is not a valid browser type"); }
139137
break;
140138
case CapabilityType::PLATFORM:
141-
if(!PlatformType::isValidPlatformType($value)) { throw new InvalidPlatformTypeException("'{$value}' is not a valid platform type"); }
139+
if(!PlatformType::isValidPlatformType($value)) { throw new Exception("'{$value}' is not a valid platform type"); }
142140
break;
143141
}
144142
}
145143
else
146144
{
147-
throw new InvalidCapabilityTypeException("'{$capabilityType}' is not a valid capability type");
145+
throw new Exception("'{$capabilityType}' is not a valid capability type");
148146
}
149147

150148
return true;

SeleniumClient/Exceptions.php

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
namespace SeleniumClient\Exceptions;
3+
4+
class ElementIsNotSelectable extends \Exception {
5+
public function __construct($message = "") {
6+
parent::__construct ( " An attempt was made to select an element that cannot be selected. " . $message);
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
namespace SeleniumClient\Exceptions;
3+
4+
class ElementNotVisible extends \Exception {
5+
public function __construct($message = "") {
6+
parent::__construct ( " An element command could not be completed because the element is not visible on the page. " . $message);
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
namespace SeleniumClient\Exceptions;
3+
4+
class IMEEngineActivationFailed extends \Exception {
5+
public function __construct($message = "") {
6+
parent::__construct ( " An IME engine could not be started. " . $message);
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
namespace SeleniumClient\Exceptions;
3+
4+
class IMENotAvailable extends \Exception {
5+
public function __construct($message = "") {
6+
parent::__construct ( " IME was not available. " . $message);
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
namespace SeleniumClient\Exceptions;
3+
4+
class InvalidCookieDomain extends \Exception {
5+
public function __construct($message = "") {
6+
parent::__construct ( " An illegal attempt was made to set a cookie under a different domain than the current page. " . $message);
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
namespace SeleniumClient\Exceptions;
3+
4+
class InvalidElementCoordinates extends \Exception {
5+
public function __construct($message = "") {
6+
parent::__construct ( " The coordinates provided to an interactions operation are invalid. " . $message);
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
namespace SeleniumClient\Exceptions;
3+
4+
class InvalidElementState extends \Exception {
5+
public function __construct($message = "") {
6+
parent::__construct ( " An element command could not be completed because the element is in an invalid state (e.g. attempting to click a disabled element). " . $message);
7+
}
8+
}

0 commit comments

Comments
 (0)