Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run protractor scripts on Android and IOS?

i'm using Protractor + Jasmine + Selenium WebdriverJS for automating angularjs application. I was able to configure and setup a sample script with all these tools to run on a desktop computer.

Now I want to run the same scripts on mobile( IOS & Android ) device / emulator.

I'm looking to use appium to run protractor scripts on IOS and Android. If anyone who has worked on protractor and appium. Please help me set up a sample script.

i'm pretty new to all these tools any Info on this is really helpful.

like image 208
Praveen Jagarlamudi Avatar asked Jan 22 '14 16:01

Praveen Jagarlamudi


2 Answers

at https://github.com/angular/protractor/blob/master/docs/browser-setup.md you can find very detailed informations how to setup appium with protractor to test on emulators (Android/iOS)

you have to replace the webdriver of protractor with the appium webdriver. the appium webdriver is running normally at port 4723. the folloing code is for android for a web-only angualr app (no apk, pure web, running in the cromebrowser of the device which must be present)

exports.config = {
  seleniumAddress: 'http://localhost:4723/wd/hub', //appium

   specs: [
    'spec.js'
    ],

   capabilities: {
     browserName: 'chrome',
     'appium-version': '1.0',
     platformName: 'Android',
     platformVersion: '4.4.2',
     deviceName: 'Android Emulator',
   },
    baseUrl: 'http://yourwebsite.com'),
 };

start appium and run test with

protractor yourtest.js

edit: adapting capabilities to recent version (browserName must be present for selenium 2.43.x)

like image 168
mojjj Avatar answered Oct 04 '22 14:10

mojjj


Have you tried using SauceLabs? I think you can request iOS and Android devices by specifying the platform in the capabilities section of the config.

If you don't want to use SauceLabs you can look at using Selenium's Grid functionality. You can get Selenium drivers for iOS and Android and have them connect to a centralized Selenium server that your Protractor scenarios are ran against, you just change the seleniumAddress in your config file to point to the centralized server.

Basically, you have to connect to the devices remotely and the easiest ways are as stated above.

like image 25
Coding Smackdown Avatar answered Oct 04 '22 14:10

Coding Smackdown