1
votes

I am not able to click on a java script alert using watir 2.0.4. This is the alert that i am trying to click on. And the line of the code that i am using to click on the javascript alert is

browser.javascript_dialog.button('OK').click

All i get is the error message

undefined method `javascript_dialog' for #<Watir::IE:0x46efcb8> (NoMethodError)

enter image description here

Do i need to install some specific gems for it to work? I thought watir is all i need and i have it already installed. Is it not supported with Watir 2.0.4 ? Please find my gems below.

I also tried supressing the java scrit alert by adding the following lines before clicking on the javascript alert. It did n't work either. Waiting for your valuable input. Thanks!

browser.execute_script "window.confirm = function() { return true; }" 

browser.execute_script "window.alert = function() { return true; }" 

browser.execute_script "window.prompt = function() { return true; }" 

* LOCAL GEMS *

builder (3.0.0)

commonwatir (2.0.4)

ffi (1.0.10 x86-mingw32)

hoe (2.12.3)

minitest (1.6.0)

nokogiri (1.5.0 x86-mingw32)

rake (0.8.7)

rautomation (0.6.3)

rdoc (2.5.8)

s4t-utils (1.0.4)

user-choices (1.1.6.1)

watir (2.0.4)

win32-api (1.4.8 x86-mingw32)

win32-process (0.6.5)

windows-api (0.4.0)

windows-pr (1.2.1)

xml-simple (1.1.1)

1

1 Answers

0
votes

The Watir RDoc list of methods does not have .javascript_dialog listed.

It does however have .java_dialog_window

I would try using

browser.javascript_dialog_window.button('OK').click

I'm not sure if the method got renamed for some reason and the popup page in the wiki did not get updated, or if that page has had the wrong method name all along. Let me know if this works and if so I can bug TPTB to figure out what needs to get changed.