webdriverio / appium-boilerplate

Boilerplate project to run WebdriverIO tests with Appium to test native applications on iOS and Android
MIT License
452 stars 262 forks source link

Webview context not loaded #33

Closed shuma closed 4 years ago

shuma commented 4 years ago

Describe your question with as much detail as possible The WebView context does not load in Android, it works in iOS.

If it's about a specific piece of code, try and include some of it to support your question. iOS output

[0-0] RUNNING in iOS - /tests/specs/app.webview.spec.js
[0-0] [ 'NATIVE_APP' ]
[0-0] [ 'NATIVE_APP', 'WEBVIEW_76375.2' ]
[0-0] [ 'NATIVE_APP', 'WEBVIEW_76375.2' ]
[0-0] [ 'NATIVE_APP', 'WEBVIEW_76375.2' ]
[0-0] [ 'NATIVE_APP', 'WEBVIEW_76375.2' ]
[0-0] [ 'NATIVE_APP', 'WEBVIEW_76375.2' ]
[0-0] PASSED in iOS - /tests/specs/app.webview.spec.js

Android output


[emulator-5554 LINUX 8.0.0 #0-0] 1) WebdriverIO and Appium, when interacting with a WebView, should be able to open call action on the Iframe page
[emulator-5554 LINUX 8.0.0 #0-0] Error: Webview context not loaded
[emulator-5554 LINUX 8.0.0 #0-0] Error: Webview context not loaded
[emulator-5554 LINUX 8.0.0 #0-0]     at WebViewScreen.waitForWebViewContextLoaded (/Users/usman.rajab/Desktop/tink/TinkLinkDemo/integration_aws_device_farm/tests/helpers/WebView.js:21:16)
[emulator-5554 LINUX 8.0.0 #0-0]     at WebViewScreen.waitForWebsiteLoaded (/Users/usman.rajab/Desktop/tink/TinkLinkDemo/integration_aws_device_farm/tests/helpers/WebView.js:69:14)
[emulator-5554 LINUX 8.0.0 #0-0]     at UserContext.beforeEach (/Users/usman.rajab/Desktop/tink/TinkLinkDemo/integration_aws_device_farm/tests/specs/app.webview.spec.js:6:19)
[emulator-5554 LINUX 8.0.0 #0-0] Error: Malformed type for "name" parameter of command switchContext
Expected: string
Actual: undefined

For more info see https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#webviews-and-other-contexts

Environment (please complete the following information):

wswebcreation commented 4 years ago

Thanks for filling an issue. Can you please tell us which app you are using? 9 out of 10 times the reason for this to happen is that the Android app isn't a "debug" build. This is a build where the Webview is enabled to be accessible.

shuma commented 4 years ago

We created on simple react native app that have webview component. Still getting the same issue when build the app in "debug" build. Build a debug APK in the command line like this: :gradlew assembleDebug

wswebcreation commented 4 years ago

You need to adjust your build for that one, not through the command line, see https://github.com/react-native-community/react-native-webview/blob/master/docs/Debugging.md#android--chrome

Because this is not an issue with the boilerplate and the app itself I'm going to close the issue, it's still open for discussion

shuma commented 4 years ago

Build a bew debug build, enabled web contents debugging in Main.java. Created a new app-debug.apk file, fix correct chromedriver version. It runs but and the log is:

[0-0] [ 'NATIVE_APP', 'WEBVIEW_chrome' ]
[0-0] [ 'NATIVE_APP', 'WEBVIEW_chrome' ]
[0-0] [ 'NATIVE_APP', 'WEBVIEW_chrome' ]

It opens the app then but quickly close the app then it get stuck like this doing nothing. @wswebcreation

wswebcreation commented 4 years ago

Can you share your script then because it is now showing the webview, you only need to switch to it

shuma commented 4 years ago

This my wdio.android.conf.js:

our simple test app.webview.spec.js

wswebcreation commented 4 years ago

And what is not working now?

shuma commented 4 years ago

It can only switch to webview when open a google chrome browser in the emulator, I dont think it finds the webview in the app itself. It get stuck doing nothing, getting no error.

have you tried building a tiny rn app with this bolierplate, if so can you share it with me?

wswebcreation commented 4 years ago

@shuma

A demo app can be found here https://github.com/webdriverio/native-demo-app

It works like it should.