TheBrainFamily / chimpy

Develop acceptance tests & end-to-end tests with realtime feedback.
https://thebrainfamily.github.io/chimpy
MIT License
52 stars 28 forks source link

Add appium support #6

Open samhatoum opened 6 years ago

samhatoum commented 6 years ago

Issue by samhatoum Saturday Jul 11, 2015 at 21:28 GMT Originally opened as https://github.com/xolvio/chimp/issues/33


Just like Selenium but Appium

Also see if calaba.sh can be used here

samhatoum commented 6 years ago

Comment by mario-ortiz Wednesday Dec 23, 2015 at 21:54 GMT


This integration would be great. Are there any news about this?

samhatoum commented 6 years ago

Comment by samhatoum Wednesday Dec 23, 2015 at 23:28 GMT


If you start all the tools manually, you can connect chimp to appium using --host

This is a lot of work for us to do right now, maybe a PR though :)

samhatoum commented 6 years ago

Comment by mario-ortiz Tuesday Dec 29, 2015 at 22:19 GMT


thank you Sam

samhatoum commented 6 years ago

Comment by DutchRican Wednesday Jan 27, 2016 at 17:25 GMT


Does anyone have a working example for this? Only specifying the host is throwing an error that the deviceName and platformName are missing. I tried to specify those over the appium CLI, but this is not working for me.

Setting these values in the CLI for Chimp is resulting in an error: setupBrowserAndDDP -- TypeError: Cannot read property 'toLowerCase' of undefined

samhatoum commented 6 years ago

Comment by mario-ortiz Wednesday Jan 27, 2016 at 17:30 GMT


I actually had to make some changes to the chimp_helper.js file, but it's working great after that. Not sure if the best solution tho.

Go to node_modules\chimp\lib and open chimp_helper.js Then, after line 110 I added this code if (process.env['chimp.platform'] === 'Android' || process.env['chimp.platform'] === 'IOS') { webdriverOptions.desiredCapabilities.platformName = webdriverOptions.desiredCapabilities.platform; webdriverOptions.desiredCapabilities.deviceName = webdriverOptions.desiredCapabilities.name; } And after that I could integrate with appium perfectly.

samhatoum commented 6 years ago

Comment by DutchRican Wednesday Jan 27, 2016 at 19:41 GMT


Thank you Mario!

The line count is not accurate any more. Right above the log output what the webdriveroptions are should be fine.

I had to modify your suggestion to this: if (process.env['chimp.platform']) { webdriverOptions.desiredCapabilities.platformName = webdriverOptions.desiredCapabilities.platform; webdriverOptions.desiredCapabilities.deviceName = process.env['chimp.deviceName']; }

samhatoum commented 6 years ago

Comment by the-boletus Tuesday Feb 16, 2016 at 15:28 GMT


Modifying the existing code does not feel right though. :) Well, it makes the deployment procedure difficult. But there is a piece of code in the same chimp_helper.js saying about "customChimpConfigPath":

if (fs.existsSync(customChimpConfigPath)) {
    var customChimpConfigurator = wrapAsync(require(customChimpConfigPath));
    global.browser = customChimpConfigurator(global.sessionManager);
    ...

I haven't found any information about the config file. What's the config's structure and could we use it for setting desired capabilities?

samhatoum commented 6 years ago

Comment by Sanjo Tuesday Feb 16, 2016 at 15:39 GMT


@the-boletus Yes, I think that was the purpose of the customChimpConfigPath option. To start with the file would roughly contain:

module.exports = function (sessionManager) {
  // Modified version of: https://github.com/xolvio/chimp/blob/master/src/lib/chimp-helper.js#L95-L136
};
samhatoum commented 6 years ago

Comment by mario-ortiz Friday Feb 19, 2016 at 22:34 GMT


Thank you @Sanjo, one quick question. I already copied the lines that you mentioned to my new chimp.js file, but I'm not sure what should I return from this file for the platform to work. I tried returning the 'return remoteSession(webdriverOptions)', but doesn't seem to work. Unless I change the chimp-helper line from this

var customChimpConfigurator = wrapAsync(require(customChimpConfigPath)); global.browser = customChimpConfigurator(global.sessionManager);

to this

var customChimpConfigurator = require(customChimpConfigPath); global.browser = customChimpConfigurator(global.sessionManager); (this one works like a charm, but again I had to change the chimp-helper.js file).

So it seems I need to return it in a specific way, but I haven't been able to found the right way to do it.

samhatoum commented 6 years ago

Comment by Sanjo Friday Feb 19, 2016 at 23:16 GMT


Oh the expected custom function must be a function with a callback. The correct signature is:

module.exports = function (sessionManager, callback) {
  // Modified version of: https://github.com/xolvio/chimp/blob/master/src/lib/chimp-helper.js#L95-L136
  var remoteSession = wrapAsync(sessionManager.remote, sessionManager);
  callback(null, remoteSession(webdriverOptions))
};

Maybe we can change this to a sync style function before 1.0. (And add the documentation).

samhatoum commented 6 years ago

Comment by mario-ortiz Monday Feb 22, 2016 at 19:41 GMT


Thank you @Sanjo, working great now. I just changed callback(remoteSession(webdriverOptions)) for callback(null, remoteSession(webdriverOptions)) Thank you very much.

samhatoum commented 6 years ago

Comment by Sanjo Thursday Feb 25, 2016 at 20:07 GMT


I have added a documentation page for the custom WebDriver configuring.

samhatoum commented 6 years ago

Comment by andyhite Friday Mar 18, 2016 at 23:34 GMT


Unless I'm totally misunderstanding this, the custom webdriver stuff doesn't seem to work for me. The --customChimpConfigPath CLI option does nothing - there doesn't even appear to be anything in the chimp bin file for it.

samhatoum commented 6 years ago

Comment by samhatoum Friday Mar 18, 2016 at 23:44 GMT


I think you might be right. Looking here: https://github.com/xolvio/chimp/blob/master/dist/lib/chimp-helper.js#L76

It looks like that's the variable name and not the option name. Tracking bug here: https://github.com/xolvio/chimp/issues/310

samhatoum commented 6 years ago

Comment by andyhite Friday Mar 18, 2016 at 23:47 GMT


Good to know I'm not going crazy :-P

I was able to get around this by just dropping the file with the callback into features/chimp.js, so it's not a huge issue for now.

samhatoum commented 6 years ago

Comment by gbhatnag Thursday Mar 24, 2016 at 20:34 GMT


Will adding the custom WebDriver config alone add support for Appium? I don't see options related to Appium or mobile testing available in the WebDriver config docs. I'm new to the Chimp / Appium worlds and need a way to test Cordova mobile apps that we've created for a Meteor app. I've got Chimp set up, connected to my Meteor app and can run tests against the server. I'm now interested in testing the web.cordova UI (on iOS and Android) and all the Appium mobile APIs available through WebDriver here look like just what I need.

Could someone point me in the right direction (docs, tutorials, videos, other) to get this combo of Meteor + Chimp + Appium set up?

samhatoum commented 6 years ago

Comment by gbhatnag Thursday Mar 24, 2016 at 21:37 GMT


I should add: we don't need to test directly on an iOS or Android device just yet. Simulators are just fine.

samhatoum commented 6 years ago

Comment by gbhatnag Tuesday Mar 29, 2016 at 21:43 GMT


Any suggestions here? Using Chimp thus far is going well and looking forward to testing our Cordova apps.

samhatoum commented 6 years ago

Comment by PierreCBSI Thursday Apr 21, 2016 at 23:00 GMT


running Chimp on my desktop, would like to see more details about connecting with Appium - maybe an official page?

samhatoum commented 6 years ago

Comment by wojtkowiak Tuesday May 10, 2016 at 14:18 GMT


I am also very interested in it. @samhatoum Could you expand a little bit this one, to have it described step by step?

If you start all the tools manually, you can connect chimp to appium using --host

samhatoum commented 6 years ago

Comment by ktoley Saturday Aug 20, 2016 at 01:01 GMT


It looks like you can specify Appium setting in a Chimp config file: //- - - - Appium connection - - - - 'platformName': 'Android', 'platform-name': 'Android', name: 'Appium Server', deviceName: "emulator-5554", host: 'localhost', port: 4723, app: "BasicSample/app/build/outputs/apk/app-debug.apk",

but the Appium server throws an error requesting platfromName and app to be specified in the capabilities. It does not seem to pick up those values from the Chimp config file. If you pass those properties in via the cli when starting Appium it looks like Chimp works. You can for example launch the apk however, overriding the settings with desiredCapabilities does not. rem cli appium --device-ready-timeout 7 --address 127.0.0.1 --port 4723 --platform-name Android --avd Nexus_5API 23_x86 --app BasicSample\app\build\outputs\apk\app-debug.apk

If you run in verbose mode it looks like webdriverio gets the desired capabilities options but they don't get passed to the server.

module.exports = { routeTo: function (route) { var driver = require('webdriverio'); var basePath = "BasicSample/app/build/outputs/apk/"; var route = (typeof route === 'undefined') ? 'app-debug.apk' : route ; var cl = driver.remote({ port: 4723, logLevel: 'verbose', desiredCapabilities: { 'appiumVersion': '1.5.3', 'deviceName': 'Nexus_5_API_23_x86', 'device-orientation': 'portrait', 'platformVersion': '6.0', 'platformName': 'Android', 'app': basePath + route } }); return cl; } };


client = require('./router').routeTo();
client.init(); // opens default apk

So for example you can't switch to a different apk or change device-orientation for a test.

Is there a work around in the config to address this or another solution. I would like to avoid modifying the Chimp source if possible.

samhatoum commented 6 years ago

Comment by martinhbramwell Saturday Jun 17, 2017 at 11:23 GMT


The main page of the docs refers to support for Appium, but the conversation above is the only documentation I can find for it!

Is there are public git repo somewhere, where I can see an example of Chimp driving Android tests?

My immediate goal is to run my first Cucumber test of a WebView app in a simulated Android device in CircleCI. If there's no single documentation for that, I would really appreciate a concise reading list.

samhatoum commented 6 years ago

Comment by egorvas Wednesday Jul 11, 2018 at 07:46 GMT


Hi, any updates in this area?