Has any one tried calabash android (java) with selenium grid

2,474 views
Skip to first unread message

tejasvi manmatha

unread,
Nov 8, 2012, 9:12:53 AM11/8/12
to calabash...@googlegroups.com
I has a nice project on calabash
But am struggling to get the set up running.
 
 

Daryn Holmes

unread,
Nov 14, 2012, 11:15:02 AM11/14/12
to calabash...@googlegroups.com
I would like to know if there are any resources specifically on using calabash with selenium grid.

Cheers

Dary, Dominik

unread,
Nov 23, 2012, 7:17:23 AM11/23/12
to calabash...@googlegroups.com
did you looked at the wiki?

There is a detailed description about how to setup everything and also how to use the driver from a user perspective.

Regards

Dominik

Tej

unread,
Jan 11, 2013, 8:59:12 AM1/11/13
to calabash...@googlegroups.com, dd...@acm.org
I have tried run this and I end up with my tests failing

I see this error below:
A JSONObject text must begin with '{' at character 0
    at sh.calaba.driver.model.CalabashAndroidDriver.<init>

Regards,
Tej

Dary, Dominik

unread,
Jan 14, 2013, 5:42:08 AM1/14/13
to calabash...@googlegroups.com

Which Version of calabash-driver and calabash-android are you using?

Pls note that only calabash-android version 3.x are supported.

Pls share also the log output of the driver server console.


regards

Dominik

Tej

unread,
Jan 16, 2013, 12:32:12 PM1/16/13
to calabash...@googlegroups.com, dd...@acm.org
Hi Dominik,

I started using exactly the same steps as in https://github.com/calabash-driver/gdg-devfest-zrh

First i converted the code in example to eclipse project using mvn eclipse:eclipse command

Green house sample app was too big as it needed lot of setup
So i updated greenhouseandroidtests.java
like below
         super(CalabashCapabilities.android("greenhouse-android", "4.0.3",
                "en_EN", "emulator-5554", "emulator",
                "com.sai.samples.views",
                "com.sai.samples.views.PickerViewSample"));

Then installed picker activity project that is attached in this email
then created a test instrumentation server  using steps mentioned in -

Creating a TestServer.apk (Instrumentation Backend) for YOUR app

I am able to find that instrumentation in my device as well

C:\Users>adb shell pm list instrumentation
instrumentation:sh.calaba.android.test/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner (target=com.sai.samples.views)

I am attaching adb logs I got from console,

Thanks in advance,

Regards,
Tej
workspace.zip
log.txt

Dary, Dominik

unread,
Jan 17, 2013, 5:14:39 AM1/17/13
to calabash...@googlegroups.com

Hi Tej,


i looked into the project and here my comments:

  • Please keep in mind, that because calabash-android is starting a http server, you app need to have the permission to access the internet:
    <uses-permission android:name="android.permission.INTERNET" /> 
  • If you test your own app you need to create a new Calabash-Android Testserver.apk that fits (from the package perspective) to the base package of your app you would like to test. To create a test server for your project please run this command from your Android App project:
    calabash-android build bin/PickerViews.apk 
    The you find in the folder test_servers/ the apk of the calabash-android test-server that must install on the device.
  • To verify everything is setup correctly, you can execute this command on the command shell:
    adb shell am instrument -e target_package com.sai.samples.views -e main_activity com.sai.samples.views.PickerViewSample -e class sh.calaba.instrumentationbackend.InstrumentationBackend sh.calaba.android.test/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner 
    As a result you will see, that the app is started in the emulator / device.
  • Please note, that above steps are just there to make sure calanbash-android is installed correctly and is working as expected. Now let us look at calabash-driver:
  • I recommend to use the latest version of calabash-android, which is 1.2-snapshot
  • I simplified the test https://gist.github.com/4554686 where you see, how the working test is looking like.
With this steps everything is working fine on my machine.The problems you had are related to an incorrect Calabash-android setup for you app.

The error message you got initially with this json error, should be improved. I have created an calabash-driver issue for this.

Dominik

Tej

unread,
Jan 18, 2013, 6:31:14 AM1/18/13
to calabash...@googlegroups.com, dd...@acm.org
Hi Dominik,

Thanks a lot for you help !!
I just got it to work, Will try posting more steps and also project so that it might help anyone who wants try

Can you please let me know if there is a way to click on screen using co ordinates ??
Also can i use element id's for buttons / text views when I am testing using apk ??
As I understand from robotium that we can use these id's only when we have source code for the application to be tested and then we have a created a test project referencing the original application

I took the snapshot jars from here - https://github.com/calabash-driver/calabash-driver.github.com/tree/master/repository/sh/calaba

Thanks again for the guidance !!

BR,
Tej

Dary, Dominik

unread,
Jan 18, 2013, 8:45:55 AM1/18/13
to calabash...@googlegroups.com
Great that it is working now.

A command to click on an element by screen coordinates i not implemented. If you wonder, what Calabash-android commands/actions are currently implemented, please have a look at this Enum:

If a command is missing there, it is relatively easy to add it to calabash-driver. what i suggest is, that you just have a look about what is missing and then just add it and create a pull request and otherwise just file a bug in the calabash-driver github project, then i will implement it.

with regards to the locator strategy, I focused with the calabash-driver mainly those:
  • id (the android element id that you find in the android xml file)
  • l10n ( a resource bundle key that is used to translate at runtime the key into the right locale and uses the returning text for element interaction)
  • index
  • text
If you have an existing app and if you would like to get an quick overview about what elements are there, you can start calabash-android in the console mode and then execute in the console 

    performAction('inspect_current_dialog')

As a result you will get a xml result with the id and displayed texts and as well of the type of the view class.
More details you find in this blog post:
This action was some while ago contributed by me to calabash-android project.

Dominik

Tej

unread,
Jan 21, 2013, 9:10:44 AM1/21/13
to calabash...@googlegroups.com, dd...@acm.org
Hi Dominik,

Thanks for the support till now and things are working fine.
I tried to attach working example it seems like the size is too big will try some other alternative way.

I have another issue this happens
When i run the test, It will launch the app but does seem to do any actions this happens 2 out of 4 times
I dont get Starting Calabash HTTP Connector this message. each time i run the testcases, It runs 2 out 4 times.

Is there anything else that needs be done or I can attach any logs that will help 

10:30:26 DEBUG sh.calaba.utils.DefaultAdbConnection (line:100) - Waiting for process...
 - 10:30:26 DEBUG sh.calaba.utils.DefaultAdbConnection (line:108) -  process exit value: 0
 - 10:30:26 DEBUG sh.calaba.utils.DefaultAdbConnection (line:73) - Process 'about to forward: local port: 34777 to remote port: 7102' is about to start: C:\android\platform-tools\adb.exe    -s    emulator-5554    forward    tcp:34777    tcp:7102   
 - 10:30:26 DEBUG sh.calaba.utils.DefaultAdbConnection (line:100) - Waiting for process...
 - 10:30:26 DEBUG sh.calaba.utils.DefaultAdbConnection (line:108) -  process exit value: 0
 - 10:30:26 DEBUG sh.calaba.driver.server.CalabashProxy (line:201) - Capability initialized: emulator on local port: 34777
 - 10:30:26 DEBUG sh.calaba.driver.server.connector.impl.CalabashAndroidConnectorImpl (line:182) - Starting Calabash HTTP Connector
 - 10:30:28 DEBUG sh.calaba.driver.server.command.impl.NewSession (line:55) - New Session Class; session iD: e091985c-fa58-4765-b8ed-af4865d9ff9b
 - 10:30:28 DEBUG sh.calaba.driver.server.command.impl.NewSession (line:64) - Created session ID in response: e091985c-fa58-4765-b8ed-af4865d9ff9b
 - 10:30:28 DEBUG sh.calaba.driver.server.servlet.CalabashServlet (line:85) - CalabashServlet: new session: e091985c-fa58-4765-b8ed-af4865d9ff9b
 - 10:30:28 DEBUG sh.calaba.driver.server.servlet.CalabashServlet (line:73) - Got called with Reuqest URI: /wd/hub/session/e091985c-fa58-4765-b8ed-af4865d9ff9b/view

Thanks,
Tej

Dary, Dominik

unread,
Jan 21, 2013, 2:14:32 PM1/21/13
to calabash...@googlegroups.com

Hi Tej,

the information you provided is sadly not enough to provide good feedback.

If sharing the example makes troubles, do you have an github account? I would suggest that you share there on your account the project. this makes it also easier fir me.

Dominik

Tej

unread,
Jan 22, 2013, 11:19:31 AM1/22/13
to calabash...@googlegroups.com, dd...@acm.org
Hi Dominik,

I have created a test project - https://github.com/tejasv02/calabash-sample

I have 2 problems
1) problem with test not running every time
2) Not able to run the test on device, I can run on emulator

Can you please have a look into this project

Thanks,
Tej

Dary, Dominik

unread,
Jan 24, 2013, 5:22:46 AM1/24/13
to calabash...@googlegroups.com
thanks for putting everything on github, i will have a look today.

Tejasvi K M

unread,
Jan 24, 2013, 5:42:05 AM1/24/13
to calabash...@googlegroups.com
Thanks for guiding me, You are like my Guru :)
 
Thanks,
Tejasvi

Dary, Dominik

unread,
Jan 25, 2013, 3:54:39 AM1/25/13
to calabash...@googlegroups.com
Hi Tej,

if you would like to run the tests on the device you have as well to specify the serial number of the device. you can get this info by pluggin in your device via usb and then run the command: adb devices
When you use emulators you will have something like emulator-5554 and when you use devices you have soemthing like this: 2222948604012003

In your test https://github.com/tejasv02/calabash-sample/blob/master/greenhouse-android-test/src/main/java/sh/calaba/calabashdriver/Pickerjavatest.java you are using the serial number of the emulator and if you change this to the serial number of your device it will work. In my case this looks like this:
 
this.capabilities =

        CalabashCapabilities.android("greenhouse-android", "4.0.3", "en_EN", "2222948604012003",

            "emulator", "com.sai.samples.views", "com.sai.samples.views.PickerViewSample");

In the end using the capabilities is very powerful. you can use them to describe what kind of emulators and real devices are running on the machine and if you start your test, you are defining what capabilities you are requesting for this test and then the calabash-driver and the selenium-grid hub are looking for the right node and right device/emulator to run the tests.

With regards to tests are not running all the time: you may have to unlock the phone before running the tests. In calabash android you can do this with this command:

adb -s emulator-5554 shell am start -a android.intent.action.MAIN -n sh.calaba.android.test/sh.calaba.instrumentationbackend.WakeUp

if you add the following lines to your constructor of your test, calabash-driver is automatically executing the command for the corresponding device before the test session starts:

    List<String> adbCommands=new ArrayList<String>();

    String wakeUpCommand =

      "shell am start -a android.intent.action.MAIN -n sh.calaba.android.test/sh.calaba.instrumentationbackend.WakeUp";

    adbCommands.add(wakeUpCommand);

    capabilities.setAdditionalAdbCommands(adbCommands);

- Dominik

noor....@playfish.com

unread,
Jan 28, 2013, 5:49:37 AM1/28/13
to calabash...@googlegroups.com, dd...@acm.org
Hello Dominik
 
I work with Tej and the problem we are getting is after launching the test it hangs this happens every 3 or 4 times. Is there a way to start and stop the wifi and mobile networking options
directly from our test.
 

 

- 10:40:52 DEBUG sh.calaba.utils.DefaultAdbConnection (line:100) - Waiting for process...

- 10:40:52 DEBUG sh.calaba.utils.DefaultAdbConnection (line:108) - process exit value: 0

- 10:40:52 DEBUG sh.calaba.driver.server.CalabashProxy (line:186) - executing adb with parameter: shell am start -a android.intent.action.MAIN -n sh.calaba.android.test/sh.calaba.instrumentationbackend.WakeUp

- 10:40:52 DEBUG sh.calaba.utils.DefaultAdbConnection (line:73) - Process 'Executing adb Command' is about to start: C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -s HT115RX16049 shell am start -a android.intent.action.MAIN -n sh.calaba.android.test/sh.calaba.instrumentationbackend.WakeUp

- 10:40:52 DEBUG sh.calaba.utils.DefaultAdbConnection (line:100) - Waiting for process...

- 10:40:52 DEBUG sh.calaba.utils.DefaultAdbConnection (line:108) - process exit value: 0

- 10:40:52 DEBUG sh.calaba.utils.DefaultAdbConnection (line:73) - Process 'about to start CalabashServer' is about to start: C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -s HT115RX16049 shell am instrument -e target_package com.playfish.origin.casual -e main_activity com.playfish.origin.casual.activity.OriginLauncher -e class sh.calaba.instrumentationbackend.InstrumentationBackend sh.calaba.android.test/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner

- 10:40:52 DEBUG sh.calaba.utils.DefaultAdbConnection (line:73) - Process 'wait for calabash-server on mobile device' is about to start: C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -s HT115RX16049 shell netstat

- 10:40:53 DEBUG sh.calaba.utils.DefaultAdbConnection (line:100) - Waiting for process...

- 10:40:53 DEBUG sh.calaba.utils.DefaultAdbConnection (line:108) - process exit value: 0

- 10:40:55 DEBUG sh.calaba.utils.DefaultAdbConnection (line:73) - Process 'wait for calabash-server on mobile device' is about to start: C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -s HT115RX16049 shell netstat

I have attached the output from the console, this is where it hangs
 
 
Thanks
 
 
Noor Uddin

Dary, Dominik

unread,
Jan 28, 2013, 8:32:09 AM1/28/13
to calabash...@googlegroups.com
Hi Noor,

currently I sadly cannot reproduce your error. To understand more, can you pls answer below questions?
- what kind of version of calabash-android you have used for creating the testserver.apk?
- what android version you have on your htc device?
- do you have the same issue when you use emulators?
- how many devices you run in parallel?

Thanks

Dominik


--
 
 

Tej

unread,
Jan 29, 2013, 10:33:31 AM1/29/13
to calabash...@googlegroups.com, dd...@acm.org
Hi Dominik,

I have trouble clicking on a webview having check box present within label

label with checkbox looks like below in webview


Code for this label

<fieldset>
<div class="checkbox">
    <input type="checkbox" name="termsAndConditions" id="c101_termsAndConditions">
        <label for="c101_termsAndConditions">I agree to the <a class="view-legal-doc" href="#legal/privacy-policy">Privacy Policy</a> and <a class="view-legal-doc" href="#legal/terms-of-service">Terms of Service</a></label>
        <label for="c101_termsAndConditions" class="help"></label></div>
</div>
    </fieldset>

Can you please guide me on how to click this.

Also is it possible to let me know
1) If there is a way to click on particular text in webview.
2) Can you please include clicking in webview using xpath.


Thanks,
Tej

Dary, Dominik

unread,
Jan 30, 2013, 1:43:40 AM1/30/13
to calabash...@googlegroups.com
Hi Tej,

clicking on this checkbox can by done by CSS selector. If you use this selector it should work: input#c101_termsAndConditions

If you would like to click on a particular link text, you can use css selector as well:
a:contains('Sign in')

Currently I only support the actions that are by default part of the calabash-android project. As far as I know is there currently no implementation available to interact with a webview based on xpath. just adding an existing command is very easy and for this I will create a wiki page.

In general I personally prefere css selectors and I really like this blog post about 'CSS Selectors in Selenium Demystified': http://sauceio.com/index.php/2010/01/selenium-totw-css-selectors-in-selenium-demystified/

- Dominik

--
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.
 
 

Tej

unread,
Feb 27, 2013, 11:11:40 AM2/27/13
to calabash...@googlegroups.com, dd...@acm.org
Hi Dominik,

I have some connection reset problem seen after running calabash for 40-50 minutes.
I am not sure for what reason is happening.
I have pasted the copy of exception that I see in Junit.

      This happen when in this line of code: driver.waitForElement().waitFor(timeToWait); // file name where it happens (at com.origin.poc2.utils.CalabashUtil.wait(CalabashUtil.java:132))

I have integrated calabash with jbehave and Then I run a particular story which repeats 100 times.
It fails after a while and I am not able to figure out the reason for exception.

sh.calaba.driver.exceptions.CalabashException: Calabash command 'wait' was not successful: {"message":" , java.net.SocketException: Connection reset","class":"sh.calaba.driver.server.connector.CalabashConnecterException","stacktrace":["sh.calaba.driver.server.connector.impl.CalabashAndroidConnectorImpl.execute(CalabashAndroidConnectorImpl.java:145)","sh.calaba.driver.server.connector.impl.CalabashAndroidConnectorImpl.execute(CalabashAndroidConnectorImpl.java:79)","sh.calaba.driver.server.CalabashProxy.redirectMessageToCalabashServer(CalabashProxy.java:287)","sh.calaba.driver.server.command.CalabashCommandHandler.handle(CalabashCommandHandler.java:32)","sh.calaba.driver.server.servlet.CalabashServlet.getResponse(CalabashServlet.java:134)","sh.calaba.driver.server.servlet.CalabashServlet.process(CalabashServlet.java:71)","sh.calaba.driver.server.servlet.CalabashServlet.doGet(CalabashServlet.java:43)","javax.servlet.http.HttpServlet.service(HttpServlet.java:707)","javax.servlet.http.HttpServlet.service(HttpServlet.java:820)","org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:533)","org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:475)","org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:224)","org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:920)","org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:403)","org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:184)","org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:856)","org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)","org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:114)","org.eclipse.jetty.server.Server.handle(Server.java:352)","org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:596)","org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1066)","org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:805)","org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)","org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:426)","org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:510)","org.eclipse.jetty.io.nio.SelectChannelEndPoint.access$000(SelectChannelEndPoint.java:34)","org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)","org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:450)","java.lang.Thread.run(Thread.java:662)"]}
    at sh.calaba.driver.client.model.impl.RemoteObject.executeCalabashCommand(RemoteObject.java:46)
    at sh.calaba.driver.client.model.impl.WaitingSupportImpl.waitFor(WaitingSupportImpl.java:55)
    at com.origin.poc2.utils.CalabashUtil.wait(CalabashUtil.java:132)
    at com.origin.poc2.utils.CalabashUtil.clickAndWaitForPageToLoad(CalabashUtil.java:292)
    at com.origin.poc2.pages.FriendsPage.confirmSuccessfullRegistration(FriendsPage.java:68)
    at com.noor.jbs.steps.MySteps.thenISeeRegistrationSuccessDialog(MySteps.java:243)
    at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jbehave.core.steps.StepCreator$ParameterisedStep.perform(StepCreator.java:553)
    at org.jbehave.core.embedder.PerformableTree$FineSoFar.run(PerformableTree.java:265)
    at org.jbehave.core.embedder.PerformableTree$PerformableSteps.perform(PerformableTree.java:870)
    at org.jbehave.core.embedder.PerformableTree$PerformableExampleScenario.perform(PerformableTree.java:830)
    at org.jbehave.core.embedder.PerformableTree$PerformableScenario.perform(PerformableTree.java:761)
    at org.jbehave.core.embedder.PerformableTree$PerformableStory.performScenarios(PerformableTree.java:672)
    at org.jbehave.core.embedder.PerformableTree$PerformableStory.perform(PerformableTree.java:661)
    at org.jbehave.core.embedder.PerformableTree.performCancellable(PerformableTree.java:330)
    at org.jbehave.core.embedder.PerformableTree.perform(PerformableTree.java:310)
    at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:227)
    at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:206)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

Thanks,
Tej

Dominik Dary

unread,
Mar 5, 2013, 2:21:03 AM3/5/13
to calabash...@googlegroups.com, dd...@acm.org
Is your calabash-server on the device still running?
if you are requesting http://localhost:YOURPORT/ping
the response should be pong

-Dominik
Reply all
Reply to author
Forward
0 new messages