Facebook authentication webview fails to be detected by Appium

I am using Appium 1.2.3 in Selendroid mode where I use Facebook to login to the applicaiton under test. I am monitoring the available webviews using Appium and Chrome remote debugging and comparing the results. The scenario is as follows:

  • I click on the Login with Facebook button
  • Facebook login page is opened in a new webview named “WEBVIEW_0”.
  • I switch to the new context, type the username and password and click on Login button.
  • Facebook shows an authentication message saying that I already authenticated the app before and asks to re-authorize again to use my credentials, I click on the OK button.
  • Authentication message appears again on the screen displaying the same screen as before and I have to click on the Ok button again in order to move on and login successfully.

When I get the available context handles, Appium returns only one context and when I get the page source using Appium it shows no elements on the page, it only shows the reply I got back from Facebook API about my successful login session details. When I inspect with Chrome remote debugging I find that there is a new context opened. The new context is the reply from the Facebook API about the session ID which Appium captures and can see, but the other context is the one I am actually seeing on the screen showing the UI elements (there is two webviews, but Appium only shows one webview and can’t see the other).

I asked my developers about this issue and they said that there is a bug with the Facebook API integration causing the authentication message to appear twice. This is not the issue though as Appium must show all the context handles that are available correctly as Chrome remote debugging shows.

Here is the view from Chrome remote debugging:

The first webview is the one Appium can’t see anymore. This is a blocking issue for me. Have anyone faced such issue before??

Bug reported on Github: https://github.com/appium/appium/issues/3802