私はC#でSelenium RCを使っていくつかの自動対話テストを行っていますが、不安を抱えています。私はオプションの「第三の選択肢は、」ページの上に存在することを確認するためにテストしたいSelect Optionのテキスト(C#)を使用してSelenium.IsElementPresent
<select id="my-select-list">
<option value="1">First option</option>
<option value="2">Second option</option>
<option value="3">Third option</option>
<option value="4">Fourth option</option>
</select>
:
は、このHTMLを考えます。
次のテストはすべて、すなわちfalseを返し、失敗した:
Selenium.IsElementPresent("//select/option[@label='Third option']")
Selenium.IsElementPresent("//select[option='Third option']")
Selenium.IsElementPresent("//select[contains(option, 'Third option')]")
Selenium.IsElementPresent("//option[contains(., 'Third option')]")
Selenium.IsElementPresent("//option[contains(text(), 'Third option')]")
はそれはセレン(RC/.NET)の制限であるか、それを選択する別の方法は何ですか?
ps。私はオプションの値を使ってテストできることは分かっていますが、それは変わるかもしれませんし、テキストは明らかにそうではありません。
EDIT:PEBKACエラー
申し訳ありませんが、私の悪いです。セレンは私がロードしていると思っていたものとは異なるサイトをロードしていたようです。
次のXPathは、すべての作業を照会します。
Selenium.IsElementPresent("//option[text()='Third option']")
Selenium.IsElementPresent("//select[option='Third option']")
Selenium.IsElementPresent("//option[contains(., 'Third option')]")
Selenium.IsElementPresent("//option[contains(text(), 'Third option')]")
PEBKACエラー、私の悪い。セレンは私が思っていたサイトとは異なるサイトをロードしていました。とにかくあなたには正しい答えが返ってきます:-) – Charlino