I have a problem with watir and javascript popup window
here's my test script
require 'watir'
browser = Watir::Browser.start "/url/"
browser.link(:text, /Add New Blog/).wait_until_present
browser.link(:text, /Add New Blog/).click
// Here is where the javascript window popup
window = browser.ie.Document.ParentWindow
browser.window(:title, /Blog/) do
browser.text_field(:id, /text title of Blog/).set 'Watir'
browser.select_list(:id, /dropdownlist type/).select ("News")
browser.button(:value, /Save/).click
end
The problem is after window popup shows , it's unable to locate the element of the text_field in window Blog . I also have try this but it says that => in 'window': wrong number of arguments (2 for 1) (ArgumentError)
browser.window(:title => "annoying popup").use do
browser.button(:id => "close").click
end
Any solution? and btw Im using ruby 1.9.3. Appreciate your help.TQ
There are two forms of Watir - watir-classic and watir-webdriver. If possible/convenient you should use watir-webdriver because it is the future of browser automation and where all the development focus will be going forward.
Your code looks fine if you are using watir-webdriver. I have never used watir-classic, but it appears that it only supports initializing a window with a hash instead of multiple arguments. So maybe this will work for you if you need to use watir-classic:
browser.window(title: /Blog/) { #execute block }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.