Description
Describe the bug
RFB not able to handle two consecutives alerts. It fails with below message:
TimeoutError: page.waitForEvent: Timeout 5000ms exceeded while waiting for event “dialog”
=========================== logs ===========================
waiting for event “dialog”
Tip: Use “Set Browser Timeout” for increasing the timeout.
To Reproduce
I prep 2 simple files to easily reproduce an issue. Create new folder and copy 2 files content ex. to c:/alert_demo, then run start CMDs
cd c:/alert_demo
robot -d example/1 -t Alert-Debug example.robot
- 1 file (index.html) - example page with 2 consecutive alerts (one alert after another)
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Multiple alerts issue - example</title>
</head>
<body>
<button onclick="showAlerts()">Click to show alerts</button>
<script>
function showAlerts() {
confirm("First alert accepted?");
alert("Second alert!");
}
</script>
</body>
</html>
- 2 file (example.robot) - steps followed to reproduce an issue.
Please notice on line 8 it needs to be correct index.html path to open sample page with 2 alerts :
*** Settings ***
Library Browser
*** Test Cases ***
Alert-Debug
Browser Setup
#provide correct index.html path below
Go To C:/alert_demo/index.html
Click //button
Validate Alert Response First alert accepted?
Validate Alert Response Second alert!
*** Keywords ***
Browser Setup
Set Browser Timeout 30
New Browser browser=chromium headless=false args=["--start-maximized"]
New Context viewport=${None}
New Page url=about:blank
Validate Alert Response
[Arguments] ${messageValue}
${message} = Wait For Alert action=accept text=${messageValue} timeout=5
Expected behavior
Two alerts should be handled correctly
Desktop :
chromium
Win 11 E
Python 3.11.9
NodeJS v20.15.1
Browser library 18.6.3
Robot Framework version: 7.0.1
Playwright 1.45.0
Additional context
More details: https://forum.robotframework.org/t/can-not-handle-two-consecutives-alerts/3347