|
20 | 20 | use Facebook\WebDriver\WebDriverBy;
|
21 | 21 | use Facebook\WebDriver\WebDriverCapabilities;
|
22 | 22 | use Facebook\WebDriver\WebDriverExpectedCondition;
|
| 23 | +use Facebook\WebDriver\WebDriverHasInputDevices; |
23 | 24 | use Symfony\Component\BrowserKit\Client as BaseClient;
|
24 | 25 | use Symfony\Component\BrowserKit\Request;
|
25 | 26 | use Symfony\Component\BrowserKit\Response;
|
|
35 | 36 |
|
36 | 37 | /**
|
37 | 38 | * @author Kévin Dunglas <dunglas@gmail.com>
|
| 39 | + * @author Dany Maillard <danymaillard93b@gmail.com> |
38 | 40 | *
|
39 | 41 | * @method Crawler getCrawler()
|
40 | 42 | */
|
41 |
| -final class Client extends BaseClient implements WebDriver, JavaScriptExecutor |
| 43 | +final class Client extends BaseClient implements WebDriver, JavaScriptExecutor, WebDriverHasInputDevices |
42 | 44 | {
|
43 | 45 | use ExceptionThrower;
|
44 | 46 |
|
@@ -413,4 +415,22 @@ public function executeAsyncScript($script, array $arguments = [])
|
413 | 415 |
|
414 | 416 | return $this->webDriver->executeAsyncScript($script, $arguments);
|
415 | 417 | }
|
| 418 | + |
| 419 | + public function getKeyboard() |
| 420 | + { |
| 421 | + if (!$this->webDriver instanceof WebDriverHasInputDevices) { |
| 422 | + throw new \RuntimeException(sprintf('"%s" does not implement "%s".', \get_class($this->webDriver), WebDriverHasInputDevices::class)); |
| 423 | + } |
| 424 | + |
| 425 | + return $this->webDriver->getKeyboard(); |
| 426 | + } |
| 427 | + |
| 428 | + public function getMouse() |
| 429 | + { |
| 430 | + if (!$this->webDriver instanceof WebDriverHasInputDevices) { |
| 431 | + throw new \RuntimeException(sprintf('"%s" does not implement "%s".', \get_class($this->webDriver), WebDriverHasInputDevices::class)); |
| 432 | + } |
| 433 | + |
| 434 | + return $this->webDriver->getMouse(); |
| 435 | + } |
416 | 436 | }
|
0 commit comments