How to Handle an Upload Dialog via Telerik test studio


How to Handle an Upload Dialog via Telerik Testing Framework


Handling an upload dialog in test automation is quite tricky since the dialog is generated from the browser not the application it self,

In Telerik you can record this function but you cannot see the inline code of the function

Actually its pretty easy,

Here is the code to upload a picture from your telerik automation suite via a upload dialog

eg: picture is in C drive

C:\\mypicture.jpg

Steps

1. Create a variable for the uploaded picture

 var x = new ArtOfTest.WebAii.Win32.Dialogs.FileUploadDialog  
 (ActiveBrowser,"C:\\mypicture.jpg", DialogButton.OPEN);  


2. Initiate the dialog

 Manager.DialogMonitor.Start();  


3. Close the dialog

 Manager.DialogMonitor.AddDialog(x);  


4. Create an object for the browse button

 HtmlInputFile choose = ActiveBrowser.Find.ById<HtmlInputFile>("Id of the browse button");  
         choose.Click();  

5. wait till the upload dialog is handled

 x.WaitUntilHandled(10000);  


Your picture will be uploaded by these 5 simple steps


C# code


 var x = new ArtOfTest.WebAii.Win32.Dialogs.FileUploadDialog  
 (ActiveBrowser,"C:\\mypicture.jpg", DialogButton.OPEN);  
 Manager.DialogMonitor.Start();  
 Manager.DialogMonitor.AddDialog(x);  
 HtmlInputFile choose = ActiveBrowser.Find.ById<HtmlInputFile>("Id of the browse button");  
         choose.Click();  
 x.WaitUntilHandled(10000);  

Comments

Popular posts from this blog

Drag and Drop with Telerik Testing Framework

Sheduling tests - Running Tests From the Command line | Telerik Testing Framework

Using page object model with Telerik Framework