This is a migrated thread and some comments may be shown as answers.
Open file dialog handling
8 Answers 163 Views
This is a migrated thread and some comments may be shown as answers.
Andrey Cherepakha
Top achievements
Rank 1
Andrey Cherepakha asked on 27 Feb 2012, 04:18 PM
Hello!

I have just migrated our solution to the 2011.2.1413.0 version and faced with the Open file dialog handling issue.

I have the code which works perfect with 2011.1.712.0 version.

 

 

 

var _fileUploadDlg = new FileUploadDialog(WebAii.Manager.ActiveBrowser,
   "fileName",
   DialogButton.OPEN,
   "Open");
WebAii.Manager.DialogMonitor.AddDialog(_fileUploadDlg);
WebAii.Manager.DialogMonitor.Start();
// click on some element to open dialog
_fileUploadDlg.WaitUntilHandled(30000);
WebAii.Manager.DialogMonitor.Stop();
WebAii.Manager.DialogMonitor.RemoveDialog(_fileUploadDlg);

With new 2011.2.1413.0 version the Open file dialog is appeared but the file is not selected. I have the error:

Message
System.TimeoutException : Timed out waiting '30000' msec. for any dialog to be handled '1'
Stack Trace
   at ArtOfTest.WebAii.Win32.Dialogs.BaseDialog.WaitUntilAnyHandled(IEnumerable`1 dialogs, Int32 handleCount, Int64 timeoutMilliseconds, Boolean resetHandleCount)
   at ArtOfTest.WebAii.Win32.Dialogs.BaseDialog.WaitUntilHandled(Int32 handleCount, Int32 timeout, Boolean resetHandleCount)
   at ArtOfTest.WebAii.Win32.Dialogs.BaseDialog.WaitUntilHandled(Int32 timeout)
...

Was the dialog handling approach changed? May be it is somehow related to the reported defect concerning ConfirmDialog and AlertDialog http://www.telerik.com/support/pits.aspx#/public/test-studio/9855  ?

Look forward to your advice.

Thanks.


OS Name Microsoft Windows XP Professional
Version 5.1.2600 Service Pack 3 Build 2600
IE Version 8.0.6001.18702

8 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 27 Feb 2012, 06:38 PM
Hello Andrey,

Use the following code to handle an Upload dialog. It worked perfectly for me in all four browsers:

Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
Manager.LaunchNewBrowser(BrowserType.FireFox);
ActiveBrowser.NavigateTo("http://encodable.com/uploaddemo/");
 
FileUploadDialog x = new FileUploadDialog(ActiveBrowser, @"C:\test.txt", DialogButton.OPEN);
Manager.DialogMonitor.Start();
Manager.DialogMonitor.AddDialog(x);
 
HtmlInputFile choose = Find.ById<HtmlInputFile>("uploadname1");
choose.MouseClick(MouseClickType.LeftDoubleClick);
 
x.WaitUntilHandled(10000);
ActiveBrowser.RefreshDomTree();
 
HtmlInputButton button = Find.ById<HtmlInputButton>("uploadbutton");
button.Click();
 
System.Threading.Thread.Sleep(3000);
 
Manager.DialogMonitor.Stop();
Manager.DialogMonitor.RemoveDialog(x);


Kind regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Andrey Cherepakha
Top achievements
Rank 1
answered on 28 Feb 2012, 09:58 AM
Hello, Anthony!

Thank you for your answer. I tried your code with my application and also I tried your code as is.  I am sorry, but it does not work.

I still have the error:

System.TimeoutException: Timed out waiting '10000' msec. for any dialog to be handled '1'
at ArtOfTest.WebAii.Win32.Dialogs.BaseDialog.WaitUntilAnyHandled(IEnumerable`1 dialogs, Int32 handleCount, Int64 timeoutMilliseconds, Boolean resetHandleCount)
at ArtOfTest.WebAii.Win32.Dialogs.BaseDialog.WaitUntilHandled(Int32 handleCount, Int32 timeout, Boolean resetHandleCount)
at ArtOfTest.WebAii.Win32.Dialogs.BaseDialog.WaitUntilHandled(Int32 timeout)
...

Should I mention that I automate Silverlight (4) application?

WebAii 2011.2.1413.0
OS Name Microsoft Windows XP Professional
Version 5.1.2600 Service Pack 3 Build 2600
IE Version 8.0.6001.18702
0
Anthony
Telerik team
answered on 28 Feb 2012, 07:27 PM
Hello Andrey,

To continue troubleshooting I'll need the complete code that demonstrates the issue against a public site. The code I provided worked in version 2011.2.1413 using Windows XP, 7, Server 2008, and with IE 8 and 9.

As a work-around in the meantime you can use Blind Keyboard Typing and code to press the Enter key. 

Regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Andrey Cherepakha
Top achievements
Rank 1
answered on 01 Mar 2012, 10:05 AM
Hello, Anthony!

Thanks for workaround. It works.

But I am still woundering why Manager.DialogMonitor does not work on my side. As for code and publiс site - I just used the code provided by you which test http://encodable.com/uploaddemo/. It does not work on my side as well.

Should I provide any other information to solve the issue?

Thanks.
0
Anthony
Telerik team
answered on 02 Mar 2012, 12:50 AM
Hello Andrey,

To further diagnose this I will need more information. How are you executing the test? Does the issue replicate on another machine with the same settings? A screen recording may help shed some light on what's happening. Jing is free and works well.

Regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Andrey Cherepakha
Top achievements
Rank 1
answered on 02 Mar 2012, 10:12 AM
Hello Anthony.

I continue investigation and have some information for you.

I have created the new solution from scratch and used the code provided by you. I am attaching the solution. It contains MS Test project and Console application.

I run test under Visual Studio 2008 using ReSharper runner. The test failed. I am attaching the screen shot.
JetBrains ReSharper 5.1 C# Edition Build 5.1.3000.12

Since my main test solution is run with Gallio runner I also run the test with Gallio Icarus runner. The test failed. I am attaching the screen shot.
http://www.gallio.org/ Gallio version 3.3.454.0

After that I run FileUploadDialogConsole.exe and everything works fine !!!

I hope this information will be helpful. Please, let me know if I can help with any other actions. 
0
Accepted
Anthony
Telerik team
answered on 02 Mar 2012, 03:46 PM
Hello Andrey,

I am sorry but ReSharper is untested and unsupported. Instead we have our own unit test runner as a part of JustCode you can use instead.

All the best,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Andrey Cherepakha
Top achievements
Rank 1
answered on 02 Mar 2012, 04:07 PM
Hello Anthony.

Running tests with ReSharper is not critical for me. Basically we use Gallio to run our test and generate a test execution report. It is deeply integrated in our solution, so I am afraid it will take a lot of time to get rid of it.

Thanks for the link to JustCode. I will investigate it deeply.
Asked by
Andrey Cherepakha
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Andrey Cherepakha
Top achievements
Rank 1
Share this question
or