Skip to content

Commit b4330a4

Browse files
committed
Correcting error handling in .NET finding of elements
This commit removes the `IllegalLocatorException`. This exception was only thrown when finding by class name where the class name contained whitespace. It is redundant, and now `InvalidSelectorException` is thrown in its place. This commit also corrects the element finding tests to expect the proper `InvalidSelectorException` when finding by tag name, where the tag name provided is an empty string.
1 parent 19f5284 commit b4330a4

File tree

3 files changed

+4
-80
lines changed

3 files changed

+4
-80
lines changed

dotnet/src/webdriver/IllegalLocatorException.cs

Lines changed: 0 additions & 75 deletions
This file was deleted.

dotnet/src/webdriver/WebDriver.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@
180180
<Compile Include="IHasInputDevices.cs" />
181181
<Compile Include="IJavascriptExecutor.cs" />
182182
<Compile Include="IKeyboard.cs" />
183-
<Compile Include="IllegalLocatorException.cs" />
184183
<Compile Include="ILocatable.cs" />
185184
<Compile Include="IMouse.cs" />
186185
<Compile Include="INavigation.cs" />

dotnet/test/common/ElementFindingTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,14 @@ public void ShouldNotBeAbleToLocateByTagNameMultipleElementsThatDoNotExist()
189189
public void FindingASingleElementByEmptyTagNameShouldThrow()
190190
{
191191
driver.Url = formsPage;
192-
Assert.Throws<NoSuchElementException>(() => driver.FindElement(By.TagName("")));
192+
Assert.Throws<InvalidSelectorException>(() => driver.FindElement(By.TagName("")));
193193
}
194194

195195
[Test]
196196
public void FindingMultipleElementsByEmptyTagNameShouldThrow()
197197
{
198198
driver.Url = formsPage;
199-
Assert.Throws<NoSuchElementException>(() => driver.FindElements(By.TagName("")));;
199+
Assert.Throws<InvalidSelectorException>(() => driver.FindElements(By.TagName("")));;
200200
}
201201

202202
[Test]
@@ -305,7 +305,7 @@ public void FindingMultipleElementsByEmptyClassNameShouldThrow()
305305
public void FindingASingleElementByCompoundClassNameShouldThrow()
306306
{
307307
driver.Url = xhtmlTestPage;
308-
Assert.Throws<IllegalLocatorException>(() => driver.FindElement(By.ClassName("a b")));
308+
Assert.Throws<InvalidSelectorException>(() => driver.FindElement(By.ClassName("a b")));
309309
}
310310

311311
[Test]
@@ -314,7 +314,7 @@ public void FindingASingleElementByCompoundClassNameShouldThrow()
314314
public void FindingMultipleElementsByCompoundClassNameShouldThrow()
315315
{
316316
driver.Url = xhtmlTestPage;
317-
Assert.Throws<IllegalLocatorException>(() => driver.FindElements(By.ClassName("a b")));
317+
Assert.Throws<InvalidSelectorException>(() => driver.FindElements(By.ClassName("a b")));
318318
}
319319

320320
[Test]

0 commit comments

Comments
 (0)