Codeceptjs: How to use with Appium (esp with WebDriver IO)

Created on 31 Aug 2016  路  10Comments  路  Source: codeceptjs/CodeceptJS

Webdriver IO as well as some of the other helpers support Appium. Appium is like Selenium but for Native and Hybrid Mobile Apps on real devices. How would be go about writing the Codecept config file in order to support this?

enhancement

Most helpful comment

Appium integration TO-DO list

  • [x] Add Appium parameters to desired capabilities (add ability to switch between Appium and Webdriver)
  • [x] Test all webdriverIO methods with Appium and change them if necessary (e.g. error message if method is not supported by appium)
  • [x] Add custom methods for Appium only (e.g. hideDeviceKeyboard)
  • [x] Test Appium on Android
  • [x] Test Appium on iOs
  • [x] Update docs
  • [x] Add regression testing for new methods
  • [x] Final polishing

All 10 comments

I've also opened a relevant issue on WebDriverIO incase the config file can just be _transferred_ here https://github.com/webdriverio/webdriverio/issues/1569

Sorry, currently I don't have an idea on using Appium with CodeceptJS. Probably I will need to work on it soon. RIght now I have a feeling it's not technically possible but it should not be hard to implement that

I think it might be a case of just configuring the webdriverio configs within codecept. Our team at https://github.com/rcorp/standard-project-structure loves codecept and maybe the team can work to integrate Appium?

First, we got to get it working with webdriver.io then we'll have a clearer idea as to how to make it work here. What's the best place to ping you for discussions @DavertMik :question:

It's actually not difficult to do. I'm using it now to test native android apps. I created a custom helper that started off as an exact copy of the WebDriverIO class, and then made some updates to the constructor so it is able to initialize webdriverio with the appium configuration and capabilities. It worked like a charm!

Obviously there are a lot methods in the codeceptjs webdriverio that are exclusive for web browsers so I removed those, and then exposed a lot of the mobile methods that weren't included.

So now codeceptjs works for testing native android and ios apps and our entire test team is writing test cases in the same format and on the same platform, regardless of whether we are testing websites or native apps. If there's any interest in having it added into the codebase as an included service then I'm more than happy to help with that.

@richie-p Thanks for your response. Can you paste your config file here?

@gaurav21r

First, we got to get it working with webdriver.io then we'll have a clearer idea as to how to make it work here. What's the best place to ping you for discussions @DavertMik :question:

Best way is to ping me in Skype: davert.ua

Sorry I can be busy by other projects so I'm not so often in gitter and I miss discussions in Issues.

@richie-p Wow! Sounds awesome. Please send Pull Request for your Appium helper, send it as it is without code polishing. I will think on how better to integrate it into existing codebase without code duplication.

Thanks!

@gaurav21r This is what we use for an Android app already installed on the device.

"helpers": {
    "WebDriverIOAppium": {
      "require": "./helper/webdriverioappium_helper.js",
      "desiredCapabilities": {
        "platformName": "Android",
        "appPackage": "com.aim.condition",
        "appActivity": "com.aim.condition.activities.MainActivity",
        "appWaitActivity": "com.aim.condition.activities.LoginNewActivity",
        "deviceName": "Samsung S7",
        "platformVersion": "6.0.1"
      },
      "port": 4723,
      "waitForTimeout": 10
    }
  }

@DavertMik It's really not in a state yet where I would feel comfortable committing it, and I don't have availability to work on it right now, but here's the gist for anyone looking:

class WebDriverIOAppium extends Helper {
  constructor(config) {
    super(config);

    webdriverio = require('webdriverio');

    // set defaults
    this.options = {};

    // override defaults with config
    Object.assign(this.options, config);
  }

  static _checkRequirements(){
    try {
      require("webdriverio");
    } catch(e) {
      return ["webdriverio"];
    }
  }

I then remove a bunch of methods that are strictly for web, but I haven't really dug into what should and shouldn't stay. And bit by bit we're wrapping webdriverio methods we want to expose as follows:

  hideKeyboard(){
    return this.browser.hideDeviceKeyboard();
  }

Finally, at the end change the export class:

}

module.exports = WebDriverIOAppium;

And that's it really, nothing special going on, and webdriverio has all the heavy lifting already built-in. Like I say I don't have a lot of time to clean this helper up right now but I will try and get to it in the near future. In the mean time if anyone beats me to it I won't be mad!

@DavertMik please, assign it to me, I'll work on it on this week (todo list will be soon)

Appium integration TO-DO list

  • [x] Add Appium parameters to desired capabilities (add ability to switch between Appium and Webdriver)
  • [x] Test all webdriverIO methods with Appium and change them if necessary (e.g. error message if method is not supported by appium)
  • [x] Add custom methods for Appium only (e.g. hideDeviceKeyboard)
  • [x] Test Appium on Android
  • [x] Test Appium on iOs
  • [x] Update docs
  • [x] Add regression testing for new methods
  • [x] Final polishing
Was this page helpful?
0 / 5 - 0 ratings

Related issues

willhowlett picture willhowlett  路  9Comments

fatso83 picture fatso83  路  9Comments

medtoure18 picture medtoure18  路  14Comments

vitaly87 picture vitaly87  路  11Comments

zordius picture zordius  路  10Comments