How to check the color code/color of an element in Appium ? I'm unable to find the color of the element in appium because in one field I want to automate the output which is defined in different colors. How to verify this using Appium/UI automator.
Asked
Active
Viewed 7,270 times
-2
-
Like @adam-burley answered [here](https://stackoverflow.com/a/66403312/6766297) You can use pixel color verify. – nby Dec 27 '21 at 08:57
2 Answers
1
This cannot be done by Appium as underlying UIAutomator framework does not allow us to do so. In app’s native context this cannot be done.
In app’s webview context could query the value of a web element's computed CSS property. Example:
MobileElement element = (MobileElement) driver.findElementById("SomeId");
String cssProperty = element.getCssValue("style");
Note: This command only applies to web view contexts. More information is available at: http://appium.io/docs/en/commands/element/attributes/css-property/
Summary:
- for element inside NATIVE CONTEXT ==>> NO
- for element inside WEB VIEW CONTEXT ==>> YES

Ivo Dimitrov
- 103
- 7