@@ -51,10 +51,8 @@ public function testShouldThrowExceptionWhenNotInstantiatedOnSelectElement()
5151 {
5252 $ notSelectElement = $ this ->driver ->findElement (WebDriverBy::cssSelector ('textarea ' ));
5353
54- $ this ->setExpectedException (
55- UnexpectedTagNameException::class,
56- 'Element should have been "select" but was "textarea" '
57- );
54+ $ this ->expectException (UnexpectedTagNameException::class);
55+ $ this ->expectExceptionMessage ('Element should have been "select" but was "textarea" ' );
5856 new WebDriverSelect ($ notSelectElement );
5957 }
6058
@@ -109,10 +107,8 @@ public function testShouldThrowExceptionIfThereIsNoFirstSelectedOptionOfMultiple
109107 {
110108 $ select = $ this ->getWebDriverSelectForMultipleSelect ();
111109
112- $ this ->setExpectedException (
113- NoSuchElementException::class,
114- 'No options are selected '
115- );
110+ $ this ->expectException (NoSuchElementException::class);
111+ $ this ->expectExceptionMessage ('No options are selected ' );
116112 $ select ->getFirstSelectedOption ();
117113 }
118114
@@ -155,10 +151,8 @@ public function testShouldThrowExceptionIfThereIsNoOptionIndexToSelect()
155151 {
156152 $ select = $ this ->getWebDriverSelectForSimpleSelect ();
157153
158- $ this ->setExpectedException (
159- NoSuchElementException::class,
160- 'Cannot locate option with index: 1337 '
161- );
154+ $ this ->expectException (NoSuchElementException::class);
155+ $ this ->expectExceptionMessage ('Cannot locate option with index: 1337 ' );
162156 $ select ->selectByIndex (1337 );
163157 }
164158
@@ -201,10 +195,8 @@ public function testShouldThrowExceptionIfThereIsNoOptionValueToSelect()
201195 {
202196 $ select = $ this ->getWebDriverSelectForSimpleSelect ();
203197
204- $ this ->setExpectedException (
205- NoSuchElementException::class,
206- 'Cannot locate option with value: 1337 '
207- );
198+ $ this ->expectException (NoSuchElementException::class);
199+ $ this ->expectExceptionMessage ('Cannot locate option with value: 1337 ' );
208200 $ select ->selectByValue (1337 );
209201 }
210202
@@ -247,10 +239,8 @@ public function testShouldThrowExceptionIfThereIsNoOptionVisibleTextToSelect()
247239 {
248240 $ select = $ this ->getWebDriverSelectForSimpleSelect ();
249241
250- $ this ->setExpectedException (
251- NoSuchElementException::class,
252- 'Cannot locate option with text: second '
253- );
242+ $ this ->expectException (NoSuchElementException::class);
243+ $ this ->expectExceptionMessage ('Cannot locate option with text: second ' );
254244 $ select ->selectByVisibleText ('second ' ); // the option is "This is second option"
255245 }
256246
@@ -296,21 +286,17 @@ public function testShouldThrowExceptionIfThereIsNoOptionVisiblePartialTextToSel
296286 {
297287 $ select = $ this ->getWebDriverSelectForSimpleSelect ();
298288
299- $ this ->setExpectedException (
300- NoSuchElementException::class,
301- 'Cannot locate option with text: Not existing option '
302- );
289+ $ this ->expectException (NoSuchElementException::class);
290+ $ this ->expectExceptionMessage ('Cannot locate option with text: Not existing option ' );
303291 $ select ->selectByVisiblePartialText ('Not existing option ' );
304292 }
305293
306294 public function testShouldThrowExceptionWhenDeselectingOnSimpleSelect ()
307295 {
308296 $ select = $ this ->getWebDriverSelectForSimpleSelect ();
309297
310- $ this ->setExpectedException (
311- UnsupportedOperationException::class,
312- 'You may only deselect all options of a multi-select '
313- );
298+ $ this ->expectException (UnsupportedOperationException::class);
299+ $ this ->expectExceptionMessage ('You may only deselect all options of a multi-select ' );
314300 $ select ->deselectAll ();
315301 }
316302
@@ -353,10 +339,8 @@ public function testShouldThrowExceptionIfDeselectingSimpleSelectByIndex()
353339 {
354340 $ select = $ this ->getWebDriverSelectForSimpleSelect ();
355341
356- $ this ->setExpectedException (
357- UnsupportedOperationException::class,
358- 'You may only deselect options of a multi-select '
359- );
342+ $ this ->expectException (UnsupportedOperationException::class);
343+ $ this ->expectExceptionMessage ('You may only deselect options of a multi-select ' );
360344 $ select ->deselectByIndex (0 );
361345 }
362346
@@ -381,10 +365,8 @@ public function testShouldThrowExceptionIfDeselectingSimpleSelectByValue()
381365 {
382366 $ select = $ this ->getWebDriverSelectForSimpleSelect ();
383367
384- $ this ->setExpectedException (
385- UnsupportedOperationException::class,
386- 'You may only deselect options of a multi-select '
387- );
368+ $ this ->expectException (UnsupportedOperationException::class);
369+ $ this ->expectExceptionMessage ('You may only deselect options of a multi-select ' );
388370 $ select ->deselectByValue ('first ' );
389371 }
390372
@@ -411,10 +393,8 @@ public function testShouldThrowExceptionIfDeselectingSimpleSelectByVisibleText()
411393 {
412394 $ select = $ this ->getWebDriverSelectForSimpleSelect ();
413395
414- $ this ->setExpectedException (
415- UnsupportedOperationException::class,
416- 'You may only deselect options of a multi-select '
417- );
396+ $ this ->expectException (UnsupportedOperationException::class);
397+ $ this ->expectExceptionMessage ('You may only deselect options of a multi-select ' );
418398 $ select ->deselectByVisibleText ('First ' );
419399 }
420400
@@ -447,10 +427,8 @@ public function testShouldThrowExceptionIfDeselectingSimpleSelectByVisiblePartia
447427 {
448428 $ select = $ this ->getWebDriverSelectForSimpleSelect ();
449429
450- $ this ->setExpectedException (
451- UnsupportedOperationException::class,
452- 'You may only deselect options of a multi-select '
453- );
430+ $ this ->expectException (UnsupportedOperationException::class);
431+ $ this ->expectExceptionMessage ('You may only deselect options of a multi-select ' );
454432 $ select ->deselectByVisiblePartialText ('First ' );
455433 }
456434
0 commit comments