lib/symbiont/enclosers.rb in symbiont-0.1.8 vs lib/symbiont/enclosers.rb in symbiont-0.1.9
- old
+ new
@@ -12,11 +12,11 @@
#
# @example
# page.within_window(title: "Report Page")
# page.within_window(url: report.html)
def within_window(locator, &block)
- @platform.within_window(locator, &block)
+ platform.within_window(locator, &block)
end
# Used to identify a web object as existing within an enclosing object
# like a frame or an iframe. It is possible to nest by passing in parent
# enclosers as the second parameter.
@@ -35,10 +35,26 @@
def within_frame(locator, encloser=nil, &block)
encloser = [] if encloser.nil?
encloser << locator
block.call(encloser)
end
-
+
+ # Used to identify a web object as existing within an enclosing object
+ # like a modal dialog box. What this does is override the normal call to
+ # showModalDialog and opens a window instead. In order to use this new
+ # window, you have to attach to it.
+ def within_modal(&block)
+ convert_modal_to_window = %Q{
+ window.showModalDialog = function(sURL, vArguments, sFeatures) {
+ window.dialogArguments = vArguments;
+ modalWin = window.open(sURL, 'modal', sFeatures);
+ return modalWin;
+ }
+ }
+ @browser.execute_script(convert_modal_to_window)
+ yield if block_given?
+ end
+
# Provides a context for an action that must succeed within a given time period.
# The logic here is simply that the result of the action will be true (meaning
# the action was carried out) or false, which means the action did not succeed
# in the time allotted.
#