Timing issues testing WPF app

2 posts, 0 answers
  1. Danielle
    Danielle avatar
    2 posts
    Member since:
    Jun 2014

    Posted 28 Oct 2014 Link to this post


    I am using Test Studio to write tests for a WPF client app that communicates with a server.  There is a lot of delay between steps due to server communication, so I'm trying to get rid of all arbitrary sleeps and key off other UI elements to synchronize my test steps.  I'm running into a lot of issues with context menus.  Here is my current approach:

    1) Find the element by XamlFindExpression that I want to right-click for a context menu.
    2) hover over the element with User.HoverOver()
    3) Sleep 200 ms
    4) issue a User.Click(MouseClickType.RightClick)
    5) refresh the visual trees of my window with win.RefreshVisualTrees()
    6) try to find the context menu item by name: win.Find.ByExpression(new XamlFindExpression("XamlTag=MenuItem", "Name=menuItemName");

    This works "some" of the time.  However, I have my find strategy set to AlwaysWaitForElementsVisible and timeout set to 30000 ms.  However, when this fails, it returns failure right away, it doesn't wait for the menu item to show up.

    Is there a better way to do this?  What am I doing wrong?

  2. Cody
    Cody avatar
    3354 posts

    Posted 31 Oct 2014 Link to this post

    Hi Danielle,

    The approach you describe sounds reasonable. Without knowing exactly what the error is when "it returns failure right away" it's impossible to say why it isn't working as expected. Can you give us the error log when it does fail?

    Having an actual copy of your code would help a little bit. It would help even more if it would be possible to get a copy of your WPF application, allow us to run it on our machines then run your test and diagnose why it's not working as expected. Then we can come up with a solution for you.

    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top