question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to run Appium + Protractor together for Hybrid App

See original GitHub issue

Hi,

Not sure if I’m trying to do something that is not possible, but I’m trying to run tests on a hybrid app using protractor+appium.

My conf looks as follows

"use strict";

var wd = require('wd'),
appium = require('appium'),
wdBridge = require('wd-bridge')(require('protractor'), wd),
_ = require('underscore');


var config = {
   allScriptsTimeout: 30000,
  // chromeDriver: './selenium/chromedriver',
  seleniumAddress: 'http://localhost:4723/wd/hub',

  specs: [
    '../spec/**/*Test.js',
  ],

  capabilities: {
    'browserName': '',
    'appium-version': '1.0',
    'platformName': 'iOS',
    'platformVersion': '7.1',
    'app': '/Users/AlexA/Documents/Worklog.app',
    'deviceName': 'iPhone 5',
    // 'appPackage': ''
    'udid': 'udid',
    'autoAcceptAlerts': 'true',
  },

 //rootElement: 'body',

  // ----- Options to be passed to minijasminenode -----
  jasmineNodeOpts: {
    // onComplete will be called just before the driver quits.
    onComplete: null,
    // If true, display spec names.
    isVerbose: false,
    // If true, print colors to the terminal.
    showColors: true,
    // If true, include stack traces in failures.
    includeStackTrace: true,
    // Default time to wait in ms before a test fails.
    defaultTimeoutInterval: 30000
  },

  onPrepare: function() {
    wdBridge.initFromProtractor(config);
  }

};

exports.config = config;

my test looks as follows:

"use strict";

describe('testing iphone local server', function() {

    it('this', function(done) {
    console.log('preparing to kill alert');
    browser.switchTo().alert().accept();
    console.log('killed alert');
    // browser.driver.context('WEBVIEW');
    var body = element(by.id('addWorkdayIcon'));
    body.click();
    // wdBrowser.wdEl(body).click().then(function (click) {
    //     body.click();
    //     }).nodeify(done);
 //    var done = element(by.id('doneButton'));
 //    wdBrowser.wdEl(done).click();
    });

});

and these are the errors that I get:

from the test stacktrace:

  1) testing iphone local server this
   Message:
     JavascriptError: An error occurred while executing user supplied JavaScript.
   Stacktrace:
     JavascriptError: An error occurred while executing user supplied JavaScript.
==== async task ====
WebDriver.executeScript()
    at null.<anonymous> (/Users/AlexA/Work/appium/test/e2e/spec/sampleTest.js:11:10)
==== async task ====
Asynchronous test function: it()
Error
    at null.<anonymous> (/Users/AlexA/Work/appium/test/e2e/spec/sampleTest.js:5:2)
    at Object.<anonymous> (/Users/AlexA/Work/appium/test/e2e/spec/sampleTest.js:3:1)

Finished in 4.121 seconds
1 test, 1 assertion, 1 failure

and the appium stacktrace:

debug: Dynamic bootstrap path: /Users/AlexA/Library/Application Support/appium/bootstrap/bootstrap-eb55a15dbb1f354a.js
debug: Reusing dynamic bootstrap: /Users/AlexA/Library/Application Support/appium/bootstrap/bootstrap-eb55a15dbb1f354a.js
debug: Not setting iOS and app preferences since we're on a real device
debug: Starting iOS device log capture via idevicesyslog
debug: Not setting device type since we're connected to a device
debug: Creating iDevice object with udid 2f7cc99b3cfdfb2f55629d589c185a413b375d6a
debug: Couldn't find ideviceinstaller, trying built-in at /Users/AlexA/appium/build/libimobiledevice-macosx/ideviceinstaller
debug: Installing app using cmd: /Users/AlexA/appium/build/fruitstrap/fruitstrap install --id 2f7cc99b3cfdfb2f55629d589c185a413b375d6a --bundle "/Users/AlexA/Documents/Worklog.app"
debug: Starting command proxy.
debug: Instruments socket server started at /tmp/instruments_sock
debug: Starting instruments
debug: Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
info: Launching instruments
debug: Attempting to run app on real device with UDID 2f7cc99b3cfdfb2f55629d589c185a413b375d6a
debug: Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -w 2f7cc99b3cfdfb2f55629d589c185a413b375d6a /Users/AlexA/Documents/Worklog.app -e UIASCRIPT /Users/AlexA/Library/Application Support/appium/bootstrap/bootstrap-eb55a15dbb1f354a.js -e UIARESULTSPATH /tmp/appium-instruments
debug: And extra without-delay env: {}
debug: And launch timeouts (in ms): {"global":90000}
info: Instruments is ready to receive commands
debug: Instruments launched. Starting poll loop for new commands.
debug: Setting bootstrap config keys/values
debug: Pushing command to appium work queue: "target = $.target();\nau = $;\n$.isVerbose = true;\nautoAcceptAlerts = true;\n"
debug: Sending command to instruments: target = $.target();
au = $;
$.isVerbose = true;
autoAcceptAlerts = true;

debug: Socket data received (2 bytes)
debug: Socket data being routed.
debug: Sending command to instruments: target = $.target();
au = $;
$.isVerbose = true;
autoAcceptAlerts = true;

debug: [INST] 2014-07-10 16:05:48 +0000 Debug: evaluation finished

debug: [INST] 2014-07-10 16:05:48 +0000 Debug: Result is not protocol compliant, wrapping

debug: [INST] 2014-07-10 16:05:48 +0000 Debug: Running system command #1: /usr/local/bin/node /Users/AlexA/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":true}...

debug: Socket data received (27 bytes)
debug: Socket data being routed.
debug: Got result from instruments: {"status":0,"value":true}
debug: Pushing command to appium work queue: "au.bundleId()"
debug: Sending command to instruments: au.bundleId()
debug: Sending command to instruments: au.bundleId()
debug: [INST] 2014-07-10 16:05:49 +0000 Debug: Got new command 1 from instruments: au.bundleId()

debug: [INST] 2014-07-10 16:05:49 +0000 Debug: evaluating au.bundleId()

debug: [INST] 2014-07-10 16:05:49 +0000 Debug: evaluation finished

debug: [INST] 2014-07-10 16:05:49 +0000 Debug: Result is not protocol compliant, wrapping

debug: [INST] 2014-07-10 16:05:49 +0000 Debug: Running system command #2: /usr/local/bin/node /Users/AlexA/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":"com.otpp.mobile.schooldays"}...

debug: Socket data received (51 bytes)
debug: Socket data being routed.
debug: Got result from instruments: {"status":0,"value":"com.otpp.mobile.schooldays"}
debug: Bundle ID for open app is com.otpp.mobile.schooldays
debug: Setting initial orientation to PORTRAIT
debug: Pushing command to appium work queue: "au.setScreenOrientation('PORTRAIT')"
debug: Sending command to instruments: au.setScreenOrientation('PORTRAIT')
debug: Sending command to instruments: au.setScreenOrientation('PORTRAIT')
debug: [INST] 2014-07-10 16:05:50 +0000 Debug: Got new command 2 from instruments: au.setScreenOrientation('PORTRAIT')

debug: [INST] 2014-07-10 16:05:50 +0000 Debug: evaluating au.setScreenOrientation('PORTRAIT')

debug: [INST] 2014-07-10 16:05:50 +0000 Debug: target.setDeviceOrientation("1")

debug: [INST] 2014-07-10 16:05:51 +0000 Debug: evaluation finished

debug: [INST] 2014-07-10 16:05:51 +0000 Debug: Running system command #3: /usr/local/bin/node /Users/AlexA/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":"PORTRAIT"}...

debug: Socket data received (33 bytes)
debug: Socket data being routed.
debug: Got result from instruments: {"status":0,"value":"PORTRAIT"}
debug: Device launched! Ready for commands
debug: Setting command timeout to the default of 60 secs
debug: Appium session started with sessionId 153a3e92-dfaa-42b5-bdb9-33cbe4ccf641
info: <-- POST /wd/hub/session 303 15114.053 ms - 9 
info: --> GET /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641 {}
debug: Appium request initiated at /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641
debug: Request received with params: {}
debug: Responding to client with success: {"status":0,"value":{"webStorageEnabled":false,"locationContextEnabled":false,"browserName":"","platform":"MAC","javascriptEnabled":true,"databaseEnabled":false,"takesScreenshot":true,"warnings":{},"desired":{"browserName":"","appium-version":"1.0","platformName":"iOS","platformVersion":"7.1","app":"/Users/AlexA/Documents/Worklog.app","deviceName":"iPhone 5","udid":"2f7cc99b3cfdfb2f55629d589c185a413b375d6a","autoAcceptAlerts":"true","count":1},"appium-version":"1.0","platformName":"iOS","platformVersion":"7.1","app":"/Users/AlexA/Documents/Worklog.app","deviceName":"iPhone 5","udid":"2f7cc99b3cfdfb2f55629d589c185a413b375d6a","autoAcceptAlerts":"true","count":1},"sessionId":"153a3e92-dfaa-42b5-bdb9-33cbe4ccf641"}
info: <-- GET /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641 200 2.928 ms - 721 {"status":0,"value":{"webStorageEnabled":false,"locationContextEnabled":false,"browserName":"","platform":"MAC","javascriptEnabled":true,"databaseEnabled":false,"takesScreenshot":true,"warnings":{},"desired":{"browserName":"","appium-version":"1.0","platformName":"iOS","platformVersion":"7.1","app":"/Users/AlexA/Documents/Worklog.app","deviceName":"iPhone 5","udid":"2f7cc99b3cfdfb2f55629d589c185a413b375d6a","autoAcceptAlerts":"true","count":1},"appium-version":"1.0","platformName":"iOS","platformVersion":"7.1","app":"/Users/AlexA/Documents/Worklog.app","deviceName":"iPhone 5","udid":"2f7cc99b3cfdfb2f55629d589c185a413b375d6a","autoAcceptAlerts":"true","count":1},"sessionId":"153a3e92-dfaa-42b5-bdb9-33cbe4ccf641"}
info: --> POST /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641/timeouts/async_script {"ms":30000}
debug: Appium request initiated at /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641/timeouts/async_script
debug: Request received with params: {"ms":30000}
debug: Set iOS async script timeout to 30000ms
debug: Responding to client with success: {"status":0,"value":null,"sessionId":"153a3e92-dfaa-42b5-bdb9-33cbe4ccf641"}
info: <-- POST /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641/timeouts/async_script 200 2.167 ms - 76 {"status":0,"value":null,"sessionId":"153a3e92-dfaa-42b5-bdb9-33cbe4ccf641"}
info: --> GET /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641/alert_text {}
debug: Appium request initiated at /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641/alert_text
debug: Request received with params: {}
debug: Pushing command to appium work queue: "au.getAlertText()"
debug: Sending command to instruments: au.getAlertText()
debug: Sending command to instruments: au.getAlertText()
debug: [INST] 2014-07-10 16:05:52 +0000 Debug: Got new command 3 from instruments: au.getAlertText()

debug: [INST] 2014-07-10 16:05:52 +0000 Debug: evaluating au.getAlertText()

debug: [INST] 2014-07-10 16:05:52 +0000 Debug: Lookup returned [object UIAStaticText] with the name " " (id: 0).

debug: [INST] 2014-07-10 16:05:52 +0000 Debug: Lookup returned [object UIAStaticText] with the name "Worklog is for personal use only. It does not report re-employment service to either your employer or the Ontario Teachers’ Pension Plan." (id: 1).

debug: [INST] 2014-07-10 16:05:52 +0000 Debug: evaluation finished

debug: [INST] 2014-07-10 16:05:52 +0000 Debug: Running system command #4: /usr/local/bin/node /Users/AlexA/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":"  Worklog is for personal use only. It does not report re-employment service to either your employer or the Ontario Teachers’ Pension Plan."}...

debug: Socket data received (164 bytes)
debug: Socket data being routed.
debug: Got result from instruments: {"status":0,"value":"  Worklog is for personal use only. It does not report re-employment service to either your employer or the Ontario Teachers’ Pension Plan."}
debug: Responding to client with success: {"status":0,"value":"  Worklog is for personal use only. It does not report re-employment service to either your employer or the Ontario Teachers’ Pension Plan.","sessionId":"153a3e92-dfaa-42b5-bdb9-33cbe4ccf641"}
info: <-- GET /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641/alert_text 200 1072.649 ms - 215 {"status":0,"value":"  Worklog is for personal use only. It does not report re-employment service to either your employer or the Ontario Teachers’ Pension Plan.","sessionId":"153a3e92-dfaa-42b5-bdb9-33cbe4ccf641"}
info: --> POST /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641/accept_alert {}
debug: Appium request initiated at /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641/accept_alert
debug: Request received with params: {}
debug: Pushing command to appium work queue: "au.acceptAlert()"
debug: Sending command to instruments: au.acceptAlert()
debug: Sending command to instruments: au.acceptAlert()
debug: [INST] 2014-07-10 16:05:53 +0000 Debug: Got new command 4 from instruments: au.acceptAlert()

debug: [INST] 2014-07-10 16:05:53 +0000 Debug: evaluating au.acceptAlert()

debug: [INST] 2014-07-10 16:05:54 +0000 Debug: target.frontMostApp().alert().defaultButton().tap()

debug: [INST] 2014-07-10 16:05:54 +0000 Debug: Waiting for alert to close...

debug: [INST] 2014-07-10 16:05:54 +0000 Debug: Waiting for alert to close...

debug: [INST] 2014-07-10 16:05:54 +0000 Debug: evaluation finished

debug: [INST] 2014-07-10 16:05:54 +0000 Debug: Running system command #5: /usr/local/bin/node /Users/AlexA/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":null}...

debug: Socket data received (27 bytes)
debug: Socket data being routed.
debug: Got result from instruments: {"status":0,"value":null}
debug: Responding to client with success: {"status":0,"value":null,"sessionId":"153a3e92-dfaa-42b5-bdb9-33cbe4ccf641"}
info: <-- POST /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641/accept_alert 200 2059.480 ms - 76 {"status":0,"value":null,"sessionId":"153a3e92-dfaa-42b5-bdb9-33cbe4ccf641"}
info: --> POST /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641/execute_async {"script":"try { return (function (selector, callback) {\n  var el = document.querySelector(selector);\n  try {\n    angular.element(el).injector().get('$browser').\n        notifyWhenNoOutstandingRequests(callback);\n  } catch (e) {\n    callback(e);\n  }\n}).apply(this, arguments); }\ncatch(e) { throw (e instanceof Error) ? e : new Error(e); }","args":["body"]}
debug: Appium request initiated at /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641/execute_async
debug: Request received with params: {"script":"try { return (function (selector, callback) {\n  var el = document.querySelector(selector);\n  try {\n    angular.element(el).injector().get('$browser').\n        notifyWhenNoOutstandingRequests(callback);\n  } catch (e) {\n    callback(e);\n  }\n}).apply(this, arguments); }\ncatch(e) { throw (e instanceof Error) ? e : new Error(e); }","args":["body"]}
debug: Pushing command to appium work queue: "try { return (function (selector, callback) {\n  var el = document.querySelector(selector);\n  try {\n    angular.element(el).injector().get('$browser').\n        notifyWhenNoOutstandingRequests(callback);\n  } catch (e) {\n    callback(e);\n  }\n}).apply(this, arguments); }\ncatch(e) { throw (e instanceof Error) ? e : new Error(e); }"
debug: Sending command to instruments: try { return (function (selector, callback) {
  var el = document.querySelector(selector);
  try {
    angular.element(el).injector().get('$browser').
        notifyWhenNoOutstandingRequests(callback);
  } catch (e) {
    callback(e);
  }
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }
debug: Sending command to instruments: try { return (function (selector, callback) {
  var el = document.querySelector(selector);
  try {
    angular.element(el).injector().get('$browser').
        notifyWhenNoOutstandingRequests(callback);
  } catch (e) {
    callback(e);
  }
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }
debug: [INST] 2014-07-10 16:05:55 +0000 Debug: Got new command 5 from instruments: try { return (function (selector, callback) {
         var el = document.querySelector(selector);
  try {
    angular.element(el).injector().get('$browser').
        notifyWhenNoOutstandingRequests(callback);
  } catch (e) {
    callback(e);
  }
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }

debug: [INST] 2014-07-10 16:05:55 +0000 Debug: evaluating try { return (function (selector, callback) {
         var el = document.querySelector(selector);
  try {
    angular.element(el).injector().get('$browser').
        notifyWhenNoOutstandingRequests(callback);
  } catch (e) {
    callback(e);
  }
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }

debug: Socket data received (75 bytes)
debug: Socket data being routed.
debug: Got result from instruments: {"status":17,"value":"Return statements are only valid inside functions"}
debug: Responding to client with error: {"status":17,"value":{"message":"An error occurred while executing user supplied JavaScript.","origValue":"Return statements are only valid inside functions"},"sessionId":"153a3e92-dfaa-42b5-bdb9-33cbe4ccf641"}
info: <-- POST /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641/execute_async 500 944.262 ms - 210 
info: --> DELETE /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641 {}
debug: Appium request initiated at /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641
debug: Request received with params: {}
info: Shutting down appium session
debug: Stopping ios
debug: Destroying instruments client socket.
debug: Closing socket server.
debug: Instruments socket server was closed
debug: Sending sigterm to instruments
debug: [INST] 2014-07-10 16:10:56 +0000 Stopped: Script was stopped by the user

debug: [INST] 2014-07-10 16:05:55 +0000 Error: Error during eval: eval@[native code]
       startProcessing@file:///Users/AlexA/appium/49DFF27F-8B3D-46F8-9351-782499CA5C92/commands.js:120:30
bootstrap@file:///Users/AlexA/appium/2FEF5B16-BF61-40D1-A6E2-E3F81CE20DEB/bootstrap.js:18:29
global code@file:///Users/AlexA/appium/8E12AF85-F3B2-4F55-90F2-8C5992D3F8F6/bootstrap-eb55a15dbb1f354a.js:9:10

debug: [INST] 2014-07-10 16:05:55 +0000 Debug: Running system command #6: /usr/local/bin/node /Users/AlexA/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":17,"value":"Return statements are only valid inside functions"}...

debug: [INST] Instruments Trace Complete (Duration : 12.549264s; Output : /Users/AlexA/appium/instrumentscli0.trace)

debug: [INSTSERVER] Instruments exited with code 0
debug: Cleaning up after instruments exit
debug: Stopping iOS log capture
debug: Killing the simulator process
debug: Killing any other simulator daemons
debug: Cleaning app state.
debug: No folders found to remove
debug: Removing app using cmd: /Users/AlexA/appium/build/fruitstrap/fruitstrap uninstall --id 2f7cc99b3cfdfb2f55629d589c185a413b375d6a --bundle com.otpp.mobile.schooldays
debug: Removed com.otpp.mobile.schooldays
debug: Cleaning up appium session
debug: Responding to client with success: {"status":0,"value":null,"sessionId":"153a3e92-dfaa-42b5-bdb9-33cbe4ccf641"}
info: <-- DELETE /wd/hub/session/153a3e92-dfaa-42b5-bdb9-33cbe4ccf641 200 1422.919 ms - 76 {"status":0,"value":null,"sessionId":"153a3e92-dfaa-42b5-bdb9-33cbe4ccf641"}

Any help would be really appreciated,

Thank you in advance,

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
bchucklescommented, Sep 15, 2016

“But its ok, i got hybrid testing working in Java so should be good. Thank you again.” Thats still not a solution for javascript users. Does wdBridge support appium + protractor. Non of these solutions still work for me.

0reactions
lock[bot]commented, Apr 29, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to run Appium + Protractor together for Native App
I have a question on Appium - protractor bridge. Is it possible to automate native apps using appium-protractor bridge? or Protractor ...
Read more >
Can you use Protractor and Appium together to test hybrid ...
To answer your question, yes you can integrate protractor and appium. Though as of now Protractor doesn't support appium officially, you can still...
Read more >
Run Appium Tests on Native & Hybrid Apps - BrowserStack
Test your native and hybrid mobile apps using Appium. Test at scale on a wide range of real Android and iOS devices on...
Read more >
Hybrid Application Testing with Protractor and Appium
With ProtractorJS and Appium you'll be able to test Angular Hybrid applications easily and quickly.
Read more >
Test Configuration Options - Sauce Labs Documentation
This setting cannot be used for mobile browsers, as your test will use the default browser installed for the given Appium version. " ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found