-
-
Notifications
You must be signed in to change notification settings - Fork 80
Closed
Description
Hello
So I'm trying to model possible <option>
values for a <select>
element. The HTML is basically:
<select data-unique-identifier="3fae10ba-dbe5-432f-a4b5-e031f699fa3c" class="status">
<option value="TODO" selected="">To do</option>
<!-- Can also be: <option value="To do">To do</option> -->
<option value="COMPLETED">Completed</option>
<!-- Can also be: <option value="Completed">Completed</option> -->
<option value="WAIVED">Waived</option>
<!-- Can also be: <option value="Waived">Waived</option> -->
</select>
The enum I've written is:
public enum BringUpStatusType
{
[Term(TermMatch.Equals, "TODO", "To do")]
ToDo,
[Term(TermMatch.Equals, "COMPLETED", nameof(Completed))]
Completed,
[Term(TermMatch.Equals, "WAIVED", nameof(Waived))]
Waived
}
// is referenced and used as:
[FindByColumnIndex(6), FindByCss("select[data-unique-identifier].status")]
[SelectsOptionByAttribute("value")]
public Select<BringUpStatusType, TOwner> StatusForBringUp { get; set; }
However, when I try to change the value of a given <select>
, using the Set() method I get the following error:
OpenQA.Selenium.NoSuchElementException: 'Unable to locate element:
- By: XPath ".//option[normalize-space(@value) = 'TODO/To do']"
- Search time: 7.022s
- Search options: {Visibility=Any, Timeout=7s, RetryInterval=0.25s, IsSafely=False}
Context element:
- Tag: select
- Location: {X=877, Y=696}
- Size: {Width=105, Height=22}
- Element ID: 29C0372F6690CAEC11D11B975AD5A6B2_element_96
- Text:
To do,
Completed,
Waived;
For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception'
So I was able to fix it by updating the enum:
public enum BringUpStatusType
{
[Term(TermMatch.Equals, "TODO")]
[Term(TermMatch.Equals, "To do")]
ToDo,
[Term(TermMatch.Equals, "COMPLETED")]
[Term(TermMatch.Equals, nameof(Completed))]
Completed,
[Term(TermMatch.Equals, "WAIVED")]
[Term(TermMatch.Equals, nameof(Waived))]
Waived
}
And it works with the above change, but I wanted to log this issue anyway as the error message reported an XPath value of .//option[normalize-space(@value) = 'TODO/To do']
, which seems kind of wrong?
[Term]
accepts multiple string
values which I just assumed meant it would search using something like LINQ's .Any()
, but it's concatenating the values with a /
.