title: JavaScript Executor working in Google Chrome but not Firefox
body: <p>So I am using Selenium tests to test my website across multiple browsers.</p>
  
  <p>The tests that I made work completely fine for Google Chrome however, it does not work for Firefox.</p>
  
  <pre><code>public class BrowserAutomationTest {
      private final static WebDriver driver = new ChromeDriver();
      private final static Actions builder = new Actions(driver);
      private final static JavascriptExecutor js = (JavascriptExecutor) driver;
  
  
      @BeforeClass
      public static void init() {
          System.setProperty("webdriver.chrome.driver", "chromedriver");
          System.setProperty("webdriver.gecko.driver", "geckodriver");
  
          final ChromeOptions options = new ChromeOptions();
          options.addArguments("disable-infobars");
  
          driver.get("file:/graph.html");
      }
  
  @Test
  private void leftClickAddNodeTest() {
      //add two nodes in different positions by left clicking
      final WebDriverWait wait = new WebDriverWait(driver, 10);
      wait.until(ExpectedConditions.elementToBeClickable(By.className("tour-close-button")));
  driver.findElement(By.className("tour-close-button")).click();
  
  builder.moveByOffset(0, 0)
          .click()
          .moveByOffset(100, 100)
          .click()
          .build()
          .perform();
  
  final ArrayList&lt;Object&gt; jsReturnObject = (ArrayList&lt;Object&gt;) js.executeScript("return sigmaInstance"); // Error is here
  assertTrue(jsReturnObject.size() == 2);
  }
  }
  </code></pre>
  
  <p>So the above code works completely fine with Google Chrome.</p>
  
  <p>However when replacing the Webdriver line to this:</p>
  
  <pre><code>private final static WebDriver driver = new FirefoxDriver();
  </code></pre>
  
  <p>Firefox does load up however when js.executeScript() is called it returns an exception:</p>
  
  <pre><code>org.openqa.selenium.JavascriptException: ReferenceError: sigmaInstance is not defined
  </code></pre>
  
  <p>The strange issue is that this error does not occur in Selenium Google Chrome test. Also, when inserting the JS manually to the Firefox browser, it will work. </p>
  
  <p>What could be the issue? Thanks</p>
  
  <p>EDIT: Full Stack Trace </p>
  
  <pre><code>objc[3179]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/bin/java (0x1088bb4c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10893f4e0). One of the two will be used. Which one is undefined.
  1525869916907   geckodriver INFO    geckodriver 0.20.1
  1525869916913   geckodriver INFO    Listening on 127.0.0.1:22235
  1525869917264   mozrunner::runner   INFO    Running command: "/Applications/Firefox.app/Contents/MacOS/firefox-bin" "-marionette" "-profile" "/var/folders/sn/b7mx42_530v_kx2xqn27d84h0000gn/T/rust_mozprofile.VRXA2ZSTKOIA"
  1525869917876   Marionette  INFO    Enabled via --marionette
  2018-05-09 13:45:18.710 plugin-container[3182:399742] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7c3f, name = 'com.apple.tsm.portname'
  See /usr/include/servers/bootstrap_defs.h for the error codes.
  2018-05-09 13:45:18.859 plugin-container[3182:399742] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7cbb, name = 'com.apple.coredrag'
  See /usr/include/servers/bootstrap_defs.h for the error codes.
  1525869919046   Marionette  INFO    Listening on port 60700
  1525869919134   Marionette  WARN    TLS certificate errors will be ignored for this session
  May 09, 2018 1:45:19 PM org.openqa.selenium.remote.ProtocolHandshake createSession
  INFO: Detected dialect: W3C
  2018-05-09 13:45:19.607 plugin-container[3183:399823] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7c43, name = 'com.apple.tsm.portname'
  See /usr/include/servers/bootstrap_defs.h for the error codes.
  2018-05-09 13:45:19.771 plugin-container[3183:399823] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x190f, name = 'com.apple.coredrag'
  See /usr/include/servers/bootstrap_defs.h for the error codes.
  
  org.openqa.selenium.JavascriptException: ReferenceError: sigmaInstance is not defined
  Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
  System info: host: 'Emans-MBP-2', ip: '2a00:23c4:4a09:b00:6cfa:11:c2f:f577', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.3', java.version: '1.8.0_151'
  Driver info: org.openqa.selenium.firefox.FirefoxDriver
  Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 59.0.3, javascriptEnabled: true, moz:accessibilityChecks: false, moz:headless: false, moz:processID: 3181, moz:profile: /var/folders/sn/b7mx42_530v..., moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: MAC, platformName: MAC, platformVersion: 17.4.0, rotatable: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}}
  Session ID: d2b4c7f5-2951-1047-8f97-4a7640091b09
  
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
      at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
      at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
      at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
      at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
      at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
      at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:482)
      at BrowserAutomationTest.leftClickAddNodeTest(BrowserAutomationTest.java:58)
      at BrowserAutomationTest.testSequence(BrowserAutomationTest.java:35)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
      at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
  
  *** UTM:SVC TimerManager:registerTimer called after profile-before-change notification. Ignoring timer registration for id: telemetry_modules_ping
  </code></pre>