-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[🐛 Bug]: alerts not working properly #15068
Comments
@bestchatgptuser, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
Hi, @bestchatgptuser. Either a complete code snippet and URL/HTML (if more than one file is needed, provide a GitHub repo and instructions to run the code), the specific versions used, or a more detailed description to help us understand the issue. Note: If you cannot share your code and URL/HTML, any complete code snippet and URL/HTML that reproduces the issue is good enough. Reply to this issue when all information is provided, thank you. |
it just does not get simpler than this. a popup appears, and Selenium doesn't detect it |
Selenium can interact web app pop-ups, not OS level pop-ups. Check that, please. Otherwise, we need a way to reproduce the issue. |
If it is an OS level pop-up, I've used pyautogui for them successfully before |
it's a web app pop-up |
@bestchatgptuser looking forward to see your code script so we can reproduce the issue! |
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'capybara'
require 'capybara/dsl'
require 'selenium-webdriver'
# @param headless [Boolean] browser: :chrome or :firefox
# @param opts [Array] additional browser command line options
def browser_opts(headless: false, opts: [])
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--ignore-certificate-errors')
options.add_argument('--no-sandbox')
options.add_argument('--disable-search-engine-choice-screen')
options.add_argument('--headless') if headless
options.accept_insecure_certs = true
options.add_option(:web_socket_url, true)
options.unhandled_prompt_behavior = :ignore
opts&.each { |opt| options.add_argument(opt) }
options
end
Capybara.register_driver(:chrome) do |app|
driver = Capybara::Selenium::Driver.new(
app,
browser: :chrome,
options: browser_opts(headless: true)
)
driver
end
Capybara.threadsafe = true
Capybara.default_driver = :chrome
Capybara.javascript_driver = :chrome
@page = Capybara::Session.new(:chrome) do |config|
config.run_server = false
config.default_max_wait_time = 5
end
# below triggers Unsaved changes dialog
@page.visit('https://regex101.com/')
@page.all('div.cm-content.cm-lineWrapping').each do |element|
element.send_keys 'Data'
end
sleep 5
puts 'Waiting for Alert'
begin
@page.accept_alert(/.*/, wait: 5) { @page.visit('https://google.com/') }
rescue Capybara::ModalNotFound
puts 'unable to find modal dialog in 5 seconds'
end
alert = @page.page.driver.browser.switch_to.alert.text
puts "alert -> #{alert.text}"
exit 0 No alert is seen
|
I do not see the google page, I see Unsaved Changes alert, but selenium does not see them ![]() with options
All simple dialogs encountered should be left to the user to handle. |
That is not a web pop-up or an alert. It is an OS prompt created by the browser itself. |
But with sleep 5
puts 'Waiting for Alert'
@page.visit('https://google.com/')
alert = @page.driver.browser.switch_to.alert
puts "alert -> #{alert}"
alert.accept
puts "URL #{@page.current_url}"
exit 0 And it gives
|
What happened?
tried triggering an alert, then dismissing it, but Selenium never detects the alert. it's just that.
![image](https://private-user-images.githubusercontent.com/193723205/402492110-fa53e8ec-5fca-4695-8f38-6c2739c63b0d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyMTY0MTAsIm5iZiI6MTczOTIxNjExMCwicGF0aCI6Ii8xOTM3MjMyMDUvNDAyNDkyMTEwLWZhNTNlOGVjLTVmY2EtNDY5NS04ZjM4LTZjMjczOWM2M2IwZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMFQxOTM1MTBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01YjMzODI4N2U3NmRhYTE3MjY1ZDcwMWExYzM2YjYyM2Y1NjZiOTFiZGQ2NjJmODE2YzhmY2JmODM1NzAyYWViJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.8GEuCm2ExQbVHcT097wr4UY6Y93CWtp2kya-3u-abnw)
How can we reproduce the issue?
Relevant log output
Operating System
windows 11
Selenium version
C# 4.27.0
What are the browser(s) and version(s) where you see this issue?
chrome 131.0.6778.265
What are the browser driver(s) and version(s) where you see this issue?
i honestly have no clue atp
Are you using Selenium Grid?
No response
The text was updated successfully, but these errors were encountered: