0

ということで、アラートが表示されるまではやりたいしwait、その後は通常通りswitchアラートを出したりget text

Java でのソリューションが提供されています Selenium 2 (WebDriver): Alert.getText() を呼び出す前にテキストが存在することを確認してください

現在私は使用していますsleepが、誰もがそれがどれほど悪いかを知っています.

これは私が持っているものです -

sleep 3
a = $driver.switch_to.alert
begin
  a.text == 'Your alert here.'
rescue
  verify { assert_match "true","false","The alert failed to be displayed"}
end
a.accept

私は次のようなものを探しています

$wait.until { a = $driver.switch_to.alert }
begin
  a.text == 'Your alert here.'
rescue
  verify { assert_match "true","false","The alert failed to be displayed"}
end
a.accept

しかし、それは機能しません。基本的に待機を無視します(ところで、30秒待機しています)。私が述べたように、私はそれを行う方法を知る必要がありますRUBY - Test Unit

4

2 に答える 2

1

アラートが表示されるのを待つ方法はありません。ただし、以下のコードを使用して、アラートが表示されるまで待つことができます。アラートが表示されると、ループから抜け出します。

status=true
while (status)
alert = driver.switch_to.alert rescue "exception happened"
if (alert == "exception happened")
status = true
alert = "nothing happened"
else
status = false
end
end
于 2012-07-24T11:49:13.433 に答える
0

watir と watir-webdriver を使用する場合、 $browser.wait_unitil_present のようなことができます

于 2012-06-05T22:11:54.417 に答える