Skip to content

Commit 2d243b8

Browse files
committed
Less duplicate code
1 parent edb6aeb commit 2d243b8

File tree

2 files changed

+5
-45
lines changed

2 files changed

+5
-45
lines changed

test/Test/WebDriver/ChromeDriverNonW3CTest.php

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -22,55 +22,14 @@
2222

2323
namespace Test\WebDriver;
2424

25-
use Test\WebDriver\WebDriverTestBase;
26-
use WebDriver\Browser;
27-
use WebDriver\Session;
28-
2925
/**
3026
* ChromeDriver
3127
*
3228
* @package WebDriver
3329
*
3430
* @group Functional
3531
*/
36-
class ChromeDriverNonW3CTest extends WebDriverTestBase
32+
class ChromeDriverNonW3CTest extends ChromeDriverTest
3733
{
38-
protected $testWebDriverRootUrl = 'http://localhost:9515';
39-
protected $testWebDriverName = 'chromedriver';
40-
41-
protected function setUp(): void
42-
{
43-
parent::setUp();
44-
try {
45-
$this->status = $this->driver->status();
46-
$this->session = $this->driver->session(Browser::CHROME, [
47-
'goog:chromeOptions' => [
48-
'w3c' => false,
49-
'args' => [
50-
'--no-sandbox',
51-
'--ignore-certificate-errors',
52-
'--allow-insecure-localhost',
53-
'--headless',
54-
],
55-
],
56-
]);
57-
}
58-
catch (\Exception $e) {
59-
if ($this->isWebDriverDown($e)) {
60-
$this->fail("{$this->testWebDriverName} server not running: {$e->getMessage()}");
61-
}
62-
throw $e;
63-
}
64-
}
65-
66-
/**
67-
* Test driver status
68-
*/
69-
public function testStatus()
70-
{
71-
$this->assertEquals(1, $this->status['ready'], 'Chromedriver is not ready');
72-
$this->assertEquals('ChromeDriver ready for new sessions.', $this->status['message'], 'Chromedriver is not ready');
73-
$this->assertNotEmpty($this->status['os'], 'OS info not detected');
74-
$this->assertFalse($this->driver->isW3c());
75-
}
34+
protected $w3c = false;
7635
}

test/Test/WebDriver/ChromeDriverTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class ChromeDriverTest extends WebDriverTestBase
3737
{
3838
protected $testWebDriverRootUrl = 'http://localhost:9515';
3939
protected $testWebDriverName = 'chromedriver';
40+
protected $w3c = true;
4041

4142
protected function setUp(): void
4243
{
@@ -45,7 +46,7 @@ protected function setUp(): void
4546
$this->status = $this->driver->status();
4647
$this->session = $this->driver->session(Browser::CHROME, [
4748
'goog:chromeOptions' => [
48-
'w3c' => true,
49+
'w3c' => $this->w3c,
4950
'args' => [
5051
'--no-sandbox',
5152
'--ignore-certificate-errors',
@@ -71,6 +72,6 @@ public function testStatus()
7172
$this->assertEquals(1, $this->status['ready'], 'Chromedriver is not ready');
7273
$this->assertEquals('ChromeDriver ready for new sessions.', $this->status['message'], 'Chromedriver is not ready');
7374
$this->assertNotEmpty($this->status['os'], 'OS info not detected');
74-
$this->assertTrue($this->driver->isW3c());
75+
$this->assertSame($this->w3c, $this->driver->isW3c());
7576
}
7677
}

0 commit comments

Comments
 (0)