title: CasperJS script not calling a function only when executed from a shell script which itself is executed from Java
body: <p>I have a script written in Casper.js. I am using a Java Process to execute a shell script which executes the Casper script.</p>
  
  <p>Almost all of the Casper script runs when I execute it this way (confirmed by console logs and <code>this.echo()</code> commands) except for one function, and I don't know why. Here's a snippet:</p>
  
  <pre><code>this.then(function() {
              this.click('input[type="type"]');
              this.then(function() {
                  this.page.uploadFile('input[type="type"]', 'picture.jpg');
                  this.then(function() {
                      this.wait(1000);
                      this.then(function() {
                          var test = this.evaluate(function() {
                              return document.getElementById('elementid').value;
                          });
                          this.echo(test);
                          return test;
                      });
  </code></pre>
  
  <p>The function in question that is not being called is the callback function for assigning a value to the variable <code>test</code>. </p>
  
  <p>It works perfectly when I execute the shell script on my computer. This only fails when it is called from my Java program.</p>
  
  <p>Any insight on the matter would be greatly appreciated, thank you!</p>