Run multiple devices at same time + Get value of a text view

2,523 views
Skip to first unread message

hico

unread,
Nov 9, 2012, 4:00:39 AM11/9/12
to calabash...@googlegroups.com
Hi,

I would like to run my scenarios/features at the same time on multiple devices. I've tried to plug in 2 devices but I get the error "more than one device and emulator".
Jonas said that it was possible in 0.2 (see post https://groups.google.com/forum/?fromgroups=#!msg/calabash-android/2ngfHeFXn3U/F_0g91Ra4Q0J) but I didn't figure out how to handle it.

Also, I would like to know if it's possible to get a value I have on an activity (text view).
It's a dynamical value so I can't predict it like a simple step "I should see the text.." 


Thanks a lot for your help and have a nice day.
Message has been deleted

Jazz

unread,
Nov 19, 2012, 8:28:17 AM11/19/12
to calabash...@googlegroups.com
Hi Hico,

It would be great help for me if you could share how to test/run two android devices at the same time using calabash?

Thanks
Jazz

Jonas Maturana Larsen

unread,
Nov 29, 2012, 12:49:27 AM11/29/12
to calabash...@googlegroups.com
You can run calabash-android with multiple devices plugged in like this:
ADB_DEVICE_ARG=<serial> calabash-android run <apk>

<serial> is the serial of the device you want to test on.


On Friday, November 9, 2012 10:00:39 AM UTC+1, hico wrote:

Claus Schou

unread,
Jan 3, 2013, 1:37:40 AM1/3/13
to calabash...@googlegroups.com
Hmm I've tried this with both the actual serial of the device and the serial which is shown by the Android Device Chooser and non of them works.
It says it's waiting for for the device.

Also could you give an example of how you execute to devices simultaneously.

Can it be done like this ADB_DEVICE_ARG=<serial1>,<serial2> calabash-android run <apk> 

or how is this done?
Best regards Claus.

Sabha

unread,
Jan 6, 2013, 12:46:25 AM1/6/13
to calabash...@googlegroups.com
HI,
How to find the serial number of the devices that are connected.
Is it the number that is listed through "adb devices" on terminal?

If not, please provide me steps to find the serial number of device.

-Sabha

Sabha

unread,
Jan 6, 2013, 2:38:30 AM1/6/13
to calabash...@googlegroups.com
Hi All,

Ignore my query...I could able to find the way to run the test cases on (more than)two different devices.

Steps for the purpose of viewers:
  • adb devices
    • List of devices attached
      • <device serial1>     device
      • <device serial2>      device
  • will show you the devices that are connected aka "serial numbers"
  • Start the terminal and run the command, on your first device of your choice: 
    • calabash-android run <apk> ADB_DEVICE_ARG=<device serial1>
  • Start another terminal and run the command
    • calabash-android run <apk> ADB_DEVICE_ARG=<device serial 2>
-
Sabha

Dubinsky

unread,
Jan 7, 2013, 7:49:44 AM1/7/13
to calabash...@googlegroups.com
This functionality is awesome . However when I try to run the same test on two devices , the device that runs the test after the first device starts - FAILS [test]

Is any one facing similar issues ?

After running it a couple of times I have noticed that both the tests assert on the same state of the app [ie. the device that starts the tests first].

For instance : Below is the log of the second device . 

The button CONTINUE AS GUEST is on the Home Page of my App . The other Buttons are on the Second Page . Once the user clicks CONTINUE AS GUEST.


When I press "CONTINUE AS GUEST >"                                                    # calabash-android-0.3.7/lib/calabash-android/steps/press_button_steps.rb:17
      Step unsuccessful: Could not find anything to press matching: 'CONTINUE AS GUEST >' found: 
      Buttons:
      SETTINGS >
      LOG OUT >
      SIGN UP NOW >
      CONTACT US >

At this stage my second device was on the Second Page.

Any suggestions ? I ran the tests from different locations in two different terminals . 
 

Claus Schou

unread,
Jan 10, 2013, 7:48:13 AM1/10/13
to calabash...@googlegroups.com
I've experienced the exact same thing

Claus Schou

unread,
Jan 10, 2013, 7:51:32 AM1/10/13
to calabash...@googlegroups.com
This is what I've tried:

I've tried doing the stuff written below however If I start up two terminals and execute the command below 

ADB_DEVICE_ARG=4df167af4dd05f4d calabash-android run NotePad.apk

in one terminal and one more in another - using a different serial. 
Then only one of the devices will finish with success. The other one fails with the output below:

Feature: Login feature

  Scenario: As a user I want to enter text in a new note         # features/my_first.feature:3
4815 KB/s (434705 bytes in 0.088s)
3573 KB/s (59690 bytes in 0.016s)
    Given my app is running                                      # calabash-android-0.3.8/lib/calabash-android/steps/app_steps.rb:11
    Then I press "New note"                                      # calabash-android-0.3.8/lib/calabash-android/steps/press_button_steps.rb:17
      Step unsuccessful: Click can not be completed! (RuntimeError)
      /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:67:in `timeout'
      features/my_first.feature:5:in `Then I press "New note"'
    Then I enter text "This is a test" into field with id "note" # calabash-android-0.3.8/lib/calabash-android/steps/enter_text_steps.rb:21
      Could not take screenshot. App is most likely not running anymore. (RuntimeError)
      /Library/Ruby/Gems/1.8/gems/calabash-android-0.3.8/lib/calabash-android/operations.rb:262:in `screenshot'
      /Library/Ruby/Gems/1.8/gems/calabash-android-0.3.8/lib/calabash-android/operations.rb:65:in `screenshot_embed'
      /Users/csc/Documents/Eclipse_workspace/features/support/app_life_cycle_hooks.rb:11:in `After'

Failing Scenarios:
cucumber features/my_first.feature:3 # Scenario: As a user I want to enter text in a new note

1 scenario (1 failed)
3 steps (1 failed, 1 skipped, 1 passed)
0m31.674s

why is that?
Should both devices run in only one terminal?

Jonas Maturana Larsen

unread,
Jan 10, 2013, 8:23:02 AM1/10/13
to calabash...@googlegroups.com
Could you try to run with the -v option so we can see the verbose output?

- Jonas

rd_ceq

unread,
Jan 11, 2013, 12:53:40 PM1/11/13
to calabash...@googlegroups.com
 I am seeing similar behavior with multiple devices. My post can be found here (still working through this issue)....
               https://groups.google.com/forum/#!starred/calabash-android/JthY_9hSjs0

Jonas Maturana Larsen

unread,
Jan 13, 2013, 4:30:56 PM1/13/13
to calabash...@googlegroups.com
You have to set TEST_SERVER_PORT as well as ADB_DEVICE_ARG for at least one of the devices otherwise both terminals will talk to whichever device is getting port 34777 to it.

Sabha

unread,
Jan 15, 2013, 9:46:46 PM1/15/13
to calabash...@googlegroups.com
Hi Jonas,

Please provide a example 'command string' how we can use two different ports for two different devices

Jonas Maturana Larsen

unread,
Jan 16, 2013, 1:53:42 AM1/16/13
to calabash...@googlegroups.com
You can run something like this in two different terminals:
ADB_DEVICE_ARG=abc TEST_SERVER_PORT=34800 calabash-android run <apk>
ADB_DEVICE_ARG=def TEST_SERVER_PORT=34801 calabash-android run <apk>
Message has been deleted

Jonas Maturana Larsen

unread,
Feb 13, 2013, 10:26:06 AM2/13/13
to calabash...@googlegroups.com
Please explain as much as you can about what you want to do?

Do you want to run on two devices in parallel or test two devices interaction in one test?

Is the file "eBayMobile_2.1.1.0-internal.apk" in your current folder?

You shouldn't put angle brackets around the serial number. It should just be:
ADB_DEVICE_ARG=01498FE715019008

- Jonas


On Wednesday, February 13, 2013 at 16:06 , Slikkk wrote:

Hello guys,

Where is should enter those commands?
In Ruby command prompt?
In Ruby command prompt, after starting ruby console with command calabash-android console xyz.apk?This i cannot do with 2 devices

For the 1st i got the error "The system cannot find the file specified."
This is the command:
ADB_DEVICE_ARG=<01498FE715019008> TEST_SERVER_PORT=34800 calabash-android run eBayMobile_2.1.1.0-internal.apk


WHERE I SHOULD RUN THAT COMMAND?

Best Regards,
Adrian
--
You received this message because you are subscribed to the Google Groups "calabash-android" group.
To unsubscribe from this group and stop receiving emails from it, send an email to calabash-andro...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Slikkk

unread,
Feb 13, 2013, 11:15:46 AM2/13/13
to calabash...@googlegroups.com
I want to to run the apk on two devices in parallel
The apk is in mine current folder and i have tried without brackets also.And still nothing.
Message has been deleted

Allen Au

unread,
Mar 5, 2013, 10:16:09 AM3/5/13
to calabash...@googlegroups.com
I tried running each of these commands on a separate terminal and got the error below with 2 physical devices connected to usb.
-------------------------------------------
ADB_DEVICE_ARG=xxxx TEST_SERVER_PORT=34800 calabash-android run path_to_my_debug_apk.apk
ADB_DEVICE_ARG=yyyy TEST_SERVER_PORT=34801 calabash-android run path_to_my_debug_apk.apk
-------------------------------------------
error: more than one device or emulator


Any ideas?

Thanks
Allen

Jonas Maturana Larsen

unread,
Mar 5, 2013, 5:00:02 PM3/5/13
to calabash...@googlegroups.com
Try to post the verbose output.

Which version are you running?

- Jonas

Allen Au

unread,
Mar 5, 2013, 9:28:59 PM3/5/13
to calabash...@googlegroups.com
I'm running 0.4.0.pre9

Here's the verbose output.  Does it reveal my problem?  Thanks!

--------------------------------------
thq-m-aau:Calabash aau$ ADB_DEVICE_ARG=HT29PW300740 calabash-android run $CLIENT_HOME/Android/App/bin/com.mycompany-debug.apk --tags @login
Setting DUT to -s HT29PW300740
logcat_HT29PW300740.out found.  Clearing and making new one...
Tee Logcat PID: 40365
Speced Device: >>-s HT29PW300740<<
Setting DUT to -s HT29PW300740
Feature: Login feature

  @login
  Scenario: Log in as an existing user after startup # features/login.feature:5
2115 KB/s (520858 bytes in 0.240s)
3677 KB/s (8867425 bytes in 2.354s)
Device iniside Init: 
error: more than one device and emulator
error: more than one device and emulator
    Given I am an existing user                      # features/step_definitions/login_steps.rb:128
      Starting scenario
      Device before instantiate: 
      undefined method `strip' for nil:NilClass (NoMethodError)
      ./features/step_definitions/login_steps.rb:46:in `LMS_version'
      ./features/step_definitions/login_steps.rb:145:in `/^I am an existing user$/'
      features/login.feature:6:in `Given I am an existing user'
    And I Look at the LMS version                    # features/step_definitions/login_steps.rb:161
    And I goto Registration screen                   # features/step_definitions/login_steps.rb:172
    And I input my user name and password            # features/step_definitions/login_steps.rb:186
    Then I should see mycompany main menu              # features/step_definitions/login_steps.rb:201

Failing Scenarios:
cucumber features/login.feature:5 # Scenario: Log in as an existing user after startup

1 scenario (1 failed)
5 steps (1 failed, 4 skipped)
0m26.353s
Killing logcat tee process...
thq-m-aau:Calabash aau$ ADB_DEVICE_ARG=HT29PW300740 calabash-android run $CLIENT_HOME/Android/App/bin/com.mycompany-debug.apk --tags @login -v
2013-03-05 18:21:34 - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S cucumber --tags @login -v PACKAGE_NAME=com.mycompany MAIN_ACTIVITY=com.mycompany.ui.LoadDispatch APP_PATH="/Users/aau/mycompany/Git/client/Android/App/bin/com.mycompany-debug.apk" TEST_APP_PATH="test_servers/ff6fb2fcea19b4cc8d9506a38e97c2e5_0.4.0.pre9.apk" TEST_SERVER_PORT=34777
Code:
  * features/support/env.rb
Setting DUT to -s HT29PW300740
logcat_HT29PW300740.out found.  Clearing and making new one...
Tee Logcat PID: 40475
  * features/support/app_installation_hooks.rb
  * features/support/app_life_cycle_hooks.rb
  * features/support/hooks.rb
Failed to load 'feature-bak' programming language for file features/login.feature-bak: no such file to load -- cucumber/feature_bak_support/feature_bak_language
  * features/login.feature-bak [NOT SUPPORTED]
  * features/step_definitions/calabash_steps.rb
  * features/step_definitions/login_steps.rb
Speced Device: >>-s HT29PW300740<<
Setting DUT to -s HT29PW300740
Failed to load 'rb-bak' programming language for file features/step_definitions/login_steps.rb-bak: no such file to load -- cucumber/rb_bak_support/rb_bak_language
  * features/step_definitions/login_steps.rb-bak [NOT SUPPORTED]

Features:
  * features/login.feature
Parsing feature files took 0m0.008s

Feature: Login feature

  @login
  Scenario: Log in as an existing user after startup # features/login.feature:5
2013-03-05 18:21:34 - First scenario in feature - reinstalling apps
2013-03-05 18:21:34 - "/Users/aau/Emulators/Android/android-sdk-mac_86/platform-tools/adb" -s HT29PW300740 forward tcp:34777 tcp:7102
2013-03-05 18:21:35 - 
2013-03-05 18:21:35 - Uninstalling: sh.calaba.android.test
2013-03-05 18:21:36 - Success
2013-03-05 18:21:36 - Uninstalling: com.mycompany
2013-03-05 18:21:39 - Success
2013-03-05 18:21:39 - Installing: test_servers/ff6fb2fcea19b4cc8d9506a38e97c2e5_0.4.0.pre9.apk
2890 KB/s (520858 bytes in 0.175s)
2013-03-05 18:21:42 - pkg: /data/local/tmp/ff6fb2fcea19b4cc8d9506a38e97c2e5_0.4.0.pre9.apk
Success
2013-03-05 18:21:44 - Installing: /Users/aau/mycompany/Git/client/Android/App/bin/com.mycompany-debug.apk
3702 KB/s (8867425 bytes in 2.339s)
2013-03-05 18:21:53 - pkg: /data/local/tmp/com.mycompany-debug.apk
Success
2013-03-05 18:21:57 - Starting test server using:
2013-03-05 18:21:57 - "/Users/aau/Emulators/Android/android-sdk-mac_86/platform-tools/adb" -s HT29PW300740 shell am instrument -e main_activity com.mycompany.ui.LoadDispatch -e class sh.calaba.instrumentationbackend.InstrumentationBackend -e debug false -e target_package com.mycompany sh.calaba.android.test/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner
2013-03-05 18:21:58 - Checking if instrumentation backend is ready
2013-03-05 18:21:59 - Is app running? true
2013-03-05 18:21:59 - Instrumentation backend not yet ready
2013-03-05 18:22:02 - Checking if instrumentation backend is ready
2013-03-05 18:22:03 - Is app running? true
2013-03-05 18:22:03 - Instrumentation backend is ready!
Device iniside Init: 
error: more than one device and emulator
error: more than one device and emulator
    Given I am an existing user                      # features/step_definitions/login_steps.rb:128
      Starting scenario
      Device before instantiate: 
      undefined method `strip' for nil:NilClass (NoMethodError)
      ./features/step_definitions/login_steps.rb:46:in `LMS_version'
      ./features/step_definitions/login_steps.rb:145:in `/^I am an existing user$/'
      features/login.feature:6:in `Given I am an existing user'
    And I Look at the LMS version                    # features/step_definitions/login_steps.rb:161
    And I goto Registration screen                   # features/step_definitions/login_steps.rb:172
    And I input my user name and password            # features/step_definitions/login_steps.rb:186
    Then I should see mycompany main menu              # features/step_definitions/login_steps.rb:201
2013-03-05 18:22:03 - java -jar /Library/Ruby/Gems/1.8/gems/calabash-android-0.4.0.pre9/lib/calabash-android/lib/screenShotTaker.jar /Users/aau/mycompany/Git/Calabash/screenshots/screenshot_0.png -s HT29PW300740

Failing Scenarios:
cucumber features/login.feature:5 # Scenario: Log in as an existing user after startup

1 scenario (1 failed)
5 steps (1 failed, 4 skipped)
0m30.615s
Killing logcat tee process...
thq-m-aau:Calabash aau$ 
--------------------------------------

Allen Au

unread,
Mar 5, 2013, 10:11:09 PM3/5/13
to calabash...@googlegroups.com
I'm running 0.4.0.pre9.


Here's the verbose output.
------------------------------------------------------------

thq-m-aau:Calabash aau$ ADB_DEVICE_ARG=HT29PW300740 calabash-android run $CLIENT_HOME/Android/App/bin/com.lookout-debug.apk --tags @login -v
2013-03-05 18:21:34 - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S cucumber --tags @login -v PACKAGE_NAME=com.lookout MAIN_ACTIVITY=com.lookout.ui.LoadDispatch APP_PATH="/Users/aau/Lookout/Git/client/Android/App/bin/com.lookout-debug.apk" TEST_APP_PATH="test_servers/ff6fb2fcea19b4cc8d9506a38e97c2e5_0.4.0.pre9.apk" TEST_SERVER_PORT=34777
2013-03-05 18:21:36 - Uninstalling: com.lookout
2013-03-05 18:21:39 - Success
2013-03-05 18:21:39 - Installing: test_servers/ff6fb2fcea19b4cc8d9506a38e97c2e5_0.4.0.pre9.apk
2890 KB/s (520858 bytes in 0.175s)
2013-03-05 18:21:42 - pkg: /data/local/tmp/ff6fb2fcea19b4cc8d9506a38e97c2e5_0.4.0.pre9.apk
Success
2013-03-05 18:21:44 - Installing: /Users/aau/Lookout/Git/client/Android/App/bin/com.lookout-debug.apk
3702 KB/s (8867425 bytes in 2.339s)
2013-03-05 18:21:53 - pkg: /data/local/tmp/com.lookout-debug.apk
Success
2013-03-05 18:21:57 - Starting test server using:
2013-03-05 18:21:57 - "/Users/aau/Emulators/Android/android-sdk-mac_86/platform-tools/adb" -s HT29PW300740 shell am instrument -e main_activity com.lookout.ui.LoadDispatch -e class sh.calaba.instrumentationbackend.InstrumentationBackend -e debug false -e target_package com.lookout sh.calaba.android.test/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner
2013-03-05 18:21:58 - Checking if instrumentation backend is ready
2013-03-05 18:21:59 - Is app running? true
2013-03-05 18:21:59 - Instrumentation backend not yet ready
2013-03-05 18:22:02 - Checking if instrumentation backend is ready
2013-03-05 18:22:03 - Is app running? true
2013-03-05 18:22:03 - Instrumentation backend is ready!
Device iniside Init: 
error: more than one device and emulator
error: more than one device and emulator
    Given I am an existing user                      # features/step_definitions/login_steps.rb:128
      Starting scenario
      Device before instantiate: 
      undefined method `strip' for nil:NilClass (NoMethodError)
      ./features/step_definitions/login_steps.rb:46:in `LMS_version'
      ./features/step_definitions/login_steps.rb:145:in `/^I am an existing user$/'
      features/login.feature:6:in `Given I am an existing user'
    And I Look at the LMS version                    # features/step_definitions/login_steps.rb:161
    And I goto Registration screen                   # features/step_definitions/login_steps.rb:172
    And I input my user name and password            # features/step_definitions/login_steps.rb:186
    Then I should see Lookout main menu              # features/step_definitions/login_steps.rb:201
2013-03-05 18:22:03 - java -jar /Library/Ruby/Gems/1.8/gems/calabash-android-0.4.0.pre9/lib/calabash-android/lib/screenShotTaker.jar /Users/aau/Lookout/Git/Calabash/screenshots/screenshot_0.png -s HT29PW300740

Failing Scenarios:
cucumber features/login.feature:5 # Scenario: Log in as an existing user after startup

1 scenario (1 failed)
5 steps (1 failed, 4 skipped)
0m30.615s
Killing logcat tee process...
thq-m-aau:Calabash aau$

Allen Au

unread,
Mar 8, 2013, 4:53:21 PM3/8/13
to calabash...@googlegroups.com
Hi Jonas,  I've included the requested information.  Any ideas what might be my problem?

Thanks
Allen

Jonas Maturana Larsen

unread,
Mar 8, 2013, 5:45:05 PM3/8/13
to calabash...@googlegroups.com

Have you wrapped calabash somehow or made customizations to the hooks.

Allen Au

unread,
Mar 8, 2013, 9:52:27 PM3/8/13
to calabash...@googlegroups.com
I have the following hooks in env.rb.  Even when calling calabash-android directly, I get the error when a 2nd usb device is connected.

Is there a hook conflicting with my objective?

-------------------------------------------------------------------

# Before each test run

ENV['SCREENSHOT_VIA_USB'] = "true"

if (ENV['ADB_DEVICE_ARG']) then

   @device = "-s #{ENV['ADB_DEVICE_ARG']}"

   puts "Setting DUT to #{@device}"

end


logcat_log = "logcat_#{ENV['ADB_DEVICE_ARG']}.out"


if File.exist?(logcat_log)

   puts "#{logcat_log} found.  Clearing and making new one..."

   File.delete(logcat_log)

end


tee_logcat_pid = fork do

   `adb #{@device} logcat -c`

   `adb #{@device} logcat -v time Lookout:V 2>&1 | tee #{logcat_log}`

   exit

end

puts "Tee Logcat PID: #{tee_logcat_pid}"



# Before each Scenario

Before do

   puts "Starting scenario"

end


# After each Scenario

After do |scenario|

   puts "Ending scenario #{scenario}"    

   if(scenario.failed?)

    subject = "[Project X] #{scenario.exception.message}"

    puts "Failure:  #{subject}"

  end

end



# After each test run

at_exit do

   puts "Killing logcat tee process..."

   Process.kill( 'HUP', tee_logcat_pid )

end

-------------------------------------------------------------------

Jonas Maturana Larsen

unread,
Mar 9, 2013, 4:20:41 PM3/9/13
to calabash...@googlegroups.com
It could be your custom hooks.

Try to disable them and try again.

Dan Zaharie

unread,
Apr 9, 2013, 8:09:30 AM4/9/13
to calabash...@googlegroups.com
I get the following error running the command:

C:\Users\danz\Desktop\demo>ADB_DEVICE_ARG=4df1287b36fc5f6f
calabash-android run

'ADB_DEVICE_ARG' is not recognized as an internal or external command,
operable program or batch file.

Any idea what I'm doing wrong? I'm using calabash-android 0.4.3.pre4

Thank you!

--
Dan Zaharie,
Software Tester
Fortech 19 Meteor Str | 400492 Cluj Napoca | Romania

dan.z...@fortech.ro | www.fortech.ro
T: +40 264 453 303(int. 609) | F: +40 264 438 217

sai krishna

unread,
Jul 26, 2013, 3:08:29 AM7/26/13
to calabash...@googlegroups.com
Yah even i get the same error

'ADB_DEVICE_ARG' is not recognized as an internal or external command, 
operable program or batch file. 

Can someone please help on this

joachim N'DOYE

unread,
Oct 4, 2013, 6:59:53 AM10/4/13
to calabash...@googlegroups.com
Yo,
On Windows its the other way around
So ADB_DEVICE_ARG=abc TEST_SERVER_PORT=34800 calabash-android run <apk> (LINUX)
Becomes  calabash-android run <apk> ADB_DEVICE_ARG=abc TEST_SERVER_PORT=34800
Does-it help?

Raj Varma

unread,
Oct 11, 2014, 11:15:48 AM10/11/14
to calabash...@googlegroups.com
On similar lines, I have created a gem to do this. 

https://rubygems.org/gems/parallel_calabash

This works on osx. not yet tested on windows. please try it out and if you need any help please let me know

Reply all
Reply to author
Forward
0 new messages