This is a migrated thread and some comments may be shown as answers.

Save as Dialog stop working

1 Answer 70 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Paola
Top achievements
Rank 1
Paola asked on 18 Oct 2012, 09:37 PM
Hi,
Test Environment: Visual Studio + Firefox

I have a problem working with the save as dialog, and it's that after some time of being working perfectly, it suddenly stops working, I mean I can download an average of 10 files, and then after that suddenly the Save As dialog does not work anymore, this is the piece of code that I'm using to Save a file:

As you can see, I'm simulating the file menu with some clicks, (if you have a better idea please let me know) because it's kind of complicated, and then I'm creating the SaveAs Dialog and adding it to the monitor, as I said it works sometimes and then suddenly it stops working.

Could you help me please?

System.Threading.

 

Thread.Sleep(1000);

 

 

 

Element input2 = myManager.ActiveBrowser.Find.ByTagIndex("table", 0);

 

myManager.ActiveBrowser.Actions.ScrollToVisible(input2);

 

myManager.ActiveBrowser.Desktop.Mouse.Click(

 

MouseClickType.RightClick,0,150);

 

myManager.ActiveBrowser.Desktop.Mouse.Click(

 

MouseClickType.RightClick, 0, 150);

 

 

System.Threading.

 

Thread.Sleep(500);

 

System.Drawing.

 

Rectangle Coor3 = input2.GetRectangle();

 

Coor3.X = Coor3.X + 10;

Coor3.Y = Coor3.Y + 10;

myManager.ActiveBrowser.Actions.ScrollToVisible(input2);

myManager.ActiveBrowser.Desktop.Mouse.Click(

 

MouseClickType.LeftClick, 10,240);

 

 

 

 

SaveAsDialog saveas3 = SaveAsDialog.CreateSaveAsDialog(myManager.ActiveBrowser, DialogButton.SAVE, "C:\Test", myManager.Desktop );

 

myManager.DialogMonitor.AddDialog(saveas3);

 

 

 

 

 

 

try

 

{

 

saveas3.WaitUntilHandled(10000);

myManager.DialogMonitor.RemoveDialogs();

 

}

 

 

catch

 

{
}

1 Answer, 1 is accepted

Sort by
0
Stoich
Telerik team
answered on 24 Oct 2012, 08:28 AM
Hi Paola,
your code seems correct. However, using fixed coordinates to click on a button is poor practice and you should avoid it. Presumably this is the element that will trigger the Dialog when clicked:
Element input2 = myManager.ActiveBrowser.Find.ByTagIndex("table", 0);

You should cast it to an HTML Control and click on it:
Element input2 = myManager.ActiveBrowser.Find.ByTagIndex("table", 0); 
input2.As<HtmlControl>().MouseClick();

This click should be much more reliable than a click on fixed coordinates. You can still keep the code that scrolls the element to visible before the click.

That being said - it won't be possible to tell what's going on without additional information. It's bad practice to have empty catch clauses:
try
{
saveas3.WaitUntilHandled(10000);
myManager.DialogMonitor.RemoveDialogs();
}
catch
{
}
It will only make potential problems much harder to spot and analyze. Additionally, you don't really need to remove the dialog unless there's a specific reason to do that.

Here's video demonstrating the kind of information that might be useful for troubleshooting:
http://tv.telerik.com/watch/automated-testing-tools/test-studio-submitting-support-ticket-for-playback-issues

I hope this helps.

All the best,
Stoich
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Paola
Top achievements
Rank 1
Answers by
Stoich
Telerik team
Share this question
or