diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d03347e8..64dac374 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -73,16 +73,17 @@ jobs: - name: Start Selenium run: | - docker run --net host --name selenium --volume /dev/shm:/dev/shm --shm-size 2g selenium/standalone-firefox:"${{ matrix.selenium }}" &> ./logs/selenium.log & + docker run --net host --name selenium --volume /dev/shm:/dev/shm --shm-size 2g selenium/standalone-firefox:${{ matrix.selenium }} &> ./logs/selenium.log & - name: Wait for browser & PHP to start run: | while ! nc -z localhost 4444 --> - + diff --git a/src/Selenium2Driver.php b/src/Selenium2Driver.php index 54e87d5f..00fa988a 100755 --- a/src/Selenium2Driver.php +++ b/src/Selenium2Driver.php @@ -218,17 +218,13 @@ public static function getDefaultCapabilities() * Checks if the WebDriver session is W3C compatible. * * @return bool - * - * @throws UnknownCommand + * @throws DriverException */ public function isW3C() { - try { - // This method doesn't exist in older versions of php-webdriver. - /** @phpstan-ignore-next-line variable.undefined */ - return $this->wdSession->isW3C(); - } catch (UnknownCommand $e) { - return false; + if (method_exists($this->getWebDriverSession(), 'isW3C')) { + return $this->getWebDriverSession()->isW3C(); } + return false; } /** @@ -522,12 +518,12 @@ public function getScreenshot() public function getWindowNames() { - return $this->getWebDriverSession()->window_handles(); + return $this->getWebDriverSession()->getWindowHandles(); } public function getWindowName() { - return $this->getWebDriverSession()->window_handle(); + return $this->getWebDriverSession()->getWindowHandle(); } /** @@ -974,7 +970,7 @@ public function resizeWindow(int $width, int $height, ?string $name = null) if ($this->isW3C()) { // This method doesn't exist in older versions of php-webdriver. /** @phpstan-ignore-next-line variable.undefined */ - $this->wdSession->window($name ? $name : 'current')->postRect( + $this->getWebDriverSession()->window($name ? $name : 'current')->postRect( array('width' => $width, 'height' => $height) ); } diff --git a/tests/Custom/TimeoutTest.php b/tests/Custom/TimeoutTest.php index e17e5f0d..3f036943 100644 --- a/tests/Custom/TimeoutTest.php +++ b/tests/Custom/TimeoutTest.php @@ -37,7 +37,7 @@ public function testInvalidTimeoutSettingThrowsException() \assert($driver instanceof Selenium2Driver); $this->expectException('\Behat\Mink\Exception\DriverException'); - $driver->setTimeouts(array('invalid' => 0)); + $driver->setTimeouts(array('invalid' => -1)); } public function testShortTimeoutDoesNotWaitForElementToAppear() diff --git a/tests/Selenium2Config.php b/tests/Selenium2Config.php index faa6cf96..e0290a2e 100644 --- a/tests/Selenium2Config.php +++ b/tests/Selenium2Config.php @@ -18,7 +18,7 @@ public static function getInstance(): self public function createDriver(): DriverInterface { $browser = getenv('WEB_FIXTURES_BROWSER') ?: 'firefox'; - $seleniumHost = $_SERVER['DRIVER_URL']; + $seleniumHost = getenv('DRIVER_URL'); return new Selenium2Driver($browser, null, $seleniumHost); }