title: Watir Webdriver how to close child windows
body: <p>I'm in the process of migrating some of our legacy Watir scripts over to Watir-Webdriver. The migration has gone mostly well except for how they designed Watir-Webdriver to handle popup windows. Rather than using the tried-and-true 'Attach' method, they have replaced it with a simplified 'Window' method. The syntax is quite simple, however I am having a difficult time understand how to close a separate child window without closing the parent window. Currently my code is something like this -</p>
  
  <pre><code>  b.button(:xpath =&gt; PREVIEWBUTTON).click
    b.window(:title, POPUPWINDOW).use DO
      b.close
    end
  </code></pre>
  
  <p>Currently what is happening is that the b.close method is closing both the child window and parent window. I'm not sure why this is happening since the b.close method is contained in the DO block. I need to verify that the 'PREVIEWBUTTON' indeed creates a child window, but I need the parent window to stay open.</p>