Skip to content

Commit

Permalink
Added test for unsupported "WebDriver::status" handling
Browse files Browse the repository at this point in the history
  • Loading branch information
aik099 committed Jan 18, 2025
1 parent 4c5da8e commit 3145d7e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/Custom/WebDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace Behat\Mink\Tests\Driver\Custom;

use Behat\Mink\Driver\Selenium2Driver;
use Behat\Mink\Exception\DriverException;
use Behat\Mink\Tests\Driver\TestCase;
use WebDriver\WebDriver;

class WebDriverTest extends TestCase
{
Expand All @@ -18,4 +20,21 @@ public function testGetWebDriverSessionId()
$driver = new Selenium2Driver();
$this->assertNull($driver->getWebDriverSessionId(), 'Not started session don\'t have an ID');
}

public function testUnsupportedStatusResponseHandling(): void
{
$mockWebDriver = $this->createMock(WebDriver::class);
$mockWebDriver->expects($this->once())
->method('__call')
->with($this->equalTo('status'))
->willThrowException(new \RuntimeException('some internal error'));

$driver = new Selenium2Driver();
$driver->setWebDriver($mockWebDriver);

$this->expectException(DriverException::class);
$this->expectExceptionMessage('Selenium Server version could not be detected: some internal error');

$driver->start();
}
}

0 comments on commit 3145d7e

Please sign in to comment.