I'm using Selenium in C# with Selenium RC to do some automated interaction testing but have come across a stumbling block.
Given this 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>
I want to test to make sure that the option "Third Option" is present on the page.
All of the following tests have failed, i.e. return 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')]")
Is it a limitation of Selenium (RC / .NET) or is there another way of selecting it?
Ps. I know I could test using the option's value but that may change and the text definately won't.
EDIT: PEBKAC error
Sorry, my bad. Seems selenium was loading a different site than what I thought it was loading.
The following XPath queries all work:
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')]")