2121using OpenQA . Selenium . Internal ;
2222using System ;
2323
24+ #nullable enable
25+
2426namespace OpenQA . Selenium
2527{
2628 /// <summary>
2729 /// Defines the interface through which the user can discover where an element is on the screen.
2830 /// </summary>
29- internal class ElementCoordinates : ICoordinates
31+ internal sealed class ElementCoordinates : ICoordinates
3032 {
31- private WebElement element ;
33+ private readonly WebElement element ;
3234
3335 /// <summary>
3436 /// Initializes a new instance of the <see cref="ElementCoordinates"/> class.
3537 /// </summary>
3638 /// <param name="element">The <see cref="WebElement"/> to be located.</param>
3739 public ElementCoordinates ( WebElement element )
3840 {
39- this . element = element ;
41+ this . element = element ?? throw new ArgumentNullException ( nameof ( element ) ) ;
4042 }
4143
4244 /// <summary>
4345 /// Gets the location of an element in absolute screen coordinates.
4446 /// </summary>
45- public System . Drawing . Point LocationOnScreen
46- {
47- get { throw new NotImplementedException ( ) ; }
48- }
47+ public System . Drawing . Point LocationOnScreen => throw new NotImplementedException ( ) ;
4948
5049 /// <summary>
5150 /// Gets the location of an element relative to the origin of the view port.
5251 /// </summary>
53- public System . Drawing . Point LocationInViewport
54- {
55- get { return this . element . LocationOnScreenOnceScrolledIntoView ; }
56- }
52+ public System . Drawing . Point LocationInViewport => this . element . LocationOnScreenOnceScrolledIntoView ;
5753
5854 /// <summary>
5955 /// Gets the location of an element's position within the HTML DOM.
6056 /// </summary>
61- public System . Drawing . Point LocationInDom
62- {
63- get { return this . element . Location ; }
64- }
57+ public System . Drawing . Point LocationInDom => this . element . Location ;
6558
6659 /// <summary>
6760 /// Gets a locator providing a user-defined location for this element.
@@ -70,17 +63,11 @@ public object AuxiliaryLocator
7063 {
7164 get
7265 {
73- IWebDriverObjectReference elementReference = this . element as IWebDriverObjectReference ;
74- if ( elementReference == null )
75- {
76- return null ;
77- }
78-
7966 // Note that the OSS dialect of the wire protocol for the Actions API
8067 // uses the raw ID of the element, not an element reference. To use this,
8168 // extract the ID using the well-known key to the dictionary for element
8269 // references.
83- return elementReference . ObjectReferenceId ;
70+ return ( ( IWebDriverObjectReference ) this . element ) . ObjectReferenceId ;
8471 }
8572 }
8673 }
0 commit comments