Skip to content

Commit 4364c1e

Browse files
committed
Updated .NET exception class hierarchy to better accommodate W3C compliant end points
1 parent c5c65e5 commit 4364c1e

File tree

4 files changed

+150
-2
lines changed

4 files changed

+150
-2
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// <copyright file="ElementNotInteractableException.cs" company="WebDriver Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
// </copyright>
18+
19+
using System;
20+
using System.Runtime.Serialization;
21+
22+
namespace OpenQA.Selenium
23+
{
24+
/// <summary>
25+
/// The exception that is thrown when an element is not visible.
26+
/// </summary>
27+
[Serializable]
28+
public class ElementNotInteractableException : InvalidElementStateException
29+
{
30+
/// <summary>
31+
/// Initializes a new instance of the <see cref="ElementNotInteractableException"/> class.
32+
/// </summary>
33+
public ElementNotInteractableException()
34+
: base()
35+
{
36+
}
37+
38+
/// <summary>
39+
/// Initializes a new instance of the <see cref="ElementNotInteractableException"/> class with
40+
/// a specified error message.
41+
/// </summary>
42+
/// <param name="message">The message that describes the error.</param>
43+
public ElementNotInteractableException(string message)
44+
: base(message)
45+
{
46+
}
47+
48+
/// <summary>
49+
/// Initializes a new instance of the <see cref="ElementNotInteractableException"/> class with
50+
/// a specified error message and a reference to the inner exception that is the
51+
/// cause of this exception.
52+
/// </summary>
53+
/// <param name="message">The error message that explains the reason for the exception.</param>
54+
/// <param name="innerException">The exception that is the cause of the current exception,
55+
/// or <see langword="null"/> if no inner exception is specified.</param>
56+
public ElementNotInteractableException(string message, Exception innerException)
57+
: base(message, innerException)
58+
{
59+
}
60+
61+
/// <summary>
62+
/// Initializes a new instance of the <see cref="ElementNotInteractableException"/> class with serialized data.
63+
/// </summary>
64+
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized
65+
/// object data about the exception being thrown.</param>
66+
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual
67+
/// information about the source or destination.</param>
68+
protected ElementNotInteractableException(SerializationInfo info, StreamingContext context)
69+
: base(info, context)
70+
{
71+
}
72+
}
73+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// <copyright file="ElementNotSelectableException.cs" company="WebDriver Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
// </copyright>
18+
19+
using System;
20+
using System.Runtime.Serialization;
21+
22+
namespace OpenQA.Selenium
23+
{
24+
/// <summary>
25+
/// The exception that is thrown when an element is not visible.
26+
/// </summary>
27+
[Serializable]
28+
public class ElementNotSelectableException : InvalidElementStateException
29+
{
30+
/// <summary>
31+
/// Initializes a new instance of the <see cref="ElementNotInteractableException"/> class.
32+
/// </summary>
33+
public ElementNotSelectableException()
34+
: base()
35+
{
36+
}
37+
38+
/// <summary>
39+
/// Initializes a new instance of the <see cref="ElementNotInteractableException"/> class with
40+
/// a specified error message.
41+
/// </summary>
42+
/// <param name="message">The message that describes the error.</param>
43+
public ElementNotSelectableException(string message)
44+
: base(message)
45+
{
46+
}
47+
48+
/// <summary>
49+
/// Initializes a new instance of the <see cref="ElementNotInteractableException"/> class with
50+
/// a specified error message and a reference to the inner exception that is the
51+
/// cause of this exception.
52+
/// </summary>
53+
/// <param name="message">The error message that explains the reason for the exception.</param>
54+
/// <param name="innerException">The exception that is the cause of the current exception,
55+
/// or <see langword="null"/> if no inner exception is specified.</param>
56+
public ElementNotSelectableException(string message, Exception innerException)
57+
: base(message, innerException)
58+
{
59+
}
60+
61+
/// <summary>
62+
/// Initializes a new instance of the <see cref="ElementNotInteractableException"/> class with serialized data.
63+
/// </summary>
64+
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized
65+
/// object data about the exception being thrown.</param>
66+
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual
67+
/// information about the source or destination.</param>
68+
protected ElementNotSelectableException(SerializationInfo info, StreamingContext context)
69+
: base(info, context)
70+
{
71+
}
72+
}
73+
}

dotnet/src/webdriver/ElementNotVisibleException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace OpenQA.Selenium
2525
/// The exception that is thrown when an element is not visible.
2626
/// </summary>
2727
[Serializable]
28-
public class ElementNotVisibleException : WebDriverException
28+
public class ElementNotVisibleException : ElementNotInteractableException
2929
{
3030
/// <summary>
3131
/// Initializes a new instance of the <see cref="ElementNotVisibleException"/> class.

dotnet/src/webdriver/Remote/RemoteWebDriver.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,8 +1380,10 @@ private static void UnpackAndThrowOnError(Response errorResponse)
13801380
case WebDriverResult.ObsoleteElement:
13811381
throw new StaleElementReferenceException(errorMessage);
13821382

1383-
case WebDriverResult.ElementNotDisplayed:
13841383
case WebDriverResult.ElementNotInteractable:
1384+
throw new ElementNotInteractableException(errorMessage);
1385+
1386+
case WebDriverResult.ElementNotDisplayed:
13851387
throw new ElementNotVisibleException(errorMessage);
13861388

13871389
case WebDriverResult.InvalidElementState:

0 commit comments

Comments
 (0)