I looked through tons of upload threads but was not able to find the answer. Can someone please help. I have a browse button that lets me pick files to upload from my pc to the website. Here is the html code where the browse button is at on the website:
<input id="contentFileInput" width="110" type="file" height="30" name="contentFileInput" style="display: none;">
<object id="contentFileInputUploader" width="110" height="30" type="application/x-shockwave-flash" data="../../Scripts/uploadify.swf" style="visibility: visible;">
<param name="quality" value="high">
<param name="wmode" value="opaque">
<param name="allowScriptAccess" value="sameDomain">
<param name="flashvars" value="uploadifyID=contentFileInput&pagepath=/Content/&script=/Content/AsyncUpload/&folder=&width=110&height=30&wmode=opaque&method=POST&queueSizeLimit=999&simUploadLimit=1&fileDesc=*.mpeg;*.mpg;*.avi;*.flv;*.mov;*.mp4;*.wmv&fileExt=*.mpeg;*.mpg;*.avi;*.flv;*.mov;*.mp4;*.wmv&auto=true&sizeLimit=1258291200&fileDataName=Filedata">
</object>
I tried: WebElement elem = driver.findElement(By.xpath("//*[@id='contentFileInputUploader']")); elem.sendKeys("C:///video/file.flv");
but it doesn't do anything. I got the xpath from firepath in ff when I hover the browse button. Can someone please suggest what I can do? I am really stuck. Thanks in advance.
type | contentFileInput | C:\\video\\file.flv
. If it will work, then probably you should use JavaScript to type your value:((JavascriptExecutor) driver).executeScript("arguments[0].value = 'C:\\video\\file.flv';", elem);
- Aleh Douhitype | contentFileInput | C:\\video\\file.flv
? And I recommend not to use xpath. In your case it would be better to use find by Id: driver.FindElement(By.Id("contentFileInput")); - Aleh Douhi