【发布时间】:2016-03-15 05:21:17
【问题描述】:
我有登录 rdp 的代码,但我无法检查任何元素:
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Automation;
using System.Windows.Forms;
using OpenQA.Selenium.Interactions;
namespace AutoTest
{
class RAAdmin
{
public void RuleTestExistingUserName()
{
var RDP = Process.Start("mstsc.exe");
Thread.Sleep(3000);
var _remoteRDP = AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "Remote Desktop Connection"));
AutomationElement rdpCombobox = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.ClassNameProperty, "ComboBox"));
AutomationElement rdpTextBox = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.ClassNameProperty, "Edit"));
TextPattern targetTextPattern = rdpTextBox.GetCurrentPattern(TextPattern.Pattern) as TextPattern;
targetTextPattern.DocumentRange.Select();
Thread.Sleep(3000);
SendKeys.SendWait("xxx.xxx.xx.xx");
rdpCombobox = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.ClassNameProperty, "ComboBox"));
_remoteRDP = AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "Remote Desktop Connection"));
SendKeys.SendWait("{ENTER}");
//clicks on connect button of rdp window.
我可以登录 rdp,但无法检查远程机器窗口中的元素。请提供想法。
【问题讨论】:
-
目标机器(和客户端)上的操作系统版本是多少?我相信 RDP 可以在 Windows 8 及更高版本上转发 UI 自动化请求;但客户端和目标都必须运行 Windows 8 或更高版本。
-
两台机器上的操作系统都是 8.1 windows,我无法检查元素
-
我错了。 RDP 不转发 UI 自动化请求。
标签: c# automation microsoft-ui-automation