On Thu, Mar 3, 2011 at 2:12 PM, Usman Hussain <usmanhhuss...@gmail.com> wrote: > Hi Guys, > > Im doing a test at the moment where when I enter in something into the > url it brings up a Javascript pop up. > Now I do not want to turn the pop up function off by writing some > Javascript and then using @b.execute_script etc... > > What I would LIKE to do is to somehow interact with the javascript pop > up and click on the button to close it. > Is there any way i can do it using the Watir or Webdriver Api or > something? > > The pop up is an ALERT box. > I am using a MAC > I am using Watir-Webdriver with Cucumber > Ruby v1.8.7 > > any more info please shout. > Any help would be awesome. >
There are two ways to do this: 1. Use watir-webdriver's execute_script hacks: require 'watir-webdriver/extensions/alert' browser.alert do # perform action that triggers alert end See https://github.com/jarib/watir-webdriver/blob/master/spec/alert_spec.rb for more examples. 2. Use WebDriver's alert handling API directly (currently Firefox-only and considered experimental) # perform action that triggers alert browser.driver.switch_to.alert.accept More examples of this here http://code.google.com/p/selenium/source/browse/trunk/rb/spec/integration/selenium/webdriver/target_locator_spec.rb#97 Jari -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com