How to get the page source of webpage in hybrid android app ? and how to locate an ID?

I’m trying to get an web page source in my hybrid app.
Actually i need to get an text field id of my web page which is located in my native app frame-layout.

Am I need to switch Web view or What to do to get page source ? ? ?

How to locate an user name and password field ?

used below code :

System.out.println("source : "+ driver.getPageSource()); 

Yes you need to switch to webview in order to get the page source.

Once you switch to the webview rest is pure selenium web automation. You can use id/css/class name as you would use for a webpage.

Hope it helps.

1 Like

Hi @pr4bh4sh when i using


I’m getting below error… Do u have any idea abt it ? ? ? and I’m using AndroidDriver…

org.openqa.selenium.WebDriverException: Not yet implemented. Please help us: (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 9 milliseconds
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'I.local', ip: '', 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.2', java.version: '1.8.0_25'
Driver info:
Capabilities [{networkConnectionEnabled=true, desired={}, platformVersion=4.1, warnings={}, webStorageEnabled=false, locationContextEnabled=false, browserName=Android, takesScreenshot=true, javascriptEnabled=true, databaseEnabled=false, platform=LINUX}]
Session ID: 43d8a251-b761-4195-be58-a6827ee2f26d
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
    at java.lang.reflect.Constructor.newInstance(
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(
    at org.openqa.selenium.remote.RemoteWebDriver.execute(
    at io.appium.java_client.AppiumDriver.execute(
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.window(
    at sneerglaw.ESFile.sample(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.testng.internal.MethodInvocationHelper.invokeMethod(
    at org.testng.internal.Invoker.invokeMethod(
    at org.testng.internal.Invoker.invokeTestMethod(
    at org.testng.internal.Invoker.invokeTestMethods(
    at org.testng.internal.TestMethodWorker.invokeTestMethods(
    at org.testng.TestRunner.privateRun(
    at org.testng.SuiteRunner.runTest(
    at org.testng.SuiteRunner.runSequentially(
    at org.testng.SuiteRunner.privateRun(
    at org.testng.SuiteRunnerWorker.runSuite(
    at org.testng.TestNG.runSuitesSequentially(
    at org.testng.TestNG.runSuitesLocally(
    at org.testng.remote.RemoteTestNG.initAndRun(
    at org.testng.remote.RemoteTestNG.main(

For switching between context you need to use Appium java client bindings.

driver.context("the web view context you wish to switch");

Refer this thread.

Hey thanks man… I got a solution its working now… :+1:

Thats great.
If you got solution other than what I suggested please share it so someone else in future faces the same issue can use it.

1 Like

yeah sure. :relaxed:

@Muhammed_Yusuf : I have similar issue , could you please share the code or clear guideline , how did you switch and how did you get page source and how did you work with web controls in the Native App.