Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Does Protractor + Appium works for Native or Hybrid apps #1798

Closed
nainighai opened this issue Feb 10, 2015 · 23 comments
Closed

Does Protractor + Appium works for Native or Hybrid apps #1798

nainighai opened this issue Feb 10, 2015 · 23 comments

Comments

@nainighai
Copy link

Was able to develop and execute Protractor successfully for web apps on desktop as well as Android. but faced issues with Native / Hybrid apps (based on PhoneGap).

Configuartion file:-

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

specs: ['example_spec_mobile.js'],

// Reference: https://github.com/appium/sample-code/blob/master/sample-code/examples/node/helpers/caps.js
capabilities: {
browserName: '',
'appium-version': '1.0',
platformName: 'Android',
platformVersion: '4.4.2',
deviceName: 'Android Emulator',
app: 'path to APK file'
},

allScriptsTimeout: 60000
};

Specification File:-
describe('homepage', function() {
it('validate service url', function() {
element(by.id('com.test.testApp:id/clearable_edit')).sendKeys('URL to type in text field');
element(by.id('com.test.testApp:id/serviceUrlButton')).click();
});
});

Error logs:-
D:\nodejs\node_modules\protractor\example>protractor conf_mobile.js
Using the selenium server at http://localhost:4723/wd/hub
[launcher] Running 1 instances of WebDriver

D:\nodejs\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:113
var template = new Error(this.message);
^
UnknownError: Not yet implemented. Please help us: http://appium.io/get-involved.html
at new bot.Error (D:\nodejs\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:113:18)
at Object.bot.response.checkResponse (D:\nodejs\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\response.js:106:9)
at D:\nodejs\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:362:20
at D:\nodejs\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\base.js:1582:15
at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (D:\nodejs\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:
1654:20)
at notify (D:\nodejs\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:465:12)
at notifyAll (D:\nodejs\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:442:7)
at resolve (D:\nodejs\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:420:7)
at [object Object].fulfill (D:\nodejs\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:535:5)
at D:\nodejs\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1520:10
==== async task ====
WebDriver.manage().timeouts().setScriptTimeout(60000)
at webdriver.WebDriver.schedule (D:\nodejs\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:345:15)
at webdriver.WebDriver.Timeouts.setScriptTimeout (D:\nodejs\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:1301:23)
at Runner.createBrowser (D:\nodejs\node_modules\protractor\lib\runner.js:180:30)
at D:\nodejs\node_modules\protractor\lib\runner.js:259:24
at _fulfilled (D:\nodejs\node_modules\protractor\node_modules\q\q.js:797:54)
at self.promiseDispatch.done (D:\nodejs\node_modules\protractor\node_modules\q\q.js:826:30)
at Promise.promise.promiseDispatch (D:\nodejs\node_modules\protractor\node_modules\q\q.js:759:13)
at D:\nodejs\node_modules\protractor\node_modules\q\q.js:525:49
at flush (D:\nodejs\node_modules\protractor\node_modules\q\q.js:108:17)
[launcher] Process exited with error code 1

@nainighai
Copy link
Author

Any update, as we need to take the decision on what choice of language / tool to use. With Java Client libraries it is do able to automate Native Apps (Selenium WebDriver + TestNG + Appium), but does not seems to be working with protractor.

@juliemr
Copy link
Member

juliemr commented Feb 15, 2015

Nope, as said, it is not yet implemented. We have a team TODO for this.

@nainighai
Copy link
Author

Thanks for your response.

Can you also let us know what is the ETA to bring in support for Native / Hybrid apps?

@napolitano
Copy link

Testability for hybrid apps running in WebViews is somehow critical and - at least for me - a show-stopper, if not possible. So it is good to read that there is a team TODO for this. Unfortunately an existing TODO does not mean that it will be implemented soon - that's why i would be very happy if a rough statement about the plans on implementing this appears :)

@juliemr
Copy link
Member

juliemr commented Mar 18, 2015

See #1940

@juliemr juliemr closed this as completed Mar 18, 2015
@csharsha
Copy link

Hi juliemr..may i know when is the release date for using protractor for hybrid apps runs in webview..in our project we need to finalize the tool.

@idaneliz
Copy link

idaneliz commented Jun 2, 2015

@napolitano
Copy link

@idaneliz Please have a look on you'r question at stackoverflow.

@bmsoko
Copy link

bmsoko commented Jun 10, 2015

@nainighai how did you setup to be able to test against Android using protractor? can you please share what you've done?

Thanks

@truedrug
Copy link

truedrug commented Sep 5, 2017

hi all,
when ever you are trying to run an apk file directly in to the device and run the test cases through protractor , check that apk you generated should be either in dev or debug stage not in release.
Was facing the same issue and resolved it by changing it to either dev or debug stage./

Hope this works.

@ssudhanshu
Copy link

Hi,
I am trying to run Protractor tests by launching a Hybrid app on a mobile emulator. My app is getting launched but then it is getting closed with the error message: 'WebDriverError: No such context found'.
I have already included autoWebview: 'true' in my conf.js file
Any solution on this would be really helpful.

@wswebcreation
Copy link
Contributor

@ssudhanshu

Your question is better suited for StackOverflow or Gitter. Please ask a question there with the 'protractor' tag or post in the Gitter Channel to get help.

From the the getting help section of the README:

Please ask usage and debugging questions on StackOverflow
(use the "protractor" tag) or in the Angular discussion group. (Please do not ask support questions here on Github.)

Thanks!

@ssudhanshu
Copy link

Thanks @wswebcreation

@babusurendra
Copy link

@wswebcreation is protractor still not supporting for Native App automation?

@wswebcreation
Copy link
Contributor

@babusurendra

True, no native support

@kommuswamy
Copy link

Hi,
I am trying to run Protractor tests by launching a Hybrid app on a mobile emulator. My app is getting launched but then it is getting closed with the error message: 'ERROR - Unable to start a WebDriver session.'
Any solution on this would be really helpful.

@kommuswamy
Copy link

@wswebcreation, Please let me know if it is possible to test Hybrid mobile app (not a web app) using Protractor + Appium.

@wswebcreation
Copy link
Contributor

Hi @kommuswamy

It is possible, only when your hybrid app starts with a Webview. The error you describe is a configuration error. SO or Google can help you with that.

@ssudhanshu
Copy link

Hi @kommuswamy

I was also facing the same issue. Generally, that WebDriver session issue comes when you have a WebView in your app and you have not switched to it. Hybrid apps contain WebViews. You need to switch to them in order to work on it.
Try adding below lines to your config file:
autoWebview: 'true',
autoWebviewTimeout: '10000',

@kommuswamy
Copy link

kommuswamy commented Oct 31, 2017

Hi @ssudhanshu, I am facing same error which you mentioned above "No such context found." after adding the autoWebview: 'true', in my conf.js file. I am seeing the following context are available when I ran the script Available contexts: ["NATIVE_APP","WEBVIEW_com.****.mobile.prod"]
did you file any request in StackOverflow or gitter?

@ssudhanshu
Copy link

Hi @kommuswamy

That means like mine, you have multiple contexts in your app like Native & WebView or multiple WebViews. You need to switch to the particular WebView where your elements are present. To switch to a particular WebView, you need to install wd and wd-bridge. You can use npm to install those. Once you install wd and wd-bridge. Add the below changes in your config and spec file.

I tried this approach and the error of no such context found was resolved.

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

Spec file :
wdBrowser.contexts().then(function (ctxs) {
//console.log(ctxs); //This will give you list of all webviews in your app.
return wdBrowser.context(ctxs[index]); //'index' of your required WebView
})

@kommuswamy
Copy link

Hi @ssudhanshu ,
I am unable to resolve this by using the above solution, please can you provide the sample config file which you are used?

@kommuswamy
Copy link

HI @wswebcreation, my app start with two contexts native and webview. is it possible to automate with the protractor?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests