watir-webdriver模态对话框错误

时间:2012-03-26 10:39:22

标签: ruby watir watir-webdriver

[remote server] file:///C:/Users/abdia/AppData/Local/Temp/webdriver-profile20120
326-6092-6x0lwb/extensions/fxdriver@googlecode.com/components/command_processor.
js:10583:in `unknown': Modal dialog present (Selenium::WebDriver::Error::Unhandl
edAlertError)

点击此链接时

<%= link_to "Delete", user, :class => user.email,:method => :delete, :confirm => "Are you sure?" %>

我收到上面的错误,无论如何告诉watir-webdriver在打开的JS对话框中单击OK?

编辑:

html输出

<a href="/users/1" class="ahmet.abdi@dai.co.uk" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Delete</a>

我是通过

找到的
b.a(:class => 'example@dai.co.uk').click

1 个答案:

答案 0 :(得分:3)

require "watir-webdriver/extensions/alerts"

browser.confirm(true) do
  browser.link(text: 'Delete').click
end

您也可以尝试使用WebDriver直接处理

browser.link(text: 'Delete').click
# when modal dialog is shown
browser.driver.switch_to.alert.dismiss