如何点击UWP应用程序的内容对话框中的按钮? [英] How to click on the button that is there in a content dialog for a UWP app?

查看:102
本文介绍了如何点击UWP应用程序的内容对话框中的按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 



我正在测试带编码UI的UWP应用。我有一个带有两个按钮的内容对话框是& NO。 


编码的UI无法找到是和& ;;没有按钮。 


在我突出显示内容对话框的父级时,在测试构建器中显示为主窗口,而不是内容窗口。 


这是开发UWP应用的方法。 


要重现类似问题,请按以下步骤操作: 


1)打开电影应用


2)点击添加按钮


3)尝试点击添加按钮 


编码的UI抛出异常"播放无法识别控件"


请帮助解决问题,父级中的位置仍显示为主窗口。 

解决方案

嗨thakurAnunay,


钍你在MSDN论坛上发帖了。


根据你的描述,你的问题是由内容对话框造成的。内容对话框上的按钮在播放过程中无法准确
。所以,请先找到内容对话框并突出显示然后,找到该内容对话框中的按钮并单击它。


以下示例代码在内容对话框UWP App中正常工作,请参考:

 XamlControl contentdialog = new XamlControl(); 
contentdialog.SearchProperties.Add(XamlControl.PropertyNames.Name," AppContentDialog");
contentdialog.SearchProperties.Add(XamlControl.PropertyNames.ControlType," Window");
contentdialog。 DrawHighlight();
XamlButton button = new XamlButton(contentdialog);
button.SearchProperties.Add(XamlButton.PropertyNames.ControlType," Button");
button.SearchProperties.Add(XamlButton .PropertyNames.Name," Button1");
Mouse.Click(按钮);





问候,


Judyzh


Hi 

I am testing an UWP app with coded UI. I have a content dialog box with two buttons Yes & NO. 

Coded UI fails to find the control for Yes & No buttons. 

In the test builder when I highlight the parent for the content dialog box is shown as the Main Window, not the content window. 

That is the way to develop UWP apps. 

To reproduce the similar problem, please follow the steps: 

1) Open movies app

2) Click on the add button

3) Try to click on the add button 

Coded UI throws an exception "Playback failed to identify the control"

Please help on how to resolve the issue, where in the parent is still been shown as main window. 

解决方案

Hi thakurAnunay,

Thank you posting in MSDN forum.

According to your description, your problem is caused by content dialog box. The button on the content dialog box cannot be accurately identified during playback. So, please first find the content dialog box and highlight it, then, find the button in that content dialog box and click on it.

Following example code work fine in content dialog box UWP App, please reference:

XamlControl contentdialog = new XamlControl();
            contentdialog.SearchProperties.Add(XamlControl.PropertyNames.Name, "AppContentDialog");
            contentdialog.SearchProperties.Add(XamlControl.PropertyNames.ControlType, "Window");
            contentdialog.DrawHighlight();
            XamlButton button = new XamlButton(contentdialog);
            button.SearchProperties.Add(XamlButton.PropertyNames.ControlType,"Button");
            button.SearchProperties.Add(XamlButton.PropertyNames.Name, "Button1");
            Mouse.Click(button);


Regards,

Judyzh


这篇关于如何点击UWP应用程序的内容对话框中的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆