What happened?
After upgrading to Chrome(driver) 121.0.6167.85 (from 120.x) we started seeing flakes in our CI. Our environment is:
- Ruby 3.3
- Latest version of
capybara (3.40.0)
- Latest version of
selenium-webdriver (4.17.0)
The flake happens because our main window is somehow resized to something small (800x600), even though we've set it to something much larger (1280x2000):
driven_by(
:selenium,
using: %w(n 0 no false).include?(ENV['HEADLESS']) ? :chrome : :headless_chrome,
screen_size: [1280, 2000],
options: driver_options
) do |capabilities|
Subsequent tests fail because the window is too small.
How can we reproduce the issue?
After much debugging, we've found some things:
The test that causes the window to be resized actually doesn't do anything with windows or popups. The test ends on a page that hooks onto beforeunload where it displays an alert ("Are you sure you want to leave?" alert). Digging into Capybara's source code, it already handles this scenario: https://github.com/teamcapybara/capybara/blob/master/lib/capybara/selenium/driver_specializations/chrome_driver.rb#L49-L52
In the chromedriver logs, I can see the unexpected alert did happen. Selenium did report it to Capybara, and Capybara does accept it. However, if you look in the logs, it looks like it passes "accept": false, to the Page.handleJavaScriptDialog action. This results in the alert being dismissed (cancel navigating away from page) the first time. Then somehow, something just resizes the frame. I have no idea what. But at this point, we're out side of any testing code and in the realm of Capybara, Selenium, Chromedriver, or even Chrome itself.
Reverting to Chrome/Chromdriver 120 fixes the issue. I'm not sure if this is a Selenium issue (incompatible with chrome 121) or a regression in Chrome 121. Seeking for some help/guidance. Thank you!
Relevant log output
[1707234203.570][DEBUG]: DevTools WebSocket Command: Page.navigate (id=8587) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E {
"url": "about:blank"
}
[1707234203.571][DEBUG]: DevTools WebSocket Event: Page.frameStartedLoading (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E {
"frameId": "5EB60A81365BD9FBCEAC879FB80F415E"
}
[1707234203.572][DEBUG]: DevTools WebSocket Event: Page.javascriptDialogOpening (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E {
"defaultPrompt": "",
"hasBrowserHandler": true,
"message": "",
"type": "beforeunload",
"url": "http://redacted.com:9400/foo/09916a84-fe28-42af-ba30-2d3c83f05eee/review"
}
[1707234203.572][DEBUG]: DevTools WebSocket Command: Inspector.enable (id=8588) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E {
"purpose": "detect if alert blocked any cmds"
}
[1707234203.579][DEBUG]: DevTools WebSocket Response: Inspector.enable (id=8588) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E {
}
[1707234203.580][INFO]: Waiting for pending navigations...
[1707234203.582][INFO]: Done waiting for pending navigations. Status: unexpected alert open: {Alert text : }
[1707234203.582][INFO]: [4f0f4e18e96ab4db629bae280cab090a] RESPONSE Navigate
[1707234203.583][INFO]: [4f0f4e18e96ab4db629bae280cab090a] COMMAND FindElements {
"using": "xpath",
"value": "/html/body/*"
}
[1707234203.583][DEBUG]: DevTools WebSocket Command: Page.handleJavaScriptDialog (id=8589) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E {
"accept": false,
"promptText": ""
}
[1707234203.584][DEBUG]: DevTools WebSocket Response: Page.navigate (id=8587) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E {
"errorText": "net::ERR_ABORTED",
"frameId": "5EB60A81365BD9FBCEAC879FB80F415E"
}
[1707234203.585][DEBUG]: DevTools WebSocket Event: Page.frameStoppedLoading (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E {
"frameId": "5EB60A81365BD9FBCEAC879FB80F415E"
}
[1707234203.586][DEBUG]: DevTools WebSocket Event: Page.javascriptDialogClosed (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E {
"result": false,
"userInput": ""
}
[1707234203.587][DEBUG]: DevTools WebSocket Response: Page.handleJavaScriptDialog (id=8589) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E {
}
[1707234203.589][INFO]: [4f0f4e18e96ab4db629bae280cab090a] RESPONSE FindElements ERROR unexpected alert open: {Alert text : }
(Session info: chrome=121.0.6167.85)
[1707234203.592][INFO]: [4f0f4e18e96ab4db629bae280cab090a] COMMAND GetAlertMessage {
}
[1707234203.592][INFO]: Waiting for pending navigations...
[1707234203.592][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=8590) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E {
"expression": "1"
}
[1707234203.606][DEBUG]: DevTools WebSocket Event: Page.frameResized (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E {
}
[1707234203.606][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=8590) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E {
"result": {
"description": "1",
"type": "number",
"value": 1
}
}
[1707234203.606][INFO]: Done waiting for pending navigations. Status: ok
[1707234203.608][INFO]: [4f0f4e18e96ab4db629bae280cab090a] RESPONSE GetAlertMessage ERROR no such alert
(Session info: chrome=121.0.6167.85)
[1707234203.611][INFO]: [4f0f4e18e96ab4db629bae280cab090a] COMMAND GetUrl {
}
[1707234203.611][INFO]: Waiting for pending navigations...
[1707234203.611][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=8591) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E {
"expression": "1"
}
[1707234203.625][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=8591) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E {
"result": {
"description": "1",
"type": "number",
"value": 1
}
}
[1707234203.625][INFO]: Done waiting for pending navigations. Status: ok
Operating System
Ubuntu
Selenium version
Ruby 3.3
What are the browser(s) and version(s) where you see this issue?
Chrome 121.0.6167.85
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 121.0.6167.85
Are you using Selenium Grid?
No response
What happened?
After upgrading to Chrome(driver)
121.0.6167.85(from 120.x) we started seeing flakes in our CI. Our environment is:capybara(3.40.0)selenium-webdriver(4.17.0)The flake happens because our main window is somehow resized to something small (800x600), even though we've set it to something much larger (1280x2000):
Subsequent tests fail because the window is too small.
How can we reproduce the issue?
After much debugging, we've found some things:
The test that causes the window to be resized actually doesn't do anything with windows or popups. The test ends on a page that hooks onto
beforeunloadwhere it displays an alert ("Are you sure you want to leave?" alert). Digging into Capybara's source code, it already handles this scenario: https://github.com/teamcapybara/capybara/blob/master/lib/capybara/selenium/driver_specializations/chrome_driver.rb#L49-L52In the chromedriver logs, I can see the unexpected alert did happen. Selenium did report it to Capybara, and Capybara does accept it. However, if you look in the logs, it looks like it passes
"accept": false,to thePage.handleJavaScriptDialogaction. This results in the alert being dismissed (cancel navigating away from page) the first time. Then somehow, something just resizes the frame. I have no idea what. But at this point, we're out side of any testing code and in the realm of Capybara, Selenium, Chromedriver, or even Chrome itself.Reverting to Chrome/Chromdriver 120 fixes the issue. I'm not sure if this is a Selenium issue (incompatible with chrome 121) or a regression in Chrome 121. Seeking for some help/guidance. Thank you!
Relevant log output
[1707234203.570][DEBUG]: DevTools WebSocket Command: Page.navigate (id=8587) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E { "url": "about:blank" } [1707234203.571][DEBUG]: DevTools WebSocket Event: Page.frameStartedLoading (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E { "frameId": "5EB60A81365BD9FBCEAC879FB80F415E" } [1707234203.572][DEBUG]: DevTools WebSocket Event: Page.javascriptDialogOpening (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E { "defaultPrompt": "", "hasBrowserHandler": true, "message": "", "type": "beforeunload", "url": "http://redacted.com:9400/foo/09916a84-fe28-42af-ba30-2d3c83f05eee/review" } [1707234203.572][DEBUG]: DevTools WebSocket Command: Inspector.enable (id=8588) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E { "purpose": "detect if alert blocked any cmds" } [1707234203.579][DEBUG]: DevTools WebSocket Response: Inspector.enable (id=8588) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E { } [1707234203.580][INFO]: Waiting for pending navigations... [1707234203.582][INFO]: Done waiting for pending navigations. Status: unexpected alert open: {Alert text : } [1707234203.582][INFO]: [4f0f4e18e96ab4db629bae280cab090a] RESPONSE Navigate [1707234203.583][INFO]: [4f0f4e18e96ab4db629bae280cab090a] COMMAND FindElements { "using": "xpath", "value": "/html/body/*" } [1707234203.583][DEBUG]: DevTools WebSocket Command: Page.handleJavaScriptDialog (id=8589) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E { "accept": false, "promptText": "" } [1707234203.584][DEBUG]: DevTools WebSocket Response: Page.navigate (id=8587) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E { "errorText": "net::ERR_ABORTED", "frameId": "5EB60A81365BD9FBCEAC879FB80F415E" } [1707234203.585][DEBUG]: DevTools WebSocket Event: Page.frameStoppedLoading (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E { "frameId": "5EB60A81365BD9FBCEAC879FB80F415E" } [1707234203.586][DEBUG]: DevTools WebSocket Event: Page.javascriptDialogClosed (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E { "result": false, "userInput": "" } [1707234203.587][DEBUG]: DevTools WebSocket Response: Page.handleJavaScriptDialog (id=8589) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E { } [1707234203.589][INFO]: [4f0f4e18e96ab4db629bae280cab090a] RESPONSE FindElements ERROR unexpected alert open: {Alert text : } (Session info: chrome=121.0.6167.85) [1707234203.592][INFO]: [4f0f4e18e96ab4db629bae280cab090a] COMMAND GetAlertMessage { } [1707234203.592][INFO]: Waiting for pending navigations... [1707234203.592][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=8590) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E { "expression": "1" } [1707234203.606][DEBUG]: DevTools WebSocket Event: Page.frameResized (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E { } [1707234203.606][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=8590) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E { "result": { "description": "1", "type": "number", "value": 1 } } [1707234203.606][INFO]: Done waiting for pending navigations. Status: ok [1707234203.608][INFO]: [4f0f4e18e96ab4db629bae280cab090a] RESPONSE GetAlertMessage ERROR no such alert (Session info: chrome=121.0.6167.85) [1707234203.611][INFO]: [4f0f4e18e96ab4db629bae280cab090a] COMMAND GetUrl { } [1707234203.611][INFO]: Waiting for pending navigations... [1707234203.611][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=8591) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E { "expression": "1" } [1707234203.625][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=8591) (session_id=86BE73592C4E79BD3EFB4127C5C4E868) 5EB60A81365BD9FBCEAC879FB80F415E { "result": { "description": "1", "type": "number", "value": 1 } } [1707234203.625][INFO]: Done waiting for pending navigations. Status: okOperating System
Ubuntu
Selenium version
Ruby 3.3
What are the browser(s) and version(s) where you see this issue?
Chrome 121.0.6167.85
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 121.0.6167.85
Are you using Selenium Grid?
No response