title: Calling DOM objects using Java's ScriptEngine or WebEngine classes
body: <p>Is it possible to modify html elements using the ScriptEngine or WebEngine classes from Java? I've tried the following:</p>
  
  <pre><code>/* theSite is a WebEngine object. Assume the id 'Email' is correct */
  Element email=(Element) theSite.executeScript("document.getElementById('Email');");
  email.setAttribute( "value", "navon.josh" );
  </code></pre>
  
  <p>I saw something like this in an example, but it didn't seem to work. I also tried this:</p>
  
  <pre><code>final ScriptEngineManager manager = new ScriptEngineManager();
  final ScriptEngine engine = manager.getEngineByName( "js" );
  try {
      engine.eval( "document.getElementById( 'Email' ).value = 'navon.josh'" );
  } catch( ScriptException e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>This also didn't work. Is it because the statement isn't linked to the WebEngine?</p>