Hi,
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?
Thanks!
Danielle
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?
Thanks!
Danielle