title: Executing Javascript elementFromPoint through Selenium driver
body: <p>I am trying to implement an "object picker" to my Selenium based framework as is common on most commercial automation tools. To do this I am using a Javascript command to find the element at the mouse location, but I am not getting the element I expect.</p>
  
  <p>If I am using ChromeDriver or InternetExplorerDriver the script always returns the header object. No matter what webpage I look at or the position of the mouse. Although it sounds like the script is taking the coordinates 0, 0 instead of the mouse position I have confirmed that Cursor.Position is sending the correct values.</p>
  
  <p>If I am using FirefoxDriver I get an exception:</p>
  
  <pre><code>"Argument 1 of Document.elementFromPoint is not a finite floating-point value. (UnexpectedJavaScriptError)"
  </code></pre>
  
  <p>Can anyone see what I am doing wrong?</p>
  
  <pre><code>    private void OnHovering()
      {
          if (Control.ModifierKeys == System.Windows.Forms.Keys.Control)
          {
              IWebElement ele = null;
              try
              {
                  // Find the element at the mouse position
                  if (driver is IJavaScriptExecutor)
                      ele = (IWebElement)((IJavaScriptExecutor)driver).ExecuteScript(
                          "return document.elementFromPoint(arguments[0], arguments[1])", 
                          new int[] { Cursor.Position.X, Cursor.Position.Y });
  
                  // Select the element found
                  if (ele != null)
                      SelectElement(ele);
              }
              catch (Exception) { }
          }
      }
  </code></pre>
  
  <p>Thanks!</p>