-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Closed
Labels
A-needs-triagingA Selenium member will evaluate this soon!A Selenium member will evaluate this soon!I-defectSomething is not working as intendedSomething is not working as intended
Description
What happened?
1.Open a new window.
2.Outputs an alert.
3.Outputs the window handle.
Normally, this would return an error due to alert being active, but in this case it freezes and further operations become impossible.
Error handling is difficult, so we would appreciate it if you could address this issue.
How can we reproduce the issue?
from selenium import webdriver
from selenium.webdriver.common.alert import Alert
from selenium.webdriver.chrome.service import Service
import time
# Initialize the Chrome driver
driver = webdriver.Chrome()
# Open Google in the first window
driver.get("https://www.google.com")
# Open a new window and switch to it
driver.execute_script("window.open('');")
# driver.switch_to.window(driver.window_handles[1])
# Open Google in the new window
driver.get("https://www.google.com")
# Display an alert
alert = Alert(driver)
alert_text = "This is an alert"
driver.execute_script(f"alert('{alert_text}');")
print(1)
# Print the window handles
time.sleep(5)
print(driver.window_handles)
print(2)
# Close the driver after a short delay
time.sleep(5)
driver.quit()Relevant log output
1Operating System
Windows
Selenium version
4.22
What are the browser(s) and version(s) where you see this issue?
Chrome
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver
Are you using Selenium Grid?
No response
Metadata
Metadata
Assignees
Labels
A-needs-triagingA Selenium member will evaluate this soon!A Selenium member will evaluate this soon!I-defectSomething is not working as intendedSomething is not working as intended