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 3452600
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:16:37+00:00 2026-05-18T09:16:37+00:00

Seems none of the code I’ve tried has any affect. My intention is to

  • 0

Seems none of the code I’ve tried has any affect. My intention is to close any and all JavaScript prompts that may come up by hitting the “OK” button. Problem is, my script has no affect on the prompts that come up. In other words, it does nothing.

Here’s what I have:

fx = FireWatir::Firefox.start(somepage)
fx.startClicker("OK")
fx.button(:id, "OK").click
fx.button(:id, "CONFIRM").click

The HTML:

<script type="text/javascript">
    alert("Alert!");
    window.confirm("Confirm?");
</script>

The text in the prompts can change, my intention is to hit OK regardless of what is inside the alert/confirm prompt.

PS: I’m running Ubuntu.

  • 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-05-18T09:16:37+00:00Added an answer on May 18, 2026 at 9:16 am

    The best way is to stop pop-ups from triggering at all.

    require 'watir'
    b = Watir::Browser.start "http://somepagewithdialogs"
    # don't return anything for alert
    b.execute_script("window.alert = function() {}")
    
    # return some string for prompt to simulate user entering it
    b.execute_script("window.prompt = function() {return 'my name'}")
    
    # return null for prompt to simulate clicking Cancel
    b.execute_script("window.prompt = function() {return null}")
    
    # return true for confirm to simulate clicking OK
    b.execute_script("window.confirm = function() {return true}")
    
    # return false for confirm to simulate clicking Cancel
    b.execute_script("window.confirm = function() {return false}")
    
    # interact with some element which would trigger the pop up
    b.button(:id => "dialogTrigger").click
    

    See: http://watirmelon.com/2010/10/31/dismissing-pesky-javascript-dialogs-with-watir/ for more detail.

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

Sidebar

Related Questions

I've tried lots of code that I have found on this site, but none
A question that seems to have quite a few options for Python, but none
I've tried several of the solutions that I've found here, but none seem to
I have that code below, It's seems to works but, space when transition works
This code seems to smell: result = None for item in list: if result
I searched over .... I see many advantages, but it seems that all the
I read much about issues with onActivityResult , but it seems that none of
In the following code, it seems that the client.Connect.Receive is pinning the byte[] result
It seems to me that the following code should display text right in the
I've tried several tutorial on the web and none seems to work properly. What

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.