Hi, I am trying to automate file upload function in our application. The application handles both silverlight drag drop upload and also normal file select dialog upload. I am trying to automate without using silverlight. The code is below.
HtmlInputFile fileUpload = ActiveBrowser.Find.ByName<HtmlInputFile>("documentFileInput");
Assert.IsTrue(fileUpload != null);
fileUpload.Upload("C:\\folder1\\folder2\\worddoc.docx, 6000");
When this code is executed, I see the upload dialog box appears but the file path is not typed in the text box on the dialog, and it closes itself and I get a timeout error at the last line.
Is there any other code that needs to be written here to handle the dialog box and write complete file path in there and to click open button?
Thanks
10 Answers, 1 is accepted
I am still working on the upload dialog handling. I am trying to use other code provided by a user. I am not finding ArtOfTest.WebAii. Win32.Window assembly in webAii framework version 2010.2.830.0 which I installed.
Also from the online help http://www.artoftest.com/support/webaii/topicsindex.aspx if I click on ArtOfTest.WebAii. Win32.Window it says "The resource you are looking for might have been moved or the name must be changed".
What is the assembly that need to be used to handle window and buttons?
This is the code I am trying to use
Window w = WindowManager.FindWindowRecursively(
IntPtr.Zero, "Upload", true, 1000);
w.SetFocus();
w.SetActive();
app.Desktop.KeyBoard.SendString(
"MyFilePath");
ArtOfTest.WebAii.Win32.
Button openButton = new ArtOfTest.WebAii.Win32.Button(w.Handle, "Open", true);
openButton.Click();
The error I get is: The type or namespace name 'Window' could not be found are you missing an assembly reference?
I am not able to use the assembly in version 2010.2.830.0
using
ArtOfTest.WebAii.Win32.Window;
Thanks
Which is the exact browser you are running the test against?
Regards,
Helen
the Telerik team
I am using Internet Explorer 8.
Thanks
Shwetha
Could you please send us a live url of the site using the Upload to examine it locally?
Regards,
Helen
the Telerik team
The site is docs.com. You need to sign in through a facebook account. And you get the upload dialog when you click Add a doc-> Upload a doc.
I am testing on beta version of the site where only developers will have access to. But docs.com should be fine it has the same features. Also it works with both silverlight and non-silverlight. Right now I have the silverlight installed.
Thanks
Shwetha
I also tried the below code. This time, it types the file name I am passing here. But it wont click the open button. After typing the file path and file name, the dialog closes itself without clicking OPEN.
FileUploadDialog fDialog= new FileUploadDialog(Manager.Current.ActiveBrowser, "C:\\FilePath\\FileName.docx", DialogButton.OPEN);
Manager.Current.DialogMonitor.AddDialog(fDialog);
Manager.Current.DialogMonitor.Start();
HtmlInputFile fUpload= ActiveBrowser.Find.ByName<HtmlInputFile>("inputfile");
fUpload.Click();
fDialog.WaitUntilHandled();
Manager.Current.DialogMonitor.Stop();
Thanks
Shwetha
Please try the following code:
Manager.DialogMonitor.AddDialog(
new
FileUploadDialog(ActiveBrowser, @
"YOUR_PATH_TO_THE_DOCUMENT"
, DialogButton.OPEN,
"Choose file to upload"
));
Manager.DialogMonitor.Start();
Pages.SignInDocsForFacebook.DocumentFileInputFile.MouseClick();
ActiveBrowser.WaitUntilReady();
Note that the file upload dialog title may vary. In the above code it is
"Choose file to upload"
.Change it in your test if necessary.
Regards,
Helen
the Telerik team
Yes this should work in Chrome as well.
Regards,
Ivaylo
Telerik
Test Studio Trainings