Can i test color buttons and font style using appium for android and ios app with mac?

Using appium with mac OS, i’m wondring if i can test text, button colors ( comparing wwith the expected rgba color code ) with appium inspector and font style. ?

Button text appearance … things related to css does not work with native elements as underlying framework does not provide any api for it so we cannot do it using appium

If you are in webview context of app then normal selenium getCSSValue() method will work to show element appearance.

1 Like

You can imagemagick/sikuli/applitools framework for image comparison, i would suggest this is not part of functional testing. Human eyes are better tools to work out on such things instead of relying on framework.

what i wanted to compare is the rgba color for example you can see the same green by your eyes but in reality 2 colors are with different rgba color.
So that i’m asking just to have real precision

There are 2 context in app. Native and WebView

Native Context is developed using Android Native API’s
WebView Context is chromless web browser running inside app

You cannot extract element styling using appium in Native Context.
You can extract element styling using appium in WebView Context since element is displayed inside app using webrowser.

So if u r element is in native context ans is NO
And if u r element is in webview context ans is Yes. How (using getCssValue() api of selenium which returns rgba value associated wit color)

By default when u launch app it is NATIVE context.


Thx a lot for this clarification.

I am using Robot Framework AppiumLibrary and wanted to check the font size of a text on Chrome browser. How can I do that?

@preety2012 try to use:


you can test the colors of buttons by doing these:
Take the screenshot
Get the RGB color of the screenshot
Compare it with the standard you want

This code should help, though it’s written for iOS

public static void checkBackgroundColor(String mobileElement, String saveReadFile, String hexValue) throws IOException {
        MobileElement elem = (MobileElement) driver.findElement(By.xpath(mobileElement));
        SoftAssert softAssertion= new SoftAssert();
        File scrFile = elem.getScreenshotAs(OutputType.FILE);
        FileUtils.copyFile(scrFile, new File(saveReadFile));
        BufferedImage image = new File(saveReadFile));

        org.openqa.selenium.Point point = elem.getCenter();
        int centerx = point.getX();
        int centerY = point.getY();

        // Getting pixel color by position x and y
        int clr=  image.getRGB(centerY,centerx);
        int  r   = (clr & 0x00ff0000) >> 16;
        int  g = (clr & 0x0000ff00) >> 8;
        int  b =  clr & 0x000000ff;

        String hex = String.format("#%02x%02x%02x", r, g, b);
//        softAssertion.assertEquals(hex, hexValue);
        Assert.assertEquals(hex, hexValue);
        if (hex.equals(hexValue)){
            System.out.println("The color matches standard = "+ hex);
        } else {
            System.out.println("This is the hex value of rgb = "+ hex);