尝试使用get_window
并检查您所期望的标题。driver.execute_script
或者,您可以使用可以查找警报窗口并执行必要操作的任意 Java 代码。
#{{{ Marathon
require_fixture 'default'
#}}} Marathon
def test
with_window("SwingSet3") {
select("JOptionPane", "true")
option = Random.rand(2)
if(option == 0)
click("Show Warning Dialog")
else
click("Show Confirmation Dialog")
end
if(get_window == "Warning Dialog Example")
with_window("Warning Dialog Example") {
click("OK")
}
end
if(get_window == "Select an Option")
with_window("Select an Option") {
click("Yes")
}
with_window("Message") {
click("OK")
}
end
}
end