iOS Automated Testing

Setting up Protractor on mobile devices

To run protractor on mobile devices Appium is used as server,

Pre-Requs:
Appium server should be up and running 
Protractor server should be running
Device(Android/iOS) should be connected to PC and accessible through adb

Its above all is Ok, only few changes in conf.js of protractor are required to point its requests appium,

  seleniumAddress: ‘http://localhost:4723/wd/hub’,
    capabilities: {
    platformName: ‘android’,
    deviceName: ‘galaxy s4’,
    browserName: ‘chrome’,
    newCommandTimeout: 60
      },
    baseUrl: ‘http://10.0.2.2:’ + (process.env.HTTP_PORT || ‘8000’),

Some points to understand, 
1. Selenium use port 4444 but to use Appium it should be port 4723 instead of 4444
2. platformName: should be name of env where script will execute, like Andorid/iOS
3. deviceName: should be name of device like s4/iphone 5
4. browserName: should be chrome/safari
5. baseUrl is 10.0.2.2 instead of localhost because it is used to access the localhost of the host machine in the android emulator/device

Sources:
https://github.com/angular/protractor/issues/361
https://github.com/angular/protractor/issues/697
https://github.com/angular/protractor/blob/master/docs/browser-setup.md