Update click in NavigationViewItem

This commit is contained in:
Xiaofeng Wang (from Dev Box)
2025-03-13 16:27:31 +08:00
parent 6bdbb6b552
commit dd5997ab06

View File

@@ -24,22 +24,26 @@ namespace Microsoft.PowerToys.UITest
/// Click the ListItem element.
/// </summary>
/// <param name="rightClick">If true, performs a right-click; otherwise, performs a left-click. Default value is false</param>
public override void Click(bool rightClick = false)
/// <param name="clickHoldMS">Mouse click hold time. Default value is 300 ms</param>
public override void Click(bool rightClick = false, int clickHoldMS = 300)
{
PerformAction((actions, windowElement) =>
{
actions.MoveToElement(windowElement, 10, 10);
actions.MoveToElement(windowElement);
// Move 2by2 offset to make click more stable instead of click on the border of the element
actions.MoveByOffset(10, 10);
if (rightClick)
{
actions.ContextClick();
actions.ContextClick().Build().Perform();
}
else
{
actions.Click();
actions.ClickAndHold().Build().Perform();
Task.Delay(clickHoldMS).Wait();
actions.Release().Build().Perform();
}
actions.Build().Perform();
});
}