Selenium RC を使用して C# で Selenium を使用して、自動化された対話テストを行っていますが、つまずきのブロックに遭遇しました。
この HTML を考えると:
<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>
オプション「Third Option」がページに存在することを確認するためにテストしたいと思います。
以下のテストはすべて失敗しました。つまり、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')]")
Selenium (RC / .NET) の制限ですか、それとも別の方法で選択できますか?
Ps。オプションの値を使用してテストできることはわかっていますが、それは変更される可能性があり、テキストは間違いなく変更されません。
編集: 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')]")