/
githubmirror
/
PowerToys
Обзор
Документация
Войти
/
githubmirror
/
PowerToys
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/common/UITestAutomation/Element/NavigationViewItem.cs
91 строка
3 KB
XiaofengWang
UI Test Automation (#39777)
17 июн 2025, 12:56
Не верифицирован
17 июн 2025, 12:56
350b9b7
Код
Авторство
О чём код?
// Copyright (c) Microsoft Corporation // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. namespace Microsoft.PowerToys.UITest { /// <summary> /// Represents a NavigationViewItem in the UI test environment. /// NavigationViewItem represents the container for an item in a NavigationView control. /// </summary> public class NavigationViewItem : Element { private static readonly string ExpectedControlType = "ControlType.ListItem"; /// <summary> /// Initializes a new instance of the <see cref="NavigationViewItem"/> class. /// </summary> public NavigationViewItem() { this.TargetControlType = NavigationViewItem.ExpectedControlType; } /// <summary> /// Click the ListItem element. /// </summary> /// <param name="rightClick">If true, performs a right-click; otherwise, performs a left-click. Default value is false</param> /// <param name="msPreAction">Pre action delay in milliseconds. Default value is 500</param> /// <param name="msPostAction">Post action delay in milliseconds. Default value is 500</param> public override void Click(bool rightClick = false, int msPreAction = 500, int msPostAction = 500) { PerformAction( (actions, windowElement) => { actions.MoveToElement(windowElement, 10, 10); if (rightClick) { actions.ContextClick(); } else { actions.Click(); } actions.Build().Perform(); }, msPreAction, msPostAction); } /// <summary> /// Click the center of the ListItem element. /// </summary> /// <param name="rightClick">If true, performs a right-click; otherwise, performs a left-click. Default value is false</param> /// <param name="msPreAction">Pre action delay in milliseconds. Default value is 500</param> /// <param name="msPostAction">Post action delay in milliseconds. Default value is 500</param> public void ClickCenter(bool rightClick = false, int msPreAction = 500, int msPostAction = 500) { PerformAction( (actions, windowElement) => { actions.MoveToElement(windowElement); if (rightClick) { actions.ContextClick(); } else { actions.Click(); } actions.Build().Perform(); }, msPreAction, msPostAction); } /// <summary> /// Double Click the ListItem element. /// </summary> public override void DoubleClick() { PerformAction((actions, windowElement) => { actions.MoveToElement(windowElement, 10, 10); actions.DoubleClick(); actions.Build().Perform(); }); } } }