Howto automate webview facebook login with appium?

down vote
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:

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

return driver
  .then(function (ctxs) {
    return driver.context(ctxs[ctxs.length - 1]);

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.

Just updated chromedriver to version 2.20 and everything works

Click Facebook login button which is native :


Switch to webview context :

//here we getting the list of context
Set<String> contextHandles = wd.getContextHandles();
for (String s : contextHandles) {
System.out.println("Context : " + s);
//if context contains webview then set the webview context
if (s.contains("WEBVIEW")) {

Do Facebook Login Flow in webview :

wd"//input[@name='pass']"".findElement(By.xpath()).sendKeys(<your_password>"); // test password
WebDriverWait driverWait = new WebDriverWait(wd, 10);
driverWait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@name='__CONFIRM__']"))); // waiting for the element to be clickable
System.out.println(wd.getPageSource()); // get the page source 
wd.findElement(By.pathx("//button[@name='__CONFIRM__']")).click(); //  this step login process is done.

Come back to Native view :

// here i need to get the context again
Set<String> contextHandles2 = wd.getContextHandles();
for (String s : contextHandles2) {
System.out.println("Context : " + s);
if (s.contains("NATIVE_APP")) {

Youtube video :,fe=17092,fr=lw-001,fs=17065;fc=0,fcr=0,fi=v-AcBzbhQgDis,r=realtime,rsc=2