How to handle this popup?
This popup can be treated like any other alert. You can confirm the dialog (ie click Leave) using:
browser.alert.ok
If you do not know if the popup will or will not be there, you can add a check for its presence:
browser.alert.ok if browser.alert.present?
If this does not work, an alternative is to disable the function being called on unload. Make sure that you override the function before it is triggered.
# Remove the function
browser.execute_script("window.onbeforeunload = null")
# Then trigger the action that leaves the page
browser.link.click
How to handle browser javascript confirm navigation alert with ruby watir script
Answer is: you can try to use alternative method, such as: @b.alert.exists?
if it return true
, then: @b.alert.close
I think this can help you in future
Watir: How I can click button in IE popup windows
As best as I can tell you have two separate issues.
Firstly, I have no idea how you set your browser variable to a page object instance. The Page Object Module definitely sets browser
as a readable attribute.
So if the code is within a class that has import PageObject
, you should be able to do browser.window(...)
just fine.
If you are using the code outside of such a class, you need to make sure that you are in a scope that has access to the Watir::Browser instance. If you have a page object defined, you can use it like: my_page_object.browser.window(...)
Secondly - based on what you are describing, the iframe usage has to be combined with the window usage:
browser.window(title: "annoying popup") do
browser.iframe(id: 'frmMain').button(id: "close").click
end
Related Topics
How to Count the Number of Occurrences of Each Item in an Array
Xmlhttprequest Status 0 (Responsetext Is Empty)
JavaScript Equivalent of Rails Try Method
How to Make a Shared State Between Two React Components
Youtube Iframe Player API - Onstatechange Not Firing
Open File Dialog Box in JavaScript
JavaScript Double Colon (Bind Operator)
Jquery UI - Close Dialog When Clicked Outside
Access JavaScript Property Case-Insensitively
Shiny App:Disable Downloadbutton
Template Language That Works on Both Server and Client
Can Nokogiri Interpret JavaScript? - Web Scraping
Escape String - Output Rails String in JavaScript
How to Create an Object from an Array of Key-Value Pairs
Rails - How to Include JavaScript Files Only on Certain Pages