Selenium WebDriver: Java: Mac OS X: how control file upload automation for CuteWebUI_Uploader_Resource from CuteWebUI for ASP.NET Selenium WebDriver: Java: Mac OS X: how control file upload automation for CuteWebUI_Uploader_Resource from CuteWebUI for ASP.NET selenium selenium

Selenium WebDriver: Java: Mac OS X: how control file upload automation for CuteWebUI_Uploader_Resource from CuteWebUI for ASP.NET


I've found a solution for this; it comes with some caveats but it works for my situation. Hopefully it will help you too.

The biggest caveat is that I only know that it works with the current version of AjaxUploader as downloaded today. I'd been using an older version that worked differently; I can't specify a version number since CuteSoft seem pathologically inclined to make the version numbers of AjaxUploader almost impossible to figure out. I can't find a version number for the current version OR the older one that I was using.

The other caveat is that it relies on there only being one AjaxUploader control on the page at a time. It appears that AjaxUploader DOES create an <input type='file'> element, but it's left dangling in a div at the top of the <body> tag, without any id or name attribute or anything else to link it to a particular uploader. I'm not sure what AjaxUploader does when more than one of it are present: maybe it creates multiple file inputs and tracks which is which by javascript; maybe it shares one. For my situation I didn't need to solve that part so I didn't try it.

Anyway, the trick is to find the file input as follows:

webDriver.findElements(By.cssSelector("body > div > input[type='file']")).get(0).sendKeys(fileName);

Note that the selector here has nothing to do with the ID or any other characteristics of the particular upload button you're using. It's just "the first file input inside a div directly inside the body tag". That's where AjaxUploader inserts its file input.

There appears to be no need to interact with any of the rest of the UI, including the Browse button: sendKeysing the filename to the right file input causes the upload to begin immediately. (This is an edit; I originally thought that clicking the button was necessary too but it doesn't seem to be)

Note that to make sure the timing of your test works correctly, you probably want to follow this click up with a wait operation that waits until the file has finished uploading (eg by waiting for the HTML that the AjaxUploader inserts after uploading is complete) before proceeding to whatever you want to do next.