I want to verify the Browser Objects When Appium is running in Native Mode

I am Appium in Native Mode and now I want to verify the Browser Objects when I switch to “WEBVIEW” Appium is shutting down can any one help me doing this ?

You have to use driver.context( webview ) to switch over webview content

I am using driver.context(webview) but this is not working as I dont have chrome on my android emulator and I am not able to install chrome driver on my emulator.

try it on real device

Below are the log when I Switch the context to WEBVIEW:

info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“d90bd350-90aa-432e-9d92-f466b238a7d7”}
info: ← POST /wd/hub/session/d90bd350-90aa-432e-9d92-f466b238a7d7/element/25/value 200 7583.272 ms - 76 {“status”:0,“value”:true,“sessionId”:“d90bd350-90aa-432e-9d92-f466b238a7d7”}
info: → GET /wd/hub/session/d90bd350-90aa-432e-9d92-f466b238a7d7/contexts {}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: C:\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell “cat /proc/net/unix”
info: [debug] WEBVIEW_16844 mapped to pid 16844
info: [debug] Getting process name for webview
info: [debug] executing cmd: C:\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell “ps”
info: [debug] Parsed pid: 16844 pkg: com.android.browser
info: [debug] from: u0_a22,16844,9587,1160348,108320,futex_wait,f72b51e2,S,com.android.browser
info: [debug] returning process name: com.android.browser
info: [debug] Available contexts:
info: [debug] [“WEBVIEW_com.android.browser”]
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.android.browser
info: [debug] Responding to client with success: {“status”:0,“value”:[“NATIVE_APP”,“WEBVIEW_com.android.browser”],“sessionId”:“d90bd350-90aa-432e-9d92-f466b238a7d7”}
info: ← GET /wd/hub/session/d90bd350-90aa-432e-9d92-f466b238a7d7/contexts 200 228.932 ms - 116 {“status”:0,“value”:[“NATIVE_APP”,“WEBVIEW_com.android.browser”],“sessionId”:“d90bd350-90aa-432e-9d92-f466b238a7d7”}
info: → POST /wd/hub/session/d90bd350-90aa-432e-9d92-f466b238a7d7/context {“name”:“WEBVIEW_com.android.browser”}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: C:\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell “cat /proc/net/unix”
info: [debug] WEBVIEW_16844 mapped to pid 16844
info: [debug] Getting process name for webview
info: [debug] executing cmd: C:\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell “ps”
info: [debug] Parsed pid: 16844 pkg: com.android.browser
info: [debug] from: u0_a22,16844,9587,1160348,108376,futex_wait,f72b51e2,S,com.android.browser
info: [debug] returning process name: com.android.browser
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.android.browser
info: [debug] [“WEBVIEW_com.android.browser”]
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.android.browser
info: [debug] Connecting to chrome-backed webview
info: Chromedriver: Changed state to ‘starting’
info: Chromedriver: Set chromedriver binary as: C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe
info: Chromedriver: Killing any old chromedrivers, running: FOR /F “usebackq tokens=5” %a in (netstat -nao ^| findstr /R /C:"9515 ") do (FOR /F “usebackq” %b in (TASKLIST /FI "PID eq %a" ^| findstr /I chromedriver.exe) do (IF NOT %b==“” TASKKILL /F /PID %a))
info: Chromedriver: No old chromedrivers seemed to exist
info: Chromedriver: Spawning chromedriver with: C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe --url-base=wd/hub --port=9515
info: Chromedriver: [STDOUT] Starting ChromeDriver 2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a) on port 9515
Only local connections are allowed.
info: JSONWP Proxy: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: JSONWP Proxy: Got response with status 200: “{"sessionId":"","status":0,"value":{"build":{"version":"alpha"},"os":{"arch":"x86_64","name":"Windows NT","version":"6.3"}}}”
info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {“desiredCapabilities”:{“chromeOptions”:{“androidPackage”:“com.certesnetworks.cryptoflow”,“androidUseRunningApp”:true,“androidDeviceSerial”:“192.168.56.101:5555”}}}
info: [debug] Didn’t get a new command in 60 secs, shutting down…
info: Shutting down appium session
info: [debug] Pressing the HOME button
info: [debug] executing cmd: C:\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell “input keyevent 3”
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“shutdown”}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:“OK, shutting down”}
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 127.622
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] We shut down because no new commands came in

First check view whether it is native or webview:
Set contextNames = Appiumsetup.driver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextName);
if (contextName.contains(“WEBVIEW”)){
Appiumsetup.driver.context(contextName);
}
}

Below is the output -

NATIVE_APP
WEBVIEW_com.android.browser

please provide screenshot of what you want to inspect

Please find the attached screen shot

I want to verify the title or some text on this Browser Page.

If you want to verify the title then you have to use
assert driver.gettitle().equals(“text”):’’“Titlte is not correct”;

Below is the exception for driver.getTitle() Method -

org.openqa.selenium.WebDriverException: Not yet implemented. Please help us: http://appium.io/get-involved.html (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 21 milliseconds
Build info: version: ‘2.53.0’, revision: ‘35ae25b’, time: ‘2016-03-15 16:57:40’
System info: host: ‘admin’, ip: ‘192.168.84.2’, os.name: ‘Windows 8.1’, os.arch: ‘amd64’, os.version: ‘6.3’, java.version: ‘1.7.0_79’
Session ID: d50fd39a-f099-4d46-9655-17e655e30c9a
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{platform=LINUX, app=C:\Users\admin1\workspace\NewAppium\Apps\app-universal-debug.apk, javascriptEnabled=true, browserName=Android, networkConnectionEnabled=true, desired={app=C:\Users\admin1\workspace\NewAppium\Apps\app-universal-debug.apk, platformVersion=6.0.0, NEW_COMMAND_TIMEOUT=90, platformName=Android, deviceName=Google_Nexus_5_6.0.0_API_23, app-package=com.certesnetworks.cryptoflow, device=Android}, locationContextEnabled=false, platformVersion=6.0, NEW_COMMAND_TIMEOUT=90, databaseEnabled=false, platformName=Android, deviceName=192.168.56.101:5555, app-package=com.certesnetworks.cryptoflow, webStorageEnabled=false, device=Android, warnings={}, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:43)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.getTitle(RemoteWebDriver.java:320)
at AndroidTest.accessSecureApp(AndroidTest.java:156)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)