Skip to content

Commit 5b326d5

Browse files
committed
Waits for context menu to open in test
Wraps context menu right-click and element retrieval in a wait condition that checks if the context menu is open.
1 parent 019e3a5 commit 5b326d5

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tests/MaterialDesignThemes.UITests/WPF/TextBoxes/TextBoxTests.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,18 @@ public async Task ContextMenu_UsesInheritedFontFamily()
335335
</StackPanel>
336336
");
337337
var textBox = await stackPanel.GetElement<TextBox>("/TextBox");
338-
await textBox.RightClick();
339-
340-
var contextMenu = await textBox.GetElement<ContextMenu>(".ContextMenu");
341-
342338
var textBoxFont = await textBox.GetFontFamily();
343339
await Assert.That(textBoxFont?.FamilyNames.Values.First()).IsEqualTo("Times New Roman");
340+
341+
IVisualElement<ContextMenu> contextMenu = null!;
342+
await Wait.For(async () =>
343+
{
344+
await textBox.RightClick();
345+
contextMenu = await textBox.GetElement<ContextMenu>(".ContextMenu");
346+
return await contextMenu.GetIsOpen();
347+
});
348+
349+
344350
await Assert.That(await contextMenu.GetFontFamily()).IsEqualTo(textBoxFont);
345351

346352
recorder.Success();

0 commit comments

Comments
 (0)