Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8176071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:01:19+00:00 2026-06-06T23:01:19+00:00

I use watir for testing in RadRails IDE.After clicking button Delete appears window Message

  • 0

I use watir for testing in RadRails IDE.After clicking button Delete appears window “Message from webpage” which confirms if I really want delete record. How can I simulate clicking OK?
Here are methods i try:
1) ie=Watir::IE.new
ie.execute_script("window.alert = function() {}") - have no effect

2) ie1.button(:name, "delete_action").click
ie4.execute_script("window.confirm = function() {return true}")

Get error – Task.rb:140:in '<main>: undefined local variable or method 'ie4' for main:Object (NameError)

3) ie1.button(:name, "delete_action").click
ie1.execute_script("window.confirm = function() {return true}")

Have no effect

4) `def startClicker( button , waitTime = 3)

   w = WinClicker.new

   longName = ie.dir.gsub("/" , "\\" )

   shortName = w.getShortFileName(longName)

   c = "start rubyw #{shortName }\\watir\\clickJSDialog.rb #{button }

#{ waitTime} "

   puts "Starting #{c}"

   w.winsystem(c)

   w=nil

 end`

And put

   `ie1.button(:name, "delete_action").click

   startClicker("OK" , 3)

   ie.button("Submit").click`

after message from webpage appears.
Get error:

E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/modal_dialog.rb:3:in 'initialize': Watir no longer supports WinClicker. Please use click_no_wait and the javascript_dialog method. (NotImplementedError)
from Task.rb:12:in 'new'
from Task.rb:12:in 'startClicker'
from Task.rb:162:in '<main>'

5) Code in the begining of test

`def check_for_popups

autoit = WIN32OLE.new('AutoItX3.Control')

loop do

    ret = autoit.WinWait('Message from webpage', '', 1)

    if (ret==1) then autoit.Send('{enter}') end

    sleep(3)

 end  end`


Code after message from webpage appears

`ie1.button(:name, "delete_action").click 

$popup = Thread.new { check_for_popups } 

at_exit { Thread.kill($popup) } `

No reaction.

6) `require ‘watir-classic\contrib\enabled_popup’

def startClicker( button , waitTime= 9, user_input=nil )

hwnd = $ie.enabled_popup(waitTime)

if (hwnd)

w = WinClicker.new

if ( user_input )

  w.setTextValueForFileNameField( hwnd, "#{user_input}" )

end

sleep 3

w.clickWindowsButton_hwnd( hwnd, "#{button}" )

w=nil

end

end`

Code after message from webpage appears

`ie1.button(:name, “delete_action”).click_no_wait

startClicker( “OK “, 7)`

Get message –
Task.rb:14:instartClicker’: undefined method enabled_popup' for nil:NilClass (NoMethodError)
from Task.rb:157:in
‘`

7)require 'watir/contrib/enabled_popup'

Code after message from webpage appears –

`hwnd = browser.enabled_popup(5)

if (hwnd)

popup = WinClicker.new

popup.makeWindowActive(hwnd)

popup.clickWindowsButton(“Message from webpage”, “OK”, “30”)

end`

Get error – E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/win32.rb:19:inblock in ‘: 1.9’s DL API not compatible with 1.8, see http://www.ruby-forum.com/topic/138277 (NotImplementedError)
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/contrib/enabled_popup.rb:11:in call'
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/contrib/enabled_popup.rb:11:in
block in enabled_popup’
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/wait.rb:18:in until'
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/contrib/enabled_popup.rb:10:in
enabled_popup’
from Task.rb:145:in <main>'

8)`require ‘watir-classic\contrib\enabled_popup’

def popupChecker(text)

Timeout::timeout(2)do

    begin

        if $ie.enabled_popup

            hwnd = ie.enabled_popup(5)

            w = WinClicker.new

            w.makeWindowActive(hwnd)

            w.clickWindowsButton_hWnd(hwnd,text)

        end

    rescue Timeout::Error

        puts 'No popup existed'

    end

end

end`

Code after message from webpage appears –

`ie1.button(:name, “delete_action”).click_no_wait

popupChecker(‘OK’)

ie1.wait`

Get message:Task.rb:13:inblock in popupChecker’: undefined method enabled_popup' for nil:NilClass (NoMethodError)
from E:/Ruby193/lib/ruby/1.9.1/timeout.rb:68:in
timeout’
from Task.rb:11:in popupChecker'
from Task.rb:158:in
‘`

9)`def check_for_popups(title=”Message from webpage”, button=”OK”)

popup=Thread.new {

    autoit=WIN32OLE.new('AutoItX3.Control')

    ret=autoit.WinWait(title,"",60)

    if (ret==1)

        puts "There is popup."

        autoit.WinActivate(title)

        button.downcase!

        if button.eql?("ok") || button.eql?("yes") || button.eql?("continue")

            autoit.Send("{Enter}")

        else

            autoit.Send("{tab}")

            autoit.Send("{Enter}")

        end

    elsif (ret==0)

        puts "No popup, please check your code."

    end

}

at_exit { Thread.kill(popup) }

end`

Code after message from webpage appears –

check_for_popups("Message from webpage", "OK")

No reaction

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:01:20+00:00Added an answer on June 6, 2026 at 11:01 pm

    Try this:

    browser.alert.ok
    

    More information: http://watir.github.io/docs/javascript-dialogs/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use watir in RadRails IDE. I need to attach a new window by
I use watir in radrails IDE. How can I find and print all existing
I'm trying for the first time to use Watir for automated browser-based testing. For
class MyWatir < Watir::Browser def with_watir_window(win) cw = window #current window win.use yield cw.use
Everytime I use watir-webdriver to initialise a chrome browser instance, it launches as a
I'm testing a feature with watir and running into an issue with validating ascii
I'm using Watir to do some automated testing for a website. This particular test
I have some single watir.rb scripts that use IE and are written in a
I tried to install and use Watij (Web Application Testing in Java) on my
I'm trying to use watir-webdriver with IE9 on 64bit Windows 7. When I try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.