I am not able to switch to the 'webapp' from native app

enviroment:
1-windows10-64bits
2-python-2.7.14
3-appium-desktop-1.2.6
4-android7.0(huawei honorv9)

problem:
after tap the sign in button from app, the screen go to the webpage which require me to log in.
but I am not able to switch to the [webview] or [webapp].

code pieces:

#find the sign_in btn
amazon_sign_in = self.driver.find_element_by_android_uiautomator(‘new UiSelector().text(“Sign in with Amazon”)’)

#click the sign_in btn and it will direct me to the amazon log in page
amazon_sign_in.click()

#wait for 20 seconds so that the full log in page loaded
sleep(20)

#print the current activity
print (self.driver.current_activity)

#print the list of all the contexts
print (self.driver.contexts)

#print the current context
print (self.driver.current_context)

what I got from the command line by the print:

com.tencent.mtt.MainActivity

[u’NATIVE_APP’]

NATIVE_APP

which seems that I do not have the webview from the printed result.
anyone who have experience for this issue, please help me out and appreciated very much in advance.

If it is a hybrid app, uiautomator viewer will not work to see the elements.

Hi GH_QA

thanks so much for your valuable comments.

just got update from dev, it is pure native app.
and it opens a web app but not webview inside the app.

any good suggestion?

Br
Sean

You must change the context so that when you switch to the appium web application, read the web view.

You must create a method so that each time you have an appium web view, detect if the view is native or webview

In android OS version 6 and above , web_view seems to be disappear from the context , although in UIAutomatorViewer you can view that it is in WebView class.

Hence to conclude , directly automate Hybrid apps in android version 6 and above with UIAutomatorViewer without context switching.

Hi Prasad_Madge

if I use the android6.0.1 Samsung S6 edge, then I can print out both:
[u’NATIVE_APP’, u’WEBVIEW_Terrace’]

but on android7.0, no webview context.

I am not quite understood you suggestions since my testing app is pure native app, how to “directly automate Hybrid apps in android version 6 and above with UIAutomatorViewer without context switching.”

Br
Sean

If you are getting webview context on android version 6 then you need to switch to webview first to automate element inside it.

If it does not shows webview context , although being inside webview class , then you can automate it directly as on android version 7 in your case without worrying about contexts switching.

okay, while on android7, you can see that from the uiautomatorviewer screen I attached, there is no way I can locate the elements like: Email textline and password textline, and that is the problem in front of me.
any suggestion for how to slove this situaton?

Still if the elements are not having any unique properties you can use xpath having properties with class and index . This will work.

Or you can use xpath axes to target your element with respect to some unique element.

Hello
I still face this issue, anyone has resolved it?

android - 7.1.2
appium - 1.18.2