0

I have a problem: I make a new group at my network webseit and then I will to delete it. When I make it - I see a new window (JavaScript) and I can nothing doing. How can I whrite my code if I see this window?

I use Watir-WebDriver in Cucumber and I work with Google Chrome.

Kurt Russell
  • 225
  • 1
  • 3
  • 15
  • related http://stackoverflow.com/questions/2249287/ruby-watir-clicking-ok-on-javascript-alerts – Marcos Jun 01 '12 at 07:38

3 Answers3

2

Not sure if this helps 100% but in my Ruby code I require "dialogs.rb" and then call killjspopup(browser) right after loading a new page into Watir::Browser. This file contains:

def killjspopup(browser)

# don't return anything for alert
browser.execute_script("window.alert = function() {}")

# return some string for prompt to simulate user entering it
#browser.execute_script("window.prompt = function() {return 'my name'}")

# return null for prompt to simulate clicking Cancel
browser.execute_script("window.prompt = function() {return null}")

# return true for confirm to simulate clicking OK
browser.execute_script("window.confirm = function() {return true}")

# return false for confirm to simulate clicking Cancel
#browser.execute_script("window.confirm = function() {return false}")
end
Marcos
  • 4,796
  • 5
  • 40
  • 64
0

Have you tried the solutions listed on the Watir-Webdriver page - http://watirwebdriver.com/javascript-dialogs/?

Justin Ko
  • 46,526
  • 5
  • 91
  • 101
0

browser.alert.ok

More details at: http://watirwebdriver.com/javascript-dialogs/

genegc
  • 1,630
  • 18
  • 16