【问题标题】:Can we automate remote machine using UI automation我们可以使用 UI 自动化来自动化远程机器吗
【发布时间】: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


【解决方案1】:

RDP 不会将 UI 自动化请求转发到远程计算机,因此您将无法发现或检查远程计算机窗口中的元素。

【讨论】:

    猜你喜欢
    • 2018-02-17
    • 2021-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 2020-09-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多