【问题标题】:Obtain text from Excel Name Box Using C# and WinAppDriver使用 C# 和 WinAppDriver 从 Excel 名称框中获取文本
【发布时间】:2020-05-30 16:22:33
【问题描述】:

我有一个 C# 自动化项目,它使用 WinAppDriver Release Candidate 1.2 与 Microsoft Excel 一起工作。

我有一个案例,我试图使用下面的代码获取工作表上已填充的行数。

    public string GetLastCellBelowStartRange(string sheetName, string startRange)
    {
        var sheet = FindSheet(sheetName);

        var nameBox = this.GetNameBox();
        nameBox.SendKeys($"{sheetName}!{startRange}{Keys.Enter}");

        this.excel.SendKeys($"{Keys.Control}{Keys.ArrowDown}");

        var endCellRange = nameBox.GetAttribute("LegacyIAccessible.Value");

        return endCellRange;
    }

代码成功转到工作簿中的最后一个单元格,nameBox 以及 excel 驱动程序(即 this.excel)都是已知的。

我无法确定如何获取 Inspect 在 Value.Value 和 LegacyIAccessible.Value 中显示的当前单元格的内容。

有人知道怎么做吗?

【问题讨论】:

    标签: selenium-webdriver appium-desktop winappdriver excel-automation


    【解决方案1】:
    public string GetLastCellBelowStartRange(string sheetName, string startRange)
    
        {
            var sheet = FindSheet(sheetName);
    
            var nameBox = this.GetNameBox();
            nameBox.SendKeys($"{sheetName}!{startRange}{Keys.Enter}");
    
            this.excel.SendKeys($"{Keys.Control}{Keys.ArrowDown}");
    
            string endCellRange = nameBox.GetAttribute("Value.Value").ToString();
    
            return endCellRange;
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-30
      • 1970-01-01
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 2013-09-18
      相关资源
      最近更新 更多