Please refer below post for automating webview app:
Prerequisites:
apk with setWebContentsDebuggingEnabled flag set to true,
desktop chrome browser to inspect elements
Java code for automating hybrid apps:
// Switching to webview
Set<String> contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextNames); //prints out something like [NATIVE_APP, WEBVIEW_<APP_PKG_NAME>]
}
driver.context(contextNames.toArray()[1]); // set context to WEBVIEW_<APP_PKG_NAME>
// do web testing
String myText = driver.findElement(By.cssSelector(".green_button")).click();
// Switching back to NATIVE_APP
driver.context("NATIVE_APP");
// do more native testing if we want
driver.findElement(By.name("home")).click();
Inspecting WEBVIEW elements of application:
Refer link:https://developer.chrome.com/devtools/docs/remote-debugging#configure-webview
Appium comes with built-in hybrid support via Chromedriver. Appium also uses Selendroid under the hood for webview support on devices older than 4.4. (In that case, you’ll want to specify "automationName": "selendroid" as a desired capability).
Make sure setWebContentsDebuggingEnabled is set to true.