Skip to content

Commit 3179985

Browse files
authored
extending WebDriverException (#11727)
* extending WebDriverException - fixes #11712 - fixes #10833 - as per https://www.selenium.dev/meetings/2022/tlc-08-17/#proposals * adding new test class * Delete InvalidSelectorTest.java * Update ElementFindingTest.java updating failing tests
1 parent cfc7eed commit 3179985

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

java/src/org/openqa/selenium/InvalidSelectorException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* errors, or a compound class name passed as an argument to By.className(),
2626
* or the expression does not select WebElements (e.g. "count(//input)").
2727
*/
28-
public class InvalidSelectorException extends NoSuchElementException {
28+
public class InvalidSelectorException extends WebDriverException {
2929

3030
private static final String SUPPORT_URL =
3131
BASE_SUPPORT_URL + "#invalid_selector_exception";

java/test/org/openqa/selenium/ElementFindingTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ void testShouldNotBeAbleToLocateByIdMultipleElementsThatDoNotExist() {
103103
@Test
104104
void testFindingASingleElementByEmptyIdShouldThrow() {
105105
driver.get(pages.formPage);
106-
assertThatExceptionOfType(NoSuchElementException.class)
106+
assertThatExceptionOfType(InvalidSelectorException.class)
107107
.isThrownBy(() -> driver.findElement(By.id("")));
108108
}
109109

110110
@Test
111111
@NotYetImplemented(HTMLUNIT)
112112
public void testFindingMultipleElementsByEmptyIdShouldThrow() {
113113
driver.get(pages.formPage);
114-
assertThatExceptionOfType(NoSuchElementException.class)
114+
assertThatExceptionOfType(InvalidSelectorException.class)
115115
.isThrownBy(() -> driver.findElements(By.id("")));
116116
}
117117

@@ -231,14 +231,14 @@ void testShouldNotBeAbleToLocateByTagNameMultipleElementsThatDoNotExist() {
231231
@Test
232232
void testFindingASingleElementByEmptyTagNameShouldThrow() {
233233
driver.get(pages.formPage);
234-
assertThatExceptionOfType(NoSuchElementException.class)
234+
assertThatExceptionOfType(InvalidSelectorException.class)
235235
.isThrownBy(() -> driver.findElement(By.tagName("")));
236236
}
237237

238238
@Test
239239
void testFindingMultipleElementsByEmptyTagNameShouldThrow() {
240240
driver.get(pages.formPage);
241-
assertThatExceptionOfType(NoSuchElementException.class)
241+
assertThatExceptionOfType(InvalidSelectorException.class)
242242
.isThrownBy(() -> driver.findElements(By.tagName("")));
243243
}
244244

@@ -320,28 +320,28 @@ void testShouldNotFindElementByClassWhenTheNameQueriedIsShorterThanCandidateName
320320
@Test
321321
void testFindingASingleElementByEmptyClassNameShouldThrow() {
322322
driver.get(pages.xhtmlTestPage);
323-
assertThatExceptionOfType(NoSuchElementException.class)
323+
assertThatExceptionOfType(InvalidSelectorException.class)
324324
.isThrownBy(() -> driver.findElement(By.className("")));
325325
}
326326

327327
@Test
328328
void testFindingMultipleElementsByEmptyClassNameShouldThrow() {
329329
driver.get(pages.xhtmlTestPage);
330-
assertThatExceptionOfType(NoSuchElementException.class)
330+
assertThatExceptionOfType(InvalidSelectorException.class)
331331
.isThrownBy(() -> driver.findElements(By.className("")));
332332
}
333333

334334
@Test
335335
void testFindingASingleElementByCompoundClassNameShouldThrow() {
336336
driver.get(pages.xhtmlTestPage);
337-
assertThatExceptionOfType(NoSuchElementException.class)
337+
assertThatExceptionOfType(InvalidSelectorException.class)
338338
.isThrownBy(() -> driver.findElement(By.className("a b")));
339339
}
340340

341341
@Test
342342
void testFindingMultipleElementsByCompoundClassNameShouldThrow() {
343343
driver.get(pages.xhtmlTestPage);
344-
assertThatExceptionOfType(NoSuchElementException.class)
344+
assertThatExceptionOfType(InvalidSelectorException.class)
345345
.isThrownBy(() -> driver.findElements(By.className("a b")));
346346
}
347347

@@ -572,28 +572,28 @@ void testShouldNotFindElementsByCssSelectorWhenThereIsNoSuchElement() {
572572
@Test
573573
void testFindingASingleElementByEmptyCssSelectorShouldThrow() {
574574
driver.get(pages.xhtmlTestPage);
575-
assertThatExceptionOfType(NoSuchElementException.class)
575+
assertThatExceptionOfType(InvalidSelectorException.class)
576576
.isThrownBy(() -> driver.findElement(By.cssSelector("")));
577577
}
578578

579579
@Test
580580
void testFindingMultipleElementsByEmptyCssSelectorShouldThrow() {
581581
driver.get(pages.xhtmlTestPage);
582-
assertThatExceptionOfType(NoSuchElementException.class)
582+
assertThatExceptionOfType(InvalidSelectorException.class)
583583
.isThrownBy(() -> driver.findElements(By.cssSelector("")));
584584
}
585585

586586
@Test
587587
void testFindingASingleElementByInvalidCssSelectorShouldThrow() {
588588
driver.get(pages.xhtmlTestPage);
589-
assertThatExceptionOfType(NoSuchElementException.class)
589+
assertThatExceptionOfType(InvalidSelectorException.class)
590590
.isThrownBy(() -> driver.findElement(By.cssSelector("//a/b/c[@id='1']")));
591591
}
592592

593593
@Test
594594
void testFindingMultipleElementsByInvalidCssSelectorShouldThrow() {
595595
driver.get(pages.xhtmlTestPage);
596-
assertThatExceptionOfType(NoSuchElementException.class)
596+
assertThatExceptionOfType(InvalidSelectorException.class)
597597
.isThrownBy(() -> driver.findElements(By.cssSelector("//a/b/c[@id='1']")));
598598
}
599599

0 commit comments

Comments
 (0)