Question

I have a text field(EditView) in my Android app, which changes color (borders) if it's value is not valid or empty. Also label(TextView) changes its color too in this case.

When I'm trying to get TextView using query, I see the following:

[0] {
                    "id" => "field_lable",
               "enabled" => true,
    "contentDescription" => nil,
                 "class" => "android.widget.TextView",
                  "text" => "Name",
                  "rect" => {
        "center_y" => 198.5,
        "center_x" => 51.0,
          "height" => 27,
               "y" => 185,
           "width" => 82,
               "x" => 10
    },
           "description" => "android.widget.TextView@a28btb00"
}

If i need to get text I can use query("TextView id:'field_label'", :text)

Is there any way in calabash to get the color of the TextView?

Was it helpful?

Solution

Unfortunately this is not possible in Android.

In Android the Views (also the TextView) can have almost anything as a background not just a color (a bitmap, a shape, a gradient color, etc). Because of this there is no way to get the background color of a view (it is not stored).

This is not a limitation of Calabash but the Android system. You can get any property of an Android view if it is accessible.

You can query the following colors on the TextView (nothing is background):

  • text color :currentTextColor
  • hintTextColor :hintTextColor
  • highlight color :highlightColor
  • shadow color :shadowColor
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top