title: Need help for webdriver and Javascript for a hidden File upload element
body: <p>I am trying to automate a file upload scenario in a client web application. The code of the entire file upload form looks like this </p>
  
  <pre><code>&lt;td valign="top"&gt;
      &lt;iframe id="batchLoad:inputFile:uploadFrame" class="iceInpFile" width="600px" scrolling="no" height="30px"             frameborder="0" title="Input File Frame" style="border-collapse:collapse; border-spacing:0px; padding:0px;" src="/hip-webapp/block/resource/LTExMzg4MjQzMTY=/" name="batchLoad:inputFile:uploadFrame" marginwidth="0"       marginheight="0" allowtransparency="true"&gt;
          &lt;html style="overflow:hidden;"&gt;
              &lt;head&gt;
                  &lt;body style="background-color:transparent; overflow:hidden"&gt;
                      &lt;form id="fileUploadForm" enctype="multipart/form-data" action="/hip-webap/uploadHtml" method="post"&gt;
                          &lt;input type="hidden" value="batchLoad:inputFile" name="ice.component"&gt;
                          &lt;input type="hidden" value="3" name="ice.view"&gt;
                          &lt;input class="iceInpFileTxt" type="file" size="35" name="upload"&gt;
                          &lt;input class="iceInpFileBtn" type="submit" value="Upload"&gt;
                      &lt;/form&gt;
                  &lt;/body&gt;
          &lt;/html&gt;
      &lt;/iframe&gt;
      &lt;br&gt;
      &lt;span id="batchLoad:j_id537"&gt;&lt;/span&gt;
  &lt;/td&gt;
  </code></pre>
  
  <p>I tried with the conventional File upload method, but that did not work.</p>
  
  <p>Please refer: <a href="https://stackoverflow.com/questions/17668826/selenium-webdriver-file-upload-error-element-iceinputfile">Selenium Webdriver FIle Upload error element ice:inputFile</a></p>
  
  <p>I am not much familiar with Javascript hence I think I am doing some syntax error.
  What I tried is:</p>
  
  <pre><code>String ew = (String)js.executeScript("document.getElementByXPath('//form[@id='fileUploadForm']/input[3]')");
  String j = "arguments[0].style.height='auto'; arguments[0].style.visibility='visible';";
  js.executeScript(j, ew);
  </code></pre>
  
  <p>Got the hint from here <a href="https://stackoverflow.com/questions/12040615/selenium-webdriver-clicking-on-hidden-element">Selenium WebDriver clicking on hidden element</a>.</p>
  
  <p>But now I am getting syntax error. I got the XPath using Selenium IDE. I have also tried this, but that did not work either.</p>
  
  <pre><code>((JavascriptExecutor)driver).executeScript("document.getElementByClassName(iceInpFileTxt).style.visibility = 'visible';");
  ((JavascriptExecutor)driver).executeScript("document.getElementByClassName('iceInpFileTxt').value = 'D:\\AD\\Prac\\Prac\\002 EditPrac Add Person Error.xml-revHEAD.svn000.tmp.xml'");
  </code></pre>
  
  <p>Please advice.</p>