@@ -293,7 +293,7 @@ public void testFindingASingleElementByEmptyClassNameShouldThrow() {
293
293
driver .findElement (By .className ("" ));
294
294
}
295
295
296
- @ Ignore (value = {CHROME }, reason = "Throws WebDriverException" )
296
+ @ Ignore (value = {CHROME , OPERA , OPERA_MOBILE }, reason = "Throws WebDriverException" )
297
297
@ Test (expected = NoSuchElementException .class )
298
298
public void testFindingMultipleElementsByEmptyClassNameShouldThrow () {
299
299
driver .get (pages .xhtmlTestPage );
@@ -321,7 +321,7 @@ public void testFindingASingleElementByInvalidClassNameShouldThrow() {
321
321
driver .findElement (By .className ("!@#$%^&*" ));
322
322
}
323
323
324
- @ Ignore (value = {CHROME }, reason = "Throws InvalidElementStateException" )
324
+ @ Ignore (value = {CHROME , OPERA , OPERA_MOBILE }, reason = "Throws InvalidElementStateException" )
325
325
@ Test (expected = NoSuchElementException .class )
326
326
public void testFindingMultipleElementsByInvalidClassNameShouldThrow () {
327
327
driver .get (pages .xhtmlTestPage );
@@ -519,7 +519,6 @@ public void testShouldThrowInvalidSelectorExceptionWhenXPathReturnsWrongTypeInEl
519
519
520
520
// By.cssSelector positive
521
521
522
- @ JavascriptEnabled
523
522
@ Test
524
523
public void testShouldBeAbleToFindASingleElementByCssSelector () {
525
524
driver .get (pages .xhtmlTestPage );
@@ -528,15 +527,13 @@ public void testShouldBeAbleToFindASingleElementByCssSelector() {
528
527
assertThat (element .getAttribute ("class" ), is ("content" ));
529
528
}
530
529
531
- @ JavascriptEnabled
532
530
@ Test
533
531
public void testShouldBeAbleToFindMultipleElementsByCssSelector () {
534
532
driver .get (pages .xhtmlTestPage );
535
533
List <WebElement > elements = driver .findElements (By .cssSelector ("p" ));
536
534
assertThat (elements .size (), greaterThan (1 ));
537
535
}
538
536
539
- @ JavascriptEnabled
540
537
@ Test
541
538
public void testShouldBeAbleToFindASingleElementByCompoundCssSelector () {
542
539
driver .get (pages .xhtmlTestPage );
@@ -545,7 +542,6 @@ public void testShouldBeAbleToFindASingleElementByCompoundCssSelector() {
545
542
assertThat (element .getAttribute ("class" ), is ("content" ));
546
543
}
547
544
548
- @ JavascriptEnabled
549
545
@ Test
550
546
public void testShouldBeAbleToFindMultipleElementsByCompoundCssSelector () {
551
547
driver .get (pages .xhtmlTestPage );
@@ -555,7 +551,6 @@ public void testShouldBeAbleToFindMultipleElementsByCompoundCssSelector() {
555
551
assertThat (elements .get (1 ).getAttribute ("class" ), is ("extraDiv" ));
556
552
}
557
553
558
- @ JavascriptEnabled
559
554
@ Test
560
555
@ Ignore (value = {IE }, reason = "IE supports only short version option[selected]" )
561
556
public void testShouldBeAbleToFindAnElementByBooleanAttributeUsingCssSelector () {
@@ -564,22 +559,62 @@ public void testShouldBeAbleToFindAnElementByBooleanAttributeUsingCssSelector()
564
559
assertThat (element .getAttribute ("value" ), is ("two" ));
565
560
}
566
561
567
- @ JavascriptEnabled
568
562
@ Test
569
563
public void testShouldBeAbleToFindAnElementByBooleanAttributeUsingShortCssSelector () {
570
564
driver .get (appServer .whereIs ("locators_tests/boolean_attribute_selected.html" ));
571
565
WebElement element = driver .findElement (By .cssSelector ("option[selected]" ));
572
566
assertThat (element .getAttribute ("value" ), is ("two" ));
573
567
}
574
568
575
- @ JavascriptEnabled
576
569
@ Test
577
570
public void testShouldBeAbleToFindAnElementByBooleanAttributeUsingShortCssSelectorOnHtml4Page () {
578
571
driver .get (appServer .whereIs ("locators_tests/boolean_attribute_selected_html4.html" ));
579
572
WebElement element = driver .findElement (By .cssSelector ("option[selected]" ));
580
573
assertThat (element .getAttribute ("value" ), is ("two" ));
581
574
}
582
575
576
+ // By.cssSelector negative
577
+
578
+ @ Test (expected = NoSuchElementException .class )
579
+ public void testShouldNotFindElementByCssSelectorWhenThereIsNoSuchElement () {
580
+ driver .get (pages .xhtmlTestPage );
581
+ driver .findElement (By .cssSelector (".there-is-no-such-class" ));
582
+ }
583
+
584
+ public void testShouldNotFindElementsByCssSelectorWhenThereIsNoSuchElement () {
585
+ driver .get (pages .xhtmlTestPage );
586
+ List <WebElement > elements = driver .findElements (By .cssSelector (".there-is-no-such-class" ));
587
+ assertThat (elements .size (), is (0 ));
588
+ }
589
+
590
+ // @Ignore(value = {CHROME}, reason = "Throws WebDriverException")
591
+ @ Test (expected = NoSuchElementException .class )
592
+ public void testFindingASingleElementByEmptyCssSelectorShouldThrow () {
593
+ driver .get (pages .xhtmlTestPage );
594
+ driver .findElement (By .cssSelector ("" ));
595
+ }
596
+
597
+ // @Ignore(value = {CHROME}, reason = "Throws WebDriverException")
598
+ @ Test (expected = NoSuchElementException .class )
599
+ public void testFindingMultipleElementsByEmptyCssSelectorShouldThrow () {
600
+ driver .get (pages .xhtmlTestPage );
601
+ driver .findElements (By .cssSelector ("" ));
602
+ }
603
+
604
+ @ Ignore (value = {CHROME }, reason = "Throws InvalidElementStateException" )
605
+ @ Test (expected = NoSuchElementException .class )
606
+ public void testFindingASingleElementByInvalidCssSelectorShouldThrow () {
607
+ driver .get (pages .xhtmlTestPage );
608
+ driver .findElement (By .cssSelector ("//a/b/c[@id='1']" ));
609
+ }
610
+
611
+ @ Ignore (value = {CHROME }, reason = "Throws InvalidElementStateException" )
612
+ @ Test (expected = NoSuchElementException .class )
613
+ public void testFindingMultipleElementsByInvalidCssSelectorShouldThrow () {
614
+ driver .get (pages .xhtmlTestPage );
615
+ driver .findElements (By .cssSelector ("//a/b/c[@id='1']" ));
616
+ }
617
+
583
618
// By.linkText positive
584
619
585
620
@ Test
0 commit comments