title: Selenium WD NullPointerException while executing simple JS code
body: <p>Spent 1 day on finding the solution to the following problem:</p>
  
  <p>Can't execute even simple js code using selenium WD. It always returns NullPointerException. Already read tonns of answers but still can't find the reason. The code below is the code after 1 day investigation (I just have tried everything):</p>
  
  <pre><code>WebDriver driver2;
  JavascriptExecutor js = (JavascriptExecutor)driver2;
  driver.get(baseUrl+ "/");
  js.executeScript("return showAlert()");
  </code></pre>
  
  <p>Here is the original code that is not working as well:</p>
  
  <pre><code>    public class DPT_class {
        private WebDriver driver;
  
        @Before
        driver = new FirefoxDriver();
        JavascriptExecutor js = (JavascriptExecutor) driver;
  
        @Test
        //some testing code here
        driver.get(baseUrl+ "/");
        js.executeScript("return showAlert()");
  }
  </code></pre>
  
  <p>the same thing for any other js code such as alert(document.title) with and without return and quotes.
  *baseUrl is predefined of course.</p>
  
  <p>Thanks!</p>