title: How to return value from JavascriptExecutor.executeScript() method in java
body: <p>I have written one method in java file and calling one method which is written in java script file with the help <code>org.openqa.selenium.JavascriptExecutor</code> from that java file method. here is the code snippet:</p>
  
  <pre><code>public void validateFilename() {
      JavascriptExecutor jsExec = (JavascriptExecutor) webDriver;
      jsExec.executeScript("getFileName();");
  }
  
  
  function() {
      window.getFileName = function() {
          var fileName = "sampleFile.txt";
          return fileName;
      }
  };
  </code></pre>
  
  <p>I am able to call method <code>getFileName()</code> from java file but I am able to get the value of file name. If I give <code>alert(fileName)</code> it is showing fileName but not able to return that method in java file. </p>
  
  <p>Is there any way to return the value from js file to java file with the help of API of selenium  <strong>JavascriptExecutor</strong>?</p>