Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

beforeunload event doesn't trigger with chromedriver v127+ #1104

Open
Labels
bugSomething isn't working
@GuySartorelli

Description

@GuySartorelli

Bug description

Found this in our CIhttps://github.com/silverstripe/silverstripe-admin/actions/runs/10138301536/job/28029791648, there's more details insilverstripe/.github#287

There's javascript that blocks page navigation using theonbeforeunload event handler.

This alert works as expected with chromedriver 126 (specifically tested with126.0.6478.182 (5b5d8292ddf182f8b2096fa665b473b6317906d5-refs/branch-heads/6478@{#1776})), and it works as expected when a user manually performs the actions in a browser. But when using chromedriver 127 (specifically tested with127.0.6533.72 (9755e24ca85aa18ffa16c743f660a3d914902775-refs/branch-heads/6533@{#1760})) there is no alert, and the following error occurs:

Fatal error: Uncaught Facebook\WebDriver\Exception\TimeoutException: Alert is expected in /var/www/vendor/php-webdriver/webdriver/lib/WebDriverWait.php:71

How could the issue be reproduced

<?phpuseFacebook\WebDriver\Chrome\ChromeOptions;useFacebook\WebDriver\Remote\DesiredCapabilities;useFacebook\WebDriver\Remote\RemoteWebDriver;useFacebook\WebDriver\WebDriverBy;useFacebook\WebDriver\WebDriverExpectedCondition;require_once__DIR__ .'/vendor/autoload.php';$desiredCapabilities = DesiredCapabilities::chrome();// Disable accepting SSL certificates$desiredCapabilities->setCapability('acceptSslCerts',false);// Add arguments via ChromeOptions to start headless chrome$options =newChromeOptions();$options->addArguments(['--headless','--no-sandbox','--disable-gpu']);$desiredCapabilities->setCapability(ChromeOptions::CAPABILITY,$options);$driver = RemoteWebDriver::create('http://127.0.0.1:9515',$desiredCapabilities);// Go to the page// Replace "<local-dev-domain>" with whatever the domain is for your local dev environment$driver->get('http://<local-dev-domain>/test.html');// Interact with the page (or else the alert won't appear)$driver->findElement(WebDriverBy::tagName('input'))->sendKeys('test');// Navigate away to trigger the alert$driver->navigate()->to('http://<local-dev-domain>/');// Dismiss the alert$driver->wait()->until(    WebDriverExpectedCondition::alertIsPresent(),"Alert is expected");$alert =$driver->switchTo()->alert();$alert->dismiss();$driver->quit();

Thetest.html file:

<html><head><script>window.onbeforeunload=()=>{return'WARNING: Your changes have not been saved.';};</script></head><body><inputtype="text"></body></html>

Expected behavior

Navigating away from the page should trigger thebeforeunload event and result in an alert, the same as it does when a human user navigates using a browser.

Php-webdriver version

1.15.1

PHP version

8.1.29

How do you start the browser driver or Selenium server

nohup sh -c "chromedriver" > /dev/null 2>&1 &

Selenium server / Selenium Docker image version

No response

Browser driver (chromedriver/geckodriver...) version

chromedriver 127.0.6533.72 (9755e24ca85aa18ffa16c743f660a3d914902775-refs/branch-heads/6533@{#1760})

Browser name and version

Google Chrome for Testing 127.0.6533.72

Operating system

Ubuntu

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp