0

我有一个问题:我在我的网络网站上创建了一个新组,然后我会删除它。当我成功时 - 我看到一个新窗口(JavaScript),我无能为力。如果我看到这个窗口,我该如何编写我的代码?

我在 Cucumber 中使用 Watir-WebDriver,并使用 Google Chrome。

4

3 回答 3

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
于 2012-06-01T07:46:10.450 回答
0

您是否尝试过 Watir-Webdriver 页面 - http://watirwebdriver.com/javascript-dialogs/上列出的解决方案?

于 2012-05-31T15:22:25.190 回答
0

browser.alert.ok

更多详情请访问:http://watirwebdriver.com/javascript-dialogs/

于 2014-08-06T17:39:01.810 回答