scosbet
scosbet

Reputation: 23

calabash-android: "y" and "center_y" coordinates offset by 222 when running query("*") through RubyMine

When running query("*") through the console on terminal I get output similar to the following. This output is correct for all intents and purposes:

[
 [ 0] {
                    "id" => nil,
               "enabled" => true,
    "contentDescription" => nil,
                 "class" => "com.android.internal.policy.impl.PhoneWindow$DecorView",
                  "rect" => {
        "center_y" => 616,
        "center_x" => 360,
          "height" => 507,
               "y" => 363,
           "width" => 640,
               "x" => 40
    }
]

However, when I run the same command on RubyMine during test execution I get incorrectly offset output like this:

{
  "id"=>nil,
  "enabled"=>true,
  "contentDescription"=>nil,
  "class"=>"com.android.internal.policy.impl.PhoneWindow$DecorView",
  "rect"=>{
      "center_y"=>394,
      "center_x"=>360,
      "height"=>507,
      "y"=>141,
      "width"=>640,
      "x"=>40
  },
  "tag"=>nil,
  "description"=>"com.android.internal.policy.impl.PhoneWindow$DecorView{41fcdad8 V.E.....  R....... 0,0-640,507}
}

I am only seeing this behaviour on one specific screen in my app. The rest have all worked as expected, but on this screen it's consistently 222 pixels out.

This is causing a click event to fail as it thinks an element is much higher up the screen than it actually is.

I have occasionally seen the incorrect output on console, and likewise had correct output from RubyMine, however approximately 95% of the time the behaviour has been as I've described.

I am using calabash-android 0.5.2

Does anyone have any idea what could be causing this variation?

Upvotes: 0

Views: 960

Answers (1)

scosbet
scosbet

Reputation: 23

It turns out that the offset appeared on this screen in the app as the keyboard was visible on the prior screen.

Clicking to generate a pop up while the keyboard was visible caused calabash to read the location of the view while the keyboard was still present, or at least in the process of disappearing, hence the "y" and "center_y" coordinates were raised a few hundred pixels.

I solved the issue by using 'press_back_button' to close the keyboard before selecting the pop up.

Upvotes: 0

Related Questions