Skip to content

Commit

Permalink
Added way of accesing the Chrome DevToolsDriver
Browse files Browse the repository at this point in the history
  • Loading branch information
mnocon committed Oct 17, 2023
1 parent 1d6e637 commit e9a85ca
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/lib/Browser/Component/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
namespace Ibexa\Behat\Browser\Component;

use Behat\Mink\Session;
use Facebook\WebDriver\Chrome\ChromeDevToolsDriver;
use Ibexa\Behat\Browser\Element\Factory\Debug\Highlighting\ElementFactory as HighlightingDebugElementFactory;
use Ibexa\Behat\Browser\Element\Factory\Debug\Interactive\ElementFactory as InteractiveDebugElementFactory;
use Ibexa\Behat\Browser\Element\Factory\ElementFactory;
use Ibexa\Behat\Browser\Element\Factory\ElementFactoryInterface;
use Ibexa\Behat\Browser\Element\RootElementInterface;
use Ibexa\Behat\Browser\Locator\LocatorCollection;
use Ibexa\Behat\Browser\Locator\LocatorInterface;
use Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException;
use OAndreyev\Mink\Driver\WebDriver;
use RuntimeException;

abstract class Component implements ComponentInterface
{
Expand Down Expand Up @@ -52,6 +56,23 @@ protected function getSession(): Session
return $this->session;
}

protected function getDevToolsDriver(): ChromeDevToolsDriver
{
$driver = $this->session->getDriver();

if (!($driver instanceof WebDriver)) {
throw new NotImplementedException('Chrome DevTools driver is not available for this driver');
}

$webDriver = $driver->getWebDriver();

if (null === $webDriver) {
throw new RuntimeException('Error happened when accessing the WebDriver');
}

return new ChromeDevToolsDriver($webDriver);
}

/**
* @return \Ibexa\Behat\Browser\Locator\LocatorInterface[]
*/
Expand Down

0 comments on commit e9a85ca

Please sign in to comment.