Save as Dialog stop working

2 posts, 0 answers
  1. Paola
    Paola avatar
    4 posts
    Member since:
    Apr 2012

    Posted 18 Oct 2012 Link to this post

    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

     

    {
    }

  2. Stoich
    Admin
    Stoich avatar
    1 posts

    Posted 24 Oct 2012 Link to this post

    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
Back to Top