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’s context this will be same as below because webview is nothing but a chromeless browser session inside and app
print searchBtn.value_of_css_property(“background-color”).
Summary
for element inside NATIVE CONTEXT ==>> NO
for element inside WEBVIEW CONTEXT ==>> YES
I’m developing a test code in c# (v3.0.02 of Appium) and I need to get the value of “background-color” property of an element that I have in my NATIVE App.
for(int i=0;i<obj.Count;i++)
{
var str = obj[i].GetCssValue(“background-color”);
}
but is throwing an exception:
Test method ASEXamarin.Shared.Tests.TelaInicial.TesteRows threw exception:
System.NotImplementedException: Not yet implemented. Please help us: http://appium.io/get-involved.html
There is any form to get this property in NATIVE Apps?
For things like this that would help testing, but are not supported in the XCode and Android testing APIs yet, I create enhancement requests for my developers to add hidden information like this into the app elements for fields I can inspect.
org.openqa.selenium.Point point = elem.getCenter();
int centerx = point.getX();
int centerY = point.getY();
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
BufferedImage image = ImageIO.read(scrFile);
// Getting pixel color by position x and y
int clr= image.getRGB(centerx,centerY);
int red = (clr & 0x00ff0000) >> 16;
int green = (clr & 0x0000ff00) >> 8;
int blue = clr & 0x000000ff;
System.out.println("Red Color value = "+ red);
System.out.println("Green Color value = "+ green);
System.out.println("Blue Color value = "+ blue);