Note that there are some explanatory texts on larger screens.

plurals
  1. POSelenium WebDriver: Java: Mac OS X: how control file upload automation for CuteWebUI_Uploader_Resource from CuteWebUI for ASP.NET
    primarykey
    data
    text
    <p>Selenium-2.37.0 </p> <p>Firefox 24.0 (although have also tried on Chrome)</p> <p>Mac OS X Mountain Lion 10.8.5 </p> <p><strong>Solutions involving Windows, Windows-specific automation tools/libraries or O/S other than Mac OS X are not acceptable answers</strong></p> <p><i>Firstly may I remark that very similar questions have be asked often here on Stackoverflow, I have examined every offered answer, and none of them work for the CuteWebUI_Uploader_Resource AJAX file uploader, as I will illustrate in detail below.</i></p> <p>I have an Enterprise Java web application with data and files and wish to automate mapping and uploading a selected subset of the data and files from that web application against (into) a separate ASP.NET web application, which uses the CuteWebUI toolkit and the CuteWebUI_Uploader_Resource from <a href="http://cutesoft.net" rel="nofollow noreferrer">CuteSoft</a>.</p> <p><strong>At the time of writing the <a href="http://cutesoft.net" rel="nofollow noreferrer">http://cutesoft.net</a> server has been down for some days; Googling gives some CuteSoft forum hits that may help with this problem, but I currently can't access them.</strong></p> <p>Like many file uploaders, the CuteWebUI AJAX file uploader has a Browse button and an Upload button.</p> <p>I want to be able to upload directly into the CuteWebUI AJAX file uploader without using that Browse button (and without having to play any tricks using the Browse dialog on Mac OS X, because the files I wish to upload will not be available to a browser on a local filesystem, but instead are stored on a server accessible to the Java web application via Java, although for testing I can have them on a local filesystem, as shown below).</p> <p>I appreciate that this problem has been answered many times for other file uploaders (see exhaustive list at end of this posting), and the process usually described as a solution for <strong>most</strong> file uploaders is roughly:</p> <ul> <li><p>Identify the INPUT field for the file upload path (sometimes hidden) populated by the Browse button. Sometimes one needs to unhide this using a JavascriptExecutor and ensure it is a text field, then use sendKeys to populate it.</p></li> <li><p>Identify the matching SUBMIT Upload button and click() it.</p></li> </ul> <p><strong>This does not work for the CuteWebUI AJAX file uploader.</strong></p> <p>The system I am targeting does indeed have an INPUT element that by name would suggest it is used to store the file upload path, but in fact when I try it by hand (and examine it using Firebug and Selenium IDE) its value is not populated at all, and instead a completely new temporary table of uploadable files appears.</p> <p>The following HTML shows the situation before any file browse or upload has been attempted. I have omitted some style markup and some irrelevant values:</p> <pre><code>&lt;script src="/CuteWebUI_Uploader_Resource.axd?type=script&amp;amp;_ver=" type="text/javascript"&gt;&lt;/script&gt; &lt;input type="hidden" autocomplete="off" name="fileuploader_433" id="fileuploader_433" isuploaderfield="1" value=""&gt; &lt;button&gt;Browse&lt;/button&gt; &lt;span style="display: none;"&gt;&lt;/span&gt; &lt;button style="display: none;"&gt;Cancel upload&lt;/button&gt; &lt;img showprogressbar="1" canceluploadmsg="Cancel upload" resourcehandler="/CuteWebUI_Uploader_Resource.axd" uploadtype="Auto" cancelallmsg="Cancel all Uploads" uploadurl="/Handlers/UploadHandler.ashx" insertext="Upload a file" uploadingmsg="Uploading.." filetoolargemsg=".." maxfileslimitmsg=".." inserttext="Browse" numfilesshowcancelall="2147483647" barstyle="Continuous" showprogressinfo="0" multiplefilesupload="0" windowsdialoglimitmsg=".." manualstartupload="1" extensions="" contextvalue=".." onerror="this.onload()" onload="this.style.display=&amp;quot;none&amp;quot; ; if(!window.CuteWebUI_AjaxUploader_Initialize){ var xh=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHttp'); xh.open('GET','/CuteWebUI_Uploader_Resource.axd?type=script&amp;amp;amp;_ver=',false);xh.send('');eval(xh.responseText)}CuteWebUI_AjaxUploader_Initialize(this.id);" src="/CuteWebUI_Uploader_Resource.axd?type=file&amp;amp;file=continuous.gif" pageupload="1" namespace="CuteWebUI" uniqueid="fileuploader_433" id="fileuploader_433_Loader_unique" style="display: none;"&gt; &lt;button onclick="return submitbutton_click('433')" class="submitbutton" name="SubmitButton" id="SubmitButton"&gt;Upload&lt;/button&gt; </code></pre> <p>The following Selenium in Java correctly unhides and populates the fileuploader_433 INPUT field, but on executing the click() on the submit I still get a popup window asserting I have to use the browse button with the message "Please use browse for file upload":</p> <pre><code> String name_fileuploader = "fileuploader_434"; JavascriptExecutor jse = (JavascriptExecutor) driver; jse.executeScript("document.getElementsByName('" + name_fileuploader + "')[0].setAttribute('type', 'text');"); WebElement element_uploader = driver.findElement(By.xpath("//input[@name='" + name_fileuploader + "']")); element_uploader.clear(); String filepath="/path/to/file.pdf"; element_uploader.sendKeys(filepath); driver.findElement(By.xpath("(//button[@id='SubmitButton'])[2]")).click(); </code></pre> <p>Firebug confirms that even if you do it by hand, that INPUT field is never used ! Instead, a new file queue table appears:</p> <pre><code>&lt;script src="/CuteWebUI_Uploader_Resource.axd?type=script&amp;amp;_ver=" type="text/javascript"&gt;&lt;/script&gt; &lt;input type="hidden" autocomplete="off" name="fileuploader_434" id="fileuploader_434" isuploaderfield="1" value=""&gt; &lt;button&gt;Browse&lt;/button&gt; &lt;table .. class="AjaxUploaderQueueTable"&gt; &lt;tbody&gt; &lt;tr class="AjaxUploaderQueueTableRow"&gt; &lt;td&gt; &lt;img src="/CuteWebUI_Uploader_Resource.axd?type=file&amp;amp;file=circle.png&amp;amp;_ver=null" title=""&gt; &lt;/td&gt; &lt;td&gt;file.pdf&lt;/td&gt;&lt;td&gt; &lt;img src="/CuteWebUI_Uploader_Resource.axd?type=file&amp;amp;file=stop.png&amp;amp;_ver=null" title="Remove" style="cursor: pointer;"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;span style="display: none;"&gt;&lt;/span&gt; &lt;button style="display: none;"&gt;Cancel upload&lt;/button&gt; &lt;img showprogressbar="1" canceluploadmsg="Cancel upload" .. resourcehandler="/CuteWebUI_Uploader_Resource.axd" uploadtype="Auto" cancelallmsg="Cancel all Uploads" uploadurl="/Handlers/UploadHandler.ashx" [snip] onerror="this.onload()" onload="this.style.display=&amp;quot;none&amp;quot; ; if(!window.CuteWebUI_AjaxUploader_Initialize){var xh=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHttp');xh.open('GET','/CuteWebUI_Uploader_Resource.axd?type=script&amp;amp;amp;_ver=',false);xh.send('');eval(xh.responseText)}CuteWebUI_AjaxUploader_Initialize(this.id);" src="/CuteWebUI_Uploader_Resource.axd?type=file&amp;amp;file=continuous.gif" pageupload="1" namespace="CuteWebUI" uniqueid="fileuploader_434" id="fileuploader_434_Loader_unique" style="display: none;"&gt; &lt;button onclick="return submitbutton_click('434')" class="submitbutton" name="SubmitButton" id="SubmitButton"&gt;Upload&lt;/button&gt; </code></pre> <p>Please note that:</p> <ul> <li><p>the hidden INPUT element is never populated with a file path value !</p></li> <li><p>instead, the string file.pdf <strong>without the full file path</strong> appears in a new TABLE with class="AjaxUploaderQueueTable" below the Browse button.</p></li> </ul> <p>That inserted AjaxUploaderQueueTable is clearly only cosmetic; it seems that the filepath selected during the Browse operation is stored server-side. I have searched for the full filepath after selecting with the Browse button using Firebug and it is not present in the page.</p> <p><em>I am open - for the sake of testing only - to suggestions that instead involve tricks manipulating the Browse dialog in Mac OS X, but that approach does not meet my eventual requirements, because I can't rely on that approach for the final task of uploading many files from an Enterprise Java web application into the targeted ASP.NET web application. I must side-step the Browse dialog completely.</em></p> <h2>Background research</h2> <p>All of the following have related questions and answers but none of these solve the problem for the CuteWebUI AJAX file uploader:</p> <p><a href="https://stackoverflow.com/questions/11858366/how-to-type-some-text-in-hidden-field-in-webdriver">How to type some text in hidden field in Selenium WebDriver using Java</a></p> <p><a href="https://stackoverflow.com/questions/11256732/how-to-handle-windows-file-upload-using-selenium-webdriver">How to handle windows file upload using Selenium WebDriver?</a></p> <p><a href="https://stackoverflow.com/questions/6101461/selenium-2-0-element-is-not-currently-visible">How to force Selenium WebDriver to click on element which is not currently visible?</a></p> <p><a href="https://stackoverflow.com/questions/13963738/how-does-selenium-webdriver-upload-files-to-the-browser">how does selenium webdriver upload files to the browser?</a></p> <p><a href="https://stackoverflow.com/questions/6128208/how-to-deal-with-file-uploading-in-test-automation-using-selenium-or-webdriver">How to deal with file uploading in test automation using selenium or webdriver</a></p> <p><a href="https://stackoverflow.com/questions/18886970/selenium-webdriver-upload-file-sendkeys-dont-work">https://stackoverflow.com/questions/18886970/selenium-webdriver-upload-file-sendkeys-dont-work</a></p> <p><a href="https://stackoverflow.com/questions/5610256/file-upload-using-selenium-webdriver-and-java">File Upload using Selenium WebDriver and Java</a></p> <p><a href="https://stackoverflow.com/questions/10340709/how-to-handle-with-uploading-files-from-modal-window-selenium-webdriver-java">How to handle with uploading files from modal window Selenium WebDriver Java</a></p> <p><a href="https://stackoverflow.com/questions/14939298/handling-a-popup-window-using-selenium">Handling a popup window using selenium</a></p> <p><a href="http://selenium.10932.n7.nabble.com/Handling-browser-pop-up-dialog-to-upload-a-file-td29153.html" rel="nofollow noreferrer">http://selenium.10932.n7.nabble.com/Handling-browser-pop-up-dialog-to-upload-a-file-td29153.html</a></p> <p>This probably relevant forum link from CuteSoft is down: </p> <p><a href="http://cutesoft.net/tags/ajaxuploader/default.aspx?PageIndex=2" rel="nofollow noreferrer">Jul 24, 2012 - Hi,I'm doing automated testing for my web system using selenium webdriver, the problem is that I can't interact with ajaxuploader component</a></p> <p>And a WebDriver forum posting with the INPUT unhide trick: <a href="https://groups.google.com/forum/#!topic/webdriver/JAXC_qEbQvI" rel="nofollow noreferrer">https://groups.google.com/forum/#!topic/webdriver/JAXC_qEbQvI</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload