Skip to content

Commit

Permalink
Apply recommended changes and test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
justafish committed Oct 3, 2023
1 parent 66c7fe7 commit e1a0c86
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 </dev/null; do echo Waiting for remote driver to start...; sleep 1; done
while ! nc -z localhost 8002 </dev/null; do echo Waiting for PHP server to start...; sleep 1; done
- name: Replace instaclick/php-webdriver for new selenium versions
- name: Replace instaclick/php-webdriver with lullabot/php-webdriver for new selenium versions
run: |
if [ "${{ matrix.selenium }}" == "latest" ]; then
# @todo replace this with a release
composer require lullabot/php-webdriver:dev-main
fi
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<!--<server name="WEB_FIXTURES_BROWSER" value="firefox"/>-->

<!-- where driver will connect to -->
<server name="DRIVER_URL" value="http://localhost:4444/wd/hub" />
<!-- <server name="DRIVER_URL" value="http://localhost:4444/wd/hub" /> -->

<!-- where DocumentRoot of 'Test Machine' is mounted to on 'Driver Machine' (only if these are 2 different machines) -->
<!--server name="DRIVER_MACHINE_BASE_PATH" value="" /-->
Expand Down
18 changes: 7 additions & 11 deletions src/Selenium2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -522,12 +518,12 @@ public function getScreenshot()

public function getWindowNames()
{
return $this->getWebDriverSession()->window_handles();
return $this->getWebDriverSession()->getWindowHandles();

Check failure on line 521 in src/Selenium2Driver.php

View workflow job for this annotation

GitHub Actions / Static analysis

Call to an undefined method WebDriver\Session::getWindowHandles().
}

public function getWindowName()
{
return $this->getWebDriverSession()->window_handle();
return $this->getWebDriverSession()->getWindowHandle();

Check failure on line 526 in src/Selenium2Driver.php

View workflow job for this annotation

GitHub Actions / Static analysis

Call to an undefined method WebDriver\Session::getWindowHandle().
}

/**
Expand Down Expand Up @@ -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)
);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Custom/TimeoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/Selenium2Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Check failure on line 23 in tests/Selenium2Config.php

View workflow job for this annotation

GitHub Actions / Static analysis

Parameter #3 $wdHost of class Behat\Mink\Driver\Selenium2Driver constructor expects string, string|false given.
}
Expand Down

0 comments on commit e1a0c86

Please sign in to comment.