2

Currently testing an Excel add in pane that we've recently added into our project. I'd like to test the color of the, "Create worksheet" text.

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
    }

Error says:

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

How should I go about testing colors of an element on the Excel add in pane?

Any help's appreciated, thanks.

This also fails:

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

With the error:

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

JumpingJacks
  • 257
  • 3
  • 18

2 Answers2

1

Coded UI does not provide any access to colour attributes. One solution is to enhance the application so that it sets an attribute that Coded UI can see at the same time as setting the colour. Another approach is to use the CaptureImage method of the relevant UI control and then test the colour(s) in that saved image.

AdrianHHH
  • 13,492
  • 16
  • 50
  • 87
  • 1
    One solution is to enhance the application so that it sets an attribute that Coded UI can see at the same time as setting the colour. <--- How would you recommend we go about doing that? Currently trying to take a screenshot but struggling with a lot of compatibility issues... Using .NetCore2.1 currently. – JumpingJacks Oct 17 '18 at 13:43
1

I used an appium screenshot function to solve this.

Kindly refer to this link for usage details: https://appium.io/docs/en/commands/session/screenshot/

JumpingJacks
  • 257
  • 3
  • 18