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 -
b.button(:xpath => PREVIEWBUTTON).click
b.window(:title, POPUPWINDOW).use DO
b.close
end
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.
Try this:
b.window(:title, POPUPWINDOW).close
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With