C# UI 测试 WinAppDriver Appium 测试颜色?

标签 c# excel appium coded-ui-tests winappdriver

当前正在测试我们最近添加到项目中的 Excel 添加 Pane 。我想测试“创建工作表”文本的颜色。

public void ConfirmBtnText()
    {
        excelSession.FindElementByName("Home").Click();
        excelSession.FindElementByXPath("//Button[@Name='AddIn button']").Click();

        var getLabel = excelSession.FindElementByName("Create worksheet");
        Assert.AreEqual("Create worksheet", getLabel.Text);

        Assert.AreEqual("rgb(75, 79, 84)", getLabel.GetAttribute("Color")); // Fails here
    }

错误说:

Expected:rgb(75, 79, 84). Actual:<(null)>.

我应该如何测试 Excel 添加 Pane 中元素的颜色?

感谢任何帮助,谢谢。

这也失败了:

string cssProperty = getLabel.GetCssValue("Color");

出现错误:

OpenQA.Selenium.WebDriverException: Unexpected error. Command not implemented: GET: /session/0CEE6663-DCBA-44E3-AC75-A7A5AF97DECA/element/42.525736.4.12/css/Color

最佳答案

编码的 UI 不提供对颜色属性的任何访问。一种解决方案是增强应用程序,使其设置编码 UI 在设置颜色的同时可以看到的属性。另一种方法是使用相关 UI 控件的 CaptureImage 方法,然后测试保存的图像中的颜色。

关于C# UI 测试 WinAppDriver Appium 测试颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52852754/

相关文章:

excel - 比较多列的高级过滤器

vba - 如何确定录制宏时将使用绝对引用还是相对引用?

java - AppiumDriverLocalService 自动下载 chrome

ios8 - 使用 Appium 自动化 iOS 8 应用程序会导致应用程序卡住

c# - 批处理文件的执行不符合 C# 中的预期

c# - 我需要 yyyy-mm-dd hh :mm:ss in SQL Server to become yyyy-mm-dd in C#

excel - 仅处理特定的 VBA 错误

c# - 工具栏中的按钮自动对齐

c# - 禁用和启用后 WPF 文本框焦点 "sticking"

appium - 在 android 中使用 appium 在一个 session 中自动化多个应用程序