@@ -34,6 +34,13 @@ public void ShouldThrowAnExceptionIfTheElementIsNotASelectElement()
3434 Assert . Throws < UnexpectedTagNameException > ( ( ) => { SelectElement elementWrapper = new SelectElement ( element ) ; } ) ;
3535 }
3636
37+ [ Test ]
38+ public void ShouldThrowAnExceptionIfTheElementIsNotEnabled ( )
39+ {
40+ IWebElement element = driver . FindElement ( By . Name ( "no-select" ) ) ;
41+ Assert . Throws < InvalidOperationException > ( ( ) => { SelectElement elementWrapper = new SelectElement ( element ) ; } ) ;
42+ }
43+
3744 [ Test ]
3845 public void ShouldIndicateThatASelectCanSupportMultipleOptions ( )
3946 {
@@ -141,7 +148,7 @@ public void ShouldReturnFirstSelectedOption()
141148
142149 // [Test]
143150 // [ExpectedException(typeof(NoSuchElementException))]
144- // The .NET bindings do not have a "FirstSelectedOption" property,
151+ // The .NET bindings do not have a "FirstSelectedOption" property,
145152 // and no one has asked for it to this point. Given that, this test
146153 // is not a valid test.
147154 public void ShouldThrowANoSuchElementExceptionIfNothingIsSelected ( )
@@ -196,6 +203,14 @@ public void ShouldThrowExceptionOnSelectByVisibleTextIfOptionDoesNotExist()
196203 Assert . Throws < NoSuchElementException > ( ( ) => elementWrapper . SelectByText ( "not there" ) ) ;
197204 }
198205
206+ [ Test ]
207+ public void ShouldThrowExceptionOnSelectByVisibleTextIfOptionDisabled ( )
208+ {
209+ IWebElement element = driver . FindElement ( By . Name ( "single_disabled" ) ) ;
210+ SelectElement elementWrapper = new SelectElement ( element ) ;
211+ Assert . Throws < NoSuchElementException > ( ( ) => elementWrapper . SelectByText ( "Disabled" ) ) ;
212+ }
213+
199214 [ Test ]
200215 public void ShouldAllowOptionsToBeSelectedByIndex ( )
201216 {
@@ -214,6 +229,14 @@ public void ShouldThrowExceptionOnSelectByIndexIfOptionDoesNotExist()
214229 Assert . Throws < NoSuchElementException > ( ( ) => elementWrapper . SelectByIndex ( 10 ) ) ;
215230 }
216231
232+ [ Test ]
233+ public void ShouldThrowExceptionOnSelectByIndexIfOptionDisabled ( )
234+ {
235+ IWebElement element = driver . FindElement ( By . Name ( "single_disabled" ) ) ;
236+ SelectElement elementWrapper = new SelectElement ( element ) ;
237+ Assert . Throws < NoSuchElementException > ( ( ) => elementWrapper . SelectByIndex ( 1 ) ) ;
238+ }
239+
217240 [ Test ]
218241 public void ShouldAllowOptionsToBeSelectedByReturnedValue ( )
219242 {
@@ -232,6 +255,14 @@ public void ShouldThrowExceptionOnSelectByReturnedValueIfOptionDoesNotExist()
232255 Assert . Throws < NoSuchElementException > ( ( ) => elementWrapper . SelectByValue ( "not there" ) ) ;
233256 }
234257
258+ [ Test ]
259+ public void ShouldThrowExceptionOnSelectByReturnedValueIfOptionDisabled ( )
260+ {
261+ IWebElement element = driver . FindElement ( By . Name ( "single_disabled" ) ) ;
262+ SelectElement elementWrapper = new SelectElement ( element ) ;
263+ Assert . Throws < NoSuchElementException > ( ( ) => elementWrapper . SelectByValue ( "disabled" ) ) ;
264+ }
265+
235266 [ Test ]
236267 public void ShouldAllowUserToDeselectAllWhenSelectSupportsMultipleSelections ( )
237268 {
0 commit comments