Closing the child browser window seems to break the Watir-webdriver link to the parent window?

In Chrome, using watir-webdriver, I click the button that opens the child browser window.

I do:

@browser.window(title: 'Child').use

I successfully interact with various elements in this child window.

Soon, an action was taken in this window, which, according to the site, was the "point" of opening the window in the first place. eg.

@browser.button(title: 'Button').click

When this action is performed, the child window closes.

When I tell watir-webdriver to return to using the parent window, however, I get an error:

@browser.window(title: 'Parent').use # => results in
# Selenium::WebDriver::Error::NoSuchWindowError: emptyScript execution failed; 
# The window could not be found

I believe this is a Selenium / Watir-webdriver error, because the following code works:

@browser.window(title: 'Child').use
# ... Now I do various things in the child window that do NOT
# ... cause it to close itself. They all work as expected.
# ...
puts @browser.window(title: 'Parent').present? #=>true
@browser.window(title: 'Child').close
puts @browser.window(title: 'Parent').present? #=>true
@browser.window(title: 'Parent').use # => No error thrown

The only difference is the action that causes the child window to close.

, watirspec , , , Windows watir-webdriver.

, , , :

require 'watir-webdriver'
@b = Watir::Browser.new :chrome
@b.goto 'ckeditor.com/demo#full'
@b.div(id: 'cke_editor1').link(title: 'Link').click
@b.link(title: 'Browse Server').wait_until_present
@b.link(title: 'Browse Server').click
@b.window(title: 'CKFinder').use { 
  @b.frame(title: 'CKFinder').link(id: 'r0').right_click
  @b.frame(title: 'CKFinder').frame(id: 'cke_22_frame').wait_until_present 
  @b.frame(title: 'CKFinder').frame(id: 'cke_22_frame').link(id: 'cke_200').click
}

:

Selenium::WebDriver::Error::NoSuchWindowError: emptyScript execution failed;
The window could not be found

, !: -)

, : " , ?" : .

, , , , CKEditor, ( ). , , , , , , . , CKEditor. Capiche?

+5
1

,

@browser.windows[0]

- ( )

@browser.windows.each do |window|
  if window.title.include?(target_string)
    window.use
  end
end
+1

All Articles