diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f863f93b..ec66cc6c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -51,7 +51,14 @@ jobs: matrix: php: [ '8.1', '8.2', '8.3' ] # 4.1.2-20220227 - last known working version of 4 where the modifications to this package weren't needed - selenium: ['4.1.2', 'latest'] + selenium: + - image: 'selenium/standalone-firefox:4.1.2' + browser: firefox + - image: 'selenium/standalone-firefox:latest' + browser: firefox + - image: 'selenium/standalone-chrome:latest' + browser: chrome + fail-fast: false steps: @@ -80,7 +87,7 @@ jobs: - name: Start Selenium run: | - docker run --net host --name selenium --volume /dev/shm:/dev/shm --volume $GITHUB_WORKSPACE:$GITHUB_WORKSPACE -e SE_NODE_OVERRIDE_MAX_SESSIONS=true -e SE_NODE_MAX_SESSIONS=5 --shm-size 2g selenium/standalone-firefox:${{ matrix.selenium }} &> ./logs/selenium.log & + docker run --net host --name selenium --volume /dev/shm:/dev/shm --volume $GITHUB_WORKSPACE:$GITHUB_WORKSPACE -e SE_NODE_OVERRIDE_MAX_SESSIONS=true -e SE_NODE_MAX_SESSIONS=5 --shm-size 2g ${{ matrix.selenium.image }} &> ./logs/selenium.log & - name: Wait for browser & PHP to start run: | @@ -88,6 +95,8 @@ jobs: while ! nc -z localhost 8002 doMouseOver($this->findElement($xpath)); } + private function scrollElementIntoView(Element $element): void { + $script = <<executeJsOnElement($element, $script); + } + private function doMouseOver(Element $element): void { if ($this->isW3C()) { + // Firefox needs the element in view in order to move the pointer to + // it. + $this->scrollElementIntoView($element); $actions = array( 'actions' => [ [ diff --git a/tests/Custom/DesiredCapabilitiesTest.php b/tests/Custom/DesiredCapabilitiesTest.php index b0dfe725..b7c910c5 100644 --- a/tests/Custom/DesiredCapabilitiesTest.php +++ b/tests/Custom/DesiredCapabilitiesTest.php @@ -7,6 +7,14 @@ class DesiredCapabilitiesTest extends TestCase { + protected function setUp(): void + { + $browser = getenv('WEB_FIXTURES_BROWSER') ?: 'firefox'; + if ($browser !== 'firefox') { + $this->markTestSkipped('This test only works with Firefox'); + } + } + public function testGetDesiredCapabilities() { $caps = array( diff --git a/tests/Custom/LargePageClickTest.php b/tests/Custom/LargePageClickTest.php new file mode 100644 index 00000000..d27aa301 --- /dev/null +++ b/tests/Custom/LargePageClickTest.php @@ -0,0 +1,26 @@ +getSession()->visit($this->pathTo('/multi_input_form.html')); + + // Add a large amount of br tags so that the button is not in view. + $large_page = str_repeat('
', 2000); + $script = <<getSession()->executeScript($script); + + $page = $this->getSession()->getPage(); + $page->pressButton('Register'); + $this->assertStringContainsString('no file', $page->getContent()); + } +}