21
21
using OpenQA . Selenium . Internal ;
22
22
using System ;
23
23
24
+ #nullable enable
25
+
24
26
namespace OpenQA . Selenium
25
27
{
26
28
/// <summary>
27
29
/// Defines the interface through which the user can discover where an element is on the screen.
28
30
/// </summary>
29
- internal class ElementCoordinates : ICoordinates
31
+ internal sealed class ElementCoordinates : ICoordinates
30
32
{
31
- private WebElement element ;
33
+ private readonly WebElement element ;
32
34
33
35
/// <summary>
34
36
/// Initializes a new instance of the <see cref="ElementCoordinates"/> class.
35
37
/// </summary>
36
38
/// <param name="element">The <see cref="WebElement"/> to be located.</param>
37
39
public ElementCoordinates ( WebElement element )
38
40
{
39
- this . element = element ;
41
+ this . element = element ?? throw new ArgumentNullException ( nameof ( element ) ) ;
40
42
}
41
43
42
44
/// <summary>
43
45
/// Gets the location of an element in absolute screen coordinates.
44
46
/// </summary>
45
- public System . Drawing . Point LocationOnScreen
46
- {
47
- get { throw new NotImplementedException ( ) ; }
48
- }
47
+ public System . Drawing . Point LocationOnScreen => throw new NotImplementedException ( ) ;
49
48
50
49
/// <summary>
51
50
/// Gets the location of an element relative to the origin of the view port.
52
51
/// </summary>
53
- public System . Drawing . Point LocationInViewport
54
- {
55
- get { return this . element . LocationOnScreenOnceScrolledIntoView ; }
56
- }
52
+ public System . Drawing . Point LocationInViewport => this . element . LocationOnScreenOnceScrolledIntoView ;
57
53
58
54
/// <summary>
59
55
/// Gets the location of an element's position within the HTML DOM.
60
56
/// </summary>
61
- public System . Drawing . Point LocationInDom
62
- {
63
- get { return this . element . Location ; }
64
- }
57
+ public System . Drawing . Point LocationInDom => this . element . Location ;
65
58
66
59
/// <summary>
67
60
/// Gets a locator providing a user-defined location for this element.
@@ -70,17 +63,11 @@ public object AuxiliaryLocator
70
63
{
71
64
get
72
65
{
73
- IWebDriverObjectReference elementReference = this . element as IWebDriverObjectReference ;
74
- if ( elementReference == null )
75
- {
76
- return null ;
77
- }
78
-
79
66
// Note that the OSS dialect of the wire protocol for the Actions API
80
67
// uses the raw ID of the element, not an element reference. To use this,
81
68
// extract the ID using the well-known key to the dictionary for element
82
69
// references.
83
- return elementReference . ObjectReferenceId ;
70
+ return ( ( IWebDriverObjectReference ) this . element ) . ObjectReferenceId ;
84
71
}
85
72
}
86
73
}
0 commit comments