How can i select element in webview popup inside Android app

We have an app that allow user login with Facebook and i want to automate testing it too.
So the flow is user click Facebook button, a popup appear that allow user enter email and password to sign in with Facebook account.

But i still dont know how to select the input: Email and Password to run method send_keys.
I try to use:

web = driver.available_contexts.last #Web context is last one
within_context web do 
  # Select element here
end

but it always throw exception:

Selenium::WebDriver::Error::UnknownError: We already have a chromedriver instance running
#or
Did not get session redirect from Chromedriver.

I already updated the lastest version of chromdriver and selenium and the same result when i try with

set_context web

too.

Thanks for your help.

What the output of puts available_contexts after clicking on Login with Facebook button
In my case also, FB pop up opens up on clicking login with fb buttton. But there is only one available context [“Native_APP”]. And i have to just find elements on pop up and tap Log in button. It is working fine for me.

Because in that case you already installed Facebook App @shankybnl. In my case i want to test when there is no Facebook app in phone yet. And the output of puts available_contexts is ["Native_APP", "Web Page"]

Hi Vu_Van_Ly,

No facebook app is not installed on my device. Actually on real device, i do not see any webview and able to perform all actions in NATIVE_APP context only. While on emulator, i could see WEBVIEW context and perform all the actions (and finding elements By.xpath("//input[@name=‘firstName’]" on the web page) after switching to WEBVIEW context.

I am using ChromeDriver (v2.9.248307), appium version: 1.3.1 and selenium webdriver (v2.42.0) on Mac OSX. I am not getting any error while switching to WEBVIEW.