Termosfera Termosfera - 1 month ago 20
Node.js Question

Howto automate webview facebook login with appium

I´m trying to write an appium functional test in node.js.
The problem comes when I switch to the webdrivers context.

Here are my contexts:

[ 'NATIVE_APP', 'WEBVIEW_com.******.***.development' ]


This is the test case code:

"use strict";

var wd = require("wd");

require('colors');
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
var should = chai.should();
chaiAsPromised.transferPromiseness = wd.transferPromiseness;

var wd = require("wd");

describe("android simple", function () {
this.timeout(300000);
var driver;
var allPassed = true;

before(function () {
driver = wd.promiseChainRemote({
host: 'localhost',
port: 4723
});

driver.on('status', function (info) {
console.log(info.cyan);
});
driver.on('command', function (meth, path, data) {
console.log(' > ' + meth.yellow, path.grey, data || '');
});
driver.on('http', function (meth, path, data) {
console.log(' > ' + meth.magenta, path, (data || '').grey);
});

var desired = {
'browserName': '',
'appium-version': '1.3',
'platformName': 'Android',
'platformVersion': '4.4.2',
'deviceName': 'Android Emulator',
'app': "path/to/apk"
};

return driver
.init(desired)
.setImplicitWaitTimeout(3000);
});

after(function () {
return driver
.quit()
.finally(function () {
if (process.env.SAUCE) {
return driver.sauceJobStatus(allPassed);
}
});
});

afterEach(function () {
allPassed = allPassed && this.currentTest.state === 'passed';
});

it("should find facebook login button", function () {

return driver
.elementById('facebook_login_button')
.click()
.sleep(10000)
.contexts()
.then(function (ctxs) {
console.log(ctxs);
return driver.context(ctxs[ctxs.length - 1]);
})
.elementByName('email')
.sendKeys('test.*****@gmail.com')
.sleep(5000)
;
});
});


And the output error from appium server:

error: Chromedriver: Error: An unknown server-side error occurred while processing the command. (Original error: unknown error: Device emulator-5554 is not online
(Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 10.0 x86_64))
at JWProxy.command$ (lib/proxy.js:149:15)
at tryCatch
status: 13,
value: { message: 'unknown error: Device emulator-5554 is not online\n (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 10.0 x86_64)' },
httpCode: 200 }

Thanks in advance.

Answer

I finally solved the problem. It just was a chromedriver bug. Updated to version 2.20 and everything works fine.

Github issue: https://github.com/appium/appium/issues/5616

Chromedriver release notes: https://sites.google.com/a/chromium.org/chromedriver/downloads