I'm new to WATIR testing (and do I love it!) and have run into a wall on how to refocus my WATIR script to a newly opened window.. Here's my (simplified) script....
#!/usr/bin/ruby
require 'rubygems'
require 'watir-webdriver'
browser=Watir::Browser.new
browser.goto("http://0:3050")
browser.text_field(:name,"userkey300203830").set("OKJHNB")
browser.button(:id, "interview48").click
puts "Expected Result:"
puts "A successful display of cars"
if browser.window(:title=>"300203830").exists?
puts " Test passed. New window opened!"
else
puts " Test Failed! No window found"
end
It all works right up to the end. After the key "interview48" is clicked, a new window is opened with the title "300203830". Looks like I find it but I just don't know how to now focus on that window.
browser.window(:title => "300203830").use do
# do something
end
More information: http://watir.github.io/docs/browser-popups/
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