title: "How to fix 'selenium.JavascriptException: javascript error: Cannot read property 'left' of undefined' error in selenium jenkins
body: <p>I am running my selenium code written in Java on Jenkins server. I used Actions class for mouse hovering. Used Chrome browser. It's working perfectly fine when I run it on my local machine. But not working when I run the same on jenkins. I am getting an error message at the moveToElement function. Error is:</p>
  
  <blockquote>
    <p>org.openqa.selenium.JavascriptException: javascript error: Cannot read
    property 'left' of undefined</p>
  </blockquote>
  
  <p>Following options tried.</p>
  
  <p>1:Using actions class</p>
  
  <pre><code>Actions action = new Actions(driver);
  action.moveToElement(WebElement).build.perform();
  </code></pre>
  
  <p>2:Using javaScript</p>
  
  <pre><code>String strJavaScript = "var element = arguments[0]; var mouseEventObj = document.createEvent('MouseEvents'); mouseEventObj.initEvent( 'mouseover', true, true ); element.dispatchEvent(mouseEventObj);";
          ((JavascriptExecutor) BrowserFunctionality.getBrowser()).executeScript(strJavaScript, linkNameElement);
  </code></pre>
  
  <p>Note: Used scrolltoview as well in javascript</p>
  
  <p>3: Using Robot class</p>
  
  <pre><code>Point coordinates =webElement.getLocation();
           Robot robot = new Robot();
           robot.mouseMove(0,0);
          robot.mouseMove(coordinates.getX(),coordinates.getY()+120);
  </code></pre>
  
  <p>Tried these options with and without below chrome Option:</p>
  
  <pre><code>ChromeOptions options = new ChromeOptions();
  options.setCapability(CapabilityType.HAS_NATIVE_EVENTS,false);
  </code></pre>
  
  <p>Hover it is not working in Jenkins. Any help would be appreciated</p>