Skip to content

Commit 4291cc1

Browse files
authored
Merge pull request symfony#117 from maidmaid/input-devices
Add support of keyboard and mouse to client
2 parents 72d6e72 + 8402829 commit 4291cc1

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/Client.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Facebook\WebDriver\WebDriverBy;
2121
use Facebook\WebDriver\WebDriverCapabilities;
2222
use Facebook\WebDriver\WebDriverExpectedCondition;
23+
use Facebook\WebDriver\WebDriverHasInputDevices;
2324
use Symfony\Component\BrowserKit\Client as BaseClient;
2425
use Symfony\Component\BrowserKit\Request;
2526
use Symfony\Component\BrowserKit\Response;
@@ -35,10 +36,11 @@
3536

3637
/**
3738
* @author Kévin Dunglas <dunglas@gmail.com>
39+
* @author Dany Maillard <danymaillard93b@gmail.com>
3840
*
3941
* @method Crawler getCrawler()
4042
*/
41-
final class Client extends BaseClient implements WebDriver, JavaScriptExecutor
43+
final class Client extends BaseClient implements WebDriver, JavaScriptExecutor, WebDriverHasInputDevices
4244
{
4345
use ExceptionThrower;
4446

@@ -413,4 +415,22 @@ public function executeAsyncScript($script, array $arguments = [])
413415

414416
return $this->webDriver->executeAsyncScript($script, $arguments);
415417
}
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+
}
416436
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy