Skip to content

Commit

Permalink
Less duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpott committed Jul 3, 2024
1 parent edb6aeb commit 2d243b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 45 deletions.
45 changes: 2 additions & 43 deletions test/Test/WebDriver/ChromeDriverNonW3CTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,55 +22,14 @@

namespace Test\WebDriver;

use Test\WebDriver\WebDriverTestBase;
use WebDriver\Browser;
use WebDriver\Session;

/**
* ChromeDriver
*
* @package WebDriver
*
* @group Functional
*/
class ChromeDriverNonW3CTest extends WebDriverTestBase
class ChromeDriverNonW3CTest extends ChromeDriverTest
{
protected $testWebDriverRootUrl = 'http://localhost:9515';
protected $testWebDriverName = 'chromedriver';

protected function setUp(): void
{
parent::setUp();
try {
$this->status = $this->driver->status();
$this->session = $this->driver->session(Browser::CHROME, [
'goog:chromeOptions' => [
'w3c' => false,
'args' => [
'--no-sandbox',
'--ignore-certificate-errors',
'--allow-insecure-localhost',
'--headless',
],
],
]);
}
catch (\Exception $e) {
if ($this->isWebDriverDown($e)) {
$this->fail("{$this->testWebDriverName} server not running: {$e->getMessage()}");
}
throw $e;
}
}

/**
* Test driver status
*/
public function testStatus()
{
$this->assertEquals(1, $this->status['ready'], 'Chromedriver is not ready');
$this->assertEquals('ChromeDriver ready for new sessions.', $this->status['message'], 'Chromedriver is not ready');
$this->assertNotEmpty($this->status['os'], 'OS info not detected');
$this->assertFalse($this->driver->isW3c());
}
protected $w3c = false;
}
5 changes: 3 additions & 2 deletions test/Test/WebDriver/ChromeDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ChromeDriverTest extends WebDriverTestBase
{
protected $testWebDriverRootUrl = 'http://localhost:9515';
protected $testWebDriverName = 'chromedriver';
protected $w3c = true;

protected function setUp(): void
{
Expand All @@ -45,7 +46,7 @@ protected function setUp(): void
$this->status = $this->driver->status();
$this->session = $this->driver->session(Browser::CHROME, [
'goog:chromeOptions' => [
'w3c' => true,
'w3c' => $this->w3c,
'args' => [
'--no-sandbox',
'--ignore-certificate-errors',
Expand All @@ -71,6 +72,6 @@ public function testStatus()
$this->assertEquals(1, $this->status['ready'], 'Chromedriver is not ready');
$this->assertEquals('ChromeDriver ready for new sessions.', $this->status['message'], 'Chromedriver is not ready');
$this->assertNotEmpty($this->status['os'], 'OS info not detected');
$this->assertTrue($this->driver->isW3c());
$this->assertSame($this->w3c, $this->driver->isW3c());
}
}

0 comments on commit 2d243b8

Please sign in to comment.