Performance testing the combo box

2 posts, 0 answers
  1. DeveloperDame
    DeveloperDame avatar
    7 posts
    Member since:
    Mar 2010

    Posted 26 Jul 2013 Link to this post

    Hi all,

    I'm currently using the framework to create performance tests for a WPF application. I need to record the time between when I click on a combo box and when the combo box is actually present. 

    I can't see an event that I can attach too that would tell me the combobox was down, you can see if it is down but no event.  

    Here's what I mean:

    IList<ComboBox> allByType = wpfWindow.Find.AllByType<ComboBox>();
    IEnumerable<ComboBox> comboBoxs = allByType.Where(x => x.Text.Contains("Test"));
    ComboBox comboBox = comboBoxs.First();
    _stopWatch = Stopwatch.StartNew();
    //Check to see if drop down is present or fire event
    Console.WriteLine("Total dropdown loading time (ms): " + _stopWatch.Elapsed.TotalMilliseconds);



  2. Velin Koychev
    Velin Koychev avatar
    88 posts

    Posted 29 Jul 2013 Link to this post

    Hello Sara,

    If you want to be sure that the ComboBoxItems are actually present, you can add additional code to verify that one of them actually exist in the DOM and is visible, before you stop the Stopwatch. 

    I have attached a demo application with a sample ComboBox. I have used the following code to measure the time elapsed:

    WpfApplication wpfApp = Manager.LaunchNewApplication(@"C:\Users\koychev\Documents\Visual Studio 2012\Projects\ComboBoxDemo\ComboBoxDemo\bin\Debug\ComboBoxDemo.exe");
    ComboBox comboBox =  wpfApp.MainWindow.Find.ByName<ComboBox>("ComboBox1");
    Stopwatch stopwatch = new Stopwatch();
    TextBlock listItem = wpfApp.MainWindow.Find.ByExpression(new XamlFindExpression ("TextContent=Coffie", "XamlTag=textblock")).As<TextBlock>();
    Log.WriteLine("Time elapsed: " + stopwatch.Elapsed.ToString());

    If this approach doesn't work for you, could you please elaborate more what timing resolution do you need. 

    Looking forward to hearing from you.

    Velin Koychev
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top