Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying write of command 11:uia.tapOffset('{:x 24, :y 41}') at index 11 (RunLoop::WriteFailedError) #997

Closed
lindanordstrom opened this issue Feb 16, 2016 · 11 comments

Comments

@lindanordstrom
Copy link

Hi, I've already commented on the following issue;
#566

But since it was closed I created a new one as well..

I have a few tests where I have set RESET_BETWEEN_SCENARIOS=1, so the user is always signed out when a test starts. But in some scenarios we want to relaunch the app as part of a test, where we don't want to app to be reset, so I am calling the relaunch function (with :uia_strategy => :host, :reset => false).

The thing is I can run the scenario by itself without problem, but if I run a similar/identical scenario as the second or third scenario in a feature, cucumber will timeout on the "Trying write of command 13:uia.tapOffset('{:x 28, :y 41}') at index 13"

I've compared the logs to see what actually differs when I run two identical test in a feature. From what I can see the one that works fine will output:
"Trying write of command 1:uia.tapOffset"
And the one that fails outputs:
Trying write of command 13:uia.tapOffset

Adding a screenshot where I compare the working scenario with the failing scenario
And adding the full log for running the feature with the scenario twice

The two tests are identical and does the following:

  • sign in
  • relaunch app
  • press menu icon

Env:
$ xcode-select --print-path
/Applications/Xcode.app/Contents/Developer

$ xcodebuild -version
Xcode 7.2
Build version 7C68

$ calabash-ios version
0.17.1

$ curl http://localhost:37265/version
{
    "device_family": "iPhone",
    "outcome": "SUCCESS",
    "server_port": 37265,
    "simulator_device": "iPhone",
    "simulator": "CoreSimulator 201.3 - Device: iPhone 6s - Runtime: iOS 9.2 (13C75) - DeviceType: iPhone 6s",
    "app_name": "",
    "app_version": "5",
    "screen_dimensions": {
        "sample": 1,
        "height": 1334,
        "width": 750,
        "scale": 2
    },
    "git": {
        "revision": "db84756",
        "remote_origin": "git@github.com:calabash\/calabash-ios-server.git",
        "branch": "master"
    },
    "device_name": "iPhone Simulator",
    "4inch": false,
    "app_id": "com.xxxx.xxxx.cal.",
    "form_factor": "iphone 6",
    "system": "x86_64",
    "version": "0.17.1",
    "iOS_version": "9.2",
    "short_version_string": "0.5.0",
    "ios_version": "9.2",
    "iphone_app_emulated_on_ipad": false,
    "model_identifier": "iPhone8,1",
    "app_base_sdk": "iphonesimulator9.2"
}

run_loop, 2.0.6

screen shot 2016-02-11 at 14 41 15

errorLog.txt

@lindanordstrom
Copy link
Author

Did some extra tests, and the following is only failing on the very last step, all the previous (exactly the same) steps works ok.

Scenario: Test
Given a user has signed in
And the application is re-launched
And the user opens the menu
And the application is re-launched
And the user opens the menu

Scenario: Test
Given a user has signed in
And the application is re-launched
And the user opens the menu <----- FAILING

@jmoody
Copy link
Contributor

jmoody commented Feb 18, 2016

"Trying write of command 1:uia.tapOffset"
And the one that fails outputs:
Trying write of command 13:uia.tapOffset

The number (1 or 13) at the beginning is an index and has no effect on the gesture.

But in some scenarios we want to relaunch the app as part of a test, where we don't want to app to be reset, so I am calling the relaunch function (with :uia_strategy => :host, :reset => false).

I am not sure I understand. Are you calling relaunch during a step?

If so, this is probably a timing problem. You should wait for a view or add an explicit sleep. I have not seen anyone calling relaunch during a step, which makes me think that I don't understand what is happening.

@lindanordstrom
Copy link
Author

Haha, yes, I am calling it from a step. We need to make sure some things in the app behaves correctly even after relaunch. (E.g. sign in, relaunch, make sure user is still signed in.. )

So I am calling this function in the middle of the test to relaunch the app;
And I am calling it by using "DeviceHelper.launch_app({:reset => false})"

def self.launch_app(options)
    launcher = LaunchControl.launcher
    options = options.merge(:uia_strategy => :host)
    unless launcher.calabash_no_stop?
      launcher.relaunch(options)
      launcher.calabash_notify(self)
    end
  end

I've added sleep to all the places I could think of, I've tried with binding.pry in several places to see what is happening. But when it comes to finding the menu icon after the second relaunch, it just refuses to press it.. no matter how long I wait..

@jmoody
Copy link
Contributor

jmoody commented Feb 18, 2016

Can I recommend the following changes:

def self.launch_app(options)
 launcher = LaunchControl.launcher
 # Don't mutate arguments 
 merged_options  = options.merge({:uia_strategy => :host})

 # You want to relaunch, so don't bother branching on NO_STOP
 launcher.relaunch(merged_options)
 launcher.calabash_notify(self)

 # Wait for the app to be ready
 # Maybe query for something specific?
 wait_for do
    !query("*").empty?
 end
end

@jmoody
Copy link
Contributor

jmoody commented Feb 18, 2016

But when it comes to finding the menu icon after the second relaunch, it just refuses to press it.. no matter how long I wait..

Any chance you can share this app so we can reproduce?

@lindanordstrom
Copy link
Author

I'll try your changes, and if I still have problems I can break loose my code for this and share it. Unfortunately I can not share the app I am testing on though. I could try to reproduce it on another app to make sure it's nothing IN the app that makes it behave like this...

I'll play around a bit and come back to you,
thanks

@jmoody
Copy link
Contributor

jmoody commented Feb 18, 2016

@lindanordstrom
Copy link
Author

Aghhh, I think I solved it, we were using a "LaunchControl" module to set the launcher:

launcher = LaunchControl.launcher

which does the following:

  def self.launcher
    @@launcher ||= Calabash::Cucumber::Launcher.new
  end

when I was playing around just now I didn't bother to use the LaunchControl module so I just wrote
launcher = Calabash::Cucumber::Launcher.new
and that seem to work just fine, I am assuming it is because now I create a new launcher every time I call the relaunch function, but before it already had one, and that somehow messed things up?

@jmoody
Copy link
Contributor

jmoody commented Feb 18, 2016

🎱 🍕

I can imagine several reasons for this and I must apologize.

The Calabash::Cucumber::Launcher caches and mutates the options it is passed. This is a bug and has been on my radar for a long time - it is terribly difficult to fix because there are a lot of side effects and low test coverage.

So I can image that the @@launcher is not respecting some option you are passing in with options.

@jmoody
Copy link
Contributor

jmoody commented Feb 19, 2016

@lindanordstrom Closing, but if you have more problems I will reopen.

@jmoody jmoody closed this as completed Feb 19, 2016
@rKrums
Copy link

rKrums commented Jun 16, 2016

I had the same problem with 0.18.2. The reason was indeed timing. I had a restart step in scenario, and after the restart I did not have the background to check if the app is launched. Added a simple check with query(*).any? that solved the issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants