We are having an issue with automated testing of file upload file (this works perfectly in Windows XP). We are using
asp
:FileUpload control. In IE, the windows explorer dialog opens up to select the file and then it hangs. In Firefox, the dialog doesn't open at all.
Is this issue already noted? Is there any workaround? Is the support for Windows 7 available now?
Cheers,
Souvika
12 Answers, 1 is accepted
I've managed to confirm this problem and I've logged it under:
Bug 108981: Upload dialog handler isn't automatically added for ASP: FileUpload control
as you can tell by the name of the bug, a Dialog Handler should automatically be added but this doesn't happen. You can still get this to work by manually adding an Upload Dialog Handler from the GUI (attachment 1). I've also attached a sample test - you might need to upgrade to the lastest WebUI Test Studio version (1421) in order to open it.
Thank you for your feedback, hope to hear from you soon!
Greetings,
Thanks for the info. We are using the Webaii framework and not the WebUI Test Studio. What do we need to need add for that?
Cheers,
Souvika
this is the code from my test:
FileUploadDialog fileDialog =
new
FileUploadDialog(ActiveBrowser,
"Desktop"
, DialogButton.CANCEL);
Manager.DialogMonitor.AddDialog(fileDialog);
ActiveBrowser.NavigateTo(
"http://www.dotnetfunda.com/tutorials/controls/fileupload.aspx"
);
Find.ByExpression<HtmlInputFile>(
"id=PlaceHolderForContents_FileUpload1"
).Click(
false
);
fileDialog.WaitUntilHandled(5000);
With this code I successfully handled the UploadDialog from this page:
http://www.dotnetfunda.com/tutorials/controls/fileupload.aspx
This code should also work for you, give it a try.
Let me know how it goes!
Best wishes,
Bug 108981: Upload dialog handler isn't automatically added for ASP: FileUpload control
hasn't been resolved yet. However, I would like to point out that you can successfully handle Upload dialogs now. The problem is only that the Handle step isn't added for you automatically.
All the best,
Stoich
the Telerik team
Register Today!
Any update about this bug? I tired with latest Testing Framework version (Testing.Framework.2011.2.1305), but still now luck.....
Thanks
Ganga S
When our software developer went to investigate the problem he was unable to reproduce it. The bug was closed on July 5, 2011 with that status.
if you continue to have a problem can you show us how to reproduce it?
Cody
the Telerik team
Hi Cody,
Thanks for the quick response.
I am seeing a different behaviour, if I execute the File Upload operation on;
1) Windows XP and IE 8: The execution was successful as expected. The file is selected and automatically opened.
2) Windows 7 (Enterprise Edition) and IE 8: The execution is not successful. The actual behaviour was; The “Browse” button was clicked successfully, but didn’t chose the file to be opened automatically as expected. (please refer the attached screen shots)
Testing Framework version: Telerik.Testing.Framework.2011.2.1305
This is my code for file upload:
public class FileUpload : BaseControl
{
protected HtmlInputFile control = null;
public FileUpload(Element element)
: base(element)
{
this.control = element.As<HtmlInputFile>();
}
public virtual void SetValue(string value)
{
if (!GetEnabled())
throw new ApplicationException("Control is not enabled for input.");
UploadFile(value);
}
protected virtual void UploadFile(string filePath)
{
// Validation
if (String.IsNullOrEmpty(filePath))
throw new ArgumentNullException("File", "Path to File to be uploaded has not been supplied.");
if (!File.Exists(filePath))
throw new FileNotFoundException(String.Format("File \"{0}\" does not appear to exist.", filePath));
// Set the file path and upload
control.Upload(filePath, 30000); [Failing at this line...., the browser button was clicked and I am getting an error “Unexpected dialog encountered. Closing the dialog, and halting execution”]
}
}
Thanks
Ganga S
Near the beginning of your test please try turning off our Unexpected Dialog Handler feature:
Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
Cody
the Telerik team
I have tried this code also, but still same......
Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
Thanks
Ganga S
I don't know what the problem could be. I verified it works as expected on Win 7 with IE8 using this code:
[TestMethod]
public
void
SampleWebAiiTest()
{
Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
// Launch a browser instance
Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
// The active browser
ActiveBrowser.NavigateTo(
"http://cgi-lib.berkeley.edu/ex/fup.html"
);
// Find the google search box and set it to "Telerik";
HtmlInputFile input = Find.ByName<HtmlInputFile>(
"upfile"
);
input.Upload(@
"c:\temp\file.txt"
, 5000);
}
I don't really know how to use your code sample. Can you send me a complete test that I can load and execute here that reproduces this problem? I can then study it to figure out the cause of the unexpected failure. Regards,
Cody
the Telerik team
Hi Cody,
thanks for the test code.... Its work on Windows 7 and IE 8. So the issue is not related to OS or web browser.
Some issue in my code, but strange. I need bit more time to debug the code. I will update the status based on my test;
Thanks
Ganga S