Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screenshot is not taken on a real device when webview is used #356

Closed
ania-s opened this issue Dec 17, 2018 · 20 comments
Closed

Screenshot is not taken on a real device when webview is used #356

ania-s opened this issue Dec 17, 2018 · 20 comments

Comments

@ania-s
Copy link

ania-s commented Dec 17, 2018

I tried to take a screenshot on a real device while in webview and it looks that it doesn't work. In native context everything works fine. The log is below:

"appium": "1.11.0-beta.2"

�[35m[HTTP]�[39m �[90m�[39m
�[35m[HTTP]�[39m �[37m-->�[39m �[37mGET�[39m �[37m/wd/hub/session/7d87626b-9c2d-48d3-be53-9fc4697d233a/screenshot�[39m
�[35m[HTTP]�[39m �[90m{}�[39m
�[35m[MJSONWP]�[39m Driver proxy active, passing request on via HTTP proxy
[debug] �[35m[JSONWP Proxy]�[39m Matched '/wd/hub/session/7d87626b-9c2d-48d3-be53-9fc4697d233a/screenshot' to command name 'getScreenshot'
[debug] �[35m[JSONWP Proxy]�[39m Proxying [GET /wd/hub/session/7d87626b-9c2d-48d3-be53-9fc4697d233a/screenshot] to [GET http://127.0.0.1:8006/wd/hub/session/9d4b189c82b882b9e0c1ad5ecf56785e/screenshot] with body: {}
�[35m[HTTP]�[39m �[37m-->�[39m �[37mDELETE�[39m �[37m/wd/hub/session/7d87626b-9c2d-48d3-be53-9fc4697d233a�[39m
�[35m[HTTP]�[39m �[90m{}�[39m
[debug] �[35m[MJSONWP]�[39m Calling AppiumDriver.deleteSession() with args: ["7d87626b-9c2d-48d3-be53-9fc4697d233a"]
[debug] �[35m[BaseDriver]�[39m Event 'quitSessionRequested' logged at 1545036327431 (09:45:27 GMT+0100 (Central European Standard Time))
�[35m[Appium]�[39m Removing session 7d87626b-9c2d-48d3-be53-9fc4697d233a from our master session list
[debug] �[35m[Espresso]�[39m Deleting espresso session
[debug] �[35m[Espresso]�[39m Deleting Espresso server session

@ania-s ania-s changed the title Screenshot is not taken on a real device Screenshot is not taken on a real device when webview is used Dec 17, 2018
@dpgraham dpgraham added the bug label Dec 20, 2018
@mykola-mokhnach
Copy link
Contributor

Do you observe any errors in the logcat output? is FLAG_SECURE set for the view, which is shown on the screen (e. g. is it possible to take a screenshot manually?)

@ania-s
Copy link
Author

ania-s commented Jan 8, 2019

Do you observe any errors in the logcat output? is FLAG_SECURE set for the view, which is shown on the screen (e. g. is it possible to take a screenshot manually?)

Sorry, I somehow missed your question. I do not see any errors and I don't think a flag is set or at least I cannot find it in the source code of the app. What do you mean by taking screenshot manually - directly through the phone/tablet?

@mykola-mokhnach
Copy link
Contributor

What do you mean by taking screenshot manually - directly through the phone/tablet?

Yes, using the special shortcut (for different devices it is different)

@ania-s
Copy link
Author

ania-s commented Jan 9, 2019

What do you mean by taking screenshot manually - directly through the phone/tablet?

Yes, using the special shortcut (for different devices it is different)

I checked it and I can take a screenshot manually using button shortcuts.

@KazuCocoa
Copy link
Member

What about applying #366 if you can build the PR manually?
@ania-s

On my environment, I could not get screenshot without nativeWebScreenshot on both uiautomato2 and espresso driver in webview context. I wonder your case is also similar.

@dpgraham
Copy link
Contributor

@KazuCocoa did your PR resolve this?

@KazuCocoa
Copy link
Member

Not sure. But it should resolve this if the main reason is "webview"

Do you have a time to try out? @ania-s

@ania-s
Copy link
Author

ania-s commented Jan 21, 2019

Sorry for the delay but I was sick. I wanted to check it with the latest appium release, however, I cannot get the tests on android running with it as I get the following error:

ERROR: An unknown server-side error occurred while processing the command. Original error: this.adb.getApplicationInstallState is not a function

Maybe I am missing sth but meanwhile if anyone knows what could be wrong I would appreciate any hint. Thanks

@KazuCocoa
Copy link
Member

Are you fine now?
Try:

  1. npm uninstall -g appium
  2. npm install -g appium@beta

I assume your environment had old modules. You should up to date them.

@ania-s
Copy link
Author

ania-s commented Jan 22, 2019

Are you fine now?
I am better, thanks :)
Try:

  1. npm uninstall -g appium
  2. npm install -g appium@beta

I assume your environment had old modules. You should up to date them.

I tried cleaning everything but I keep on getting this error.

@KazuCocoa
Copy link
Member

What the result of $ npm list -g appium-espresso-driver appium-adb?

The command prints dependency versions

@ania-s
Copy link
Author

ania-s commented Jan 22, 2019

What the result of $ npm list -g appium-espresso-driver appium-adb?

The command prints dependency versions

npm list -g appium-espresso-driver appium-adb
/usr/local/lib
└─┬ appium@1.11.0-beta.3
├─┬ appium-android-driver@4.8.0
│ └── appium-adb@7.2.0
├─┬ appium-espresso-driver@1.7.1
│ └── appium-adb@7.2.0 deduped
├─┬ appium-selendroid-driver@1.13.3
│ └── appium-adb@7.2.0 deduped
└─┬ appium-uiautomator2-driver@1.28.0
└── appium-adb@7.2.0 deduped

@KazuCocoa
Copy link
Member

thanks. I assumed you had older appium-adb which had no getApplicationInstallState

Below was mine which worked.

├─┬ appium@1.11.0-beta.3
│ ├─┬ appium-android-driver@4.8.0
│ │ └── appium-adb@7.2.0
│ ├─┬ appium-espresso-driver@1.7.1
│ │ └── appium-adb@7.2.0  deduped
│ ├─┬ appium-selendroid-driver@1.13.3
│ │ └── appium-adb@7.2.0  deduped
│ └─┬ appium-uiautomator2-driver@1.28.0
│   └── appium-adb@7.2.0  deduped

What about below flow? It can force the espresso driver build with the repository's one.

$ cd /usr/local/lib/node_modules/
$ rm -rf appium-espresso-driver
$ git clone git@github.com:appium/appium-espresso-driver.git
$ cd appium-espresso-driver
$ npm install # then, you can use the lates dependencies in the driver

@ania-s
Copy link
Author

ania-s commented Jan 22, 2019

@KazuCocoa unfortunately it doesn't make any difference. I cleaned my environment one more time as well as tried on a different machine and I cannot get it working. Not it even doesn't install the apps on the device (the testing app & appium), instead it throws the errors, like:

Exception occurred while executing:
java.lang.IllegalArgumentException: Unknown package: io.appium.settings
at com.android.server.pm.Settings.getInstallerPackageNameLPr(Settings.java:5053)
at com.android.server.pm.PackageManagerService.getInstallerPackageName(PackageManagerService.java:27935)
at com.android.server.pm.PackageManagerService.isOrphaned(PackageManagerService.java:27941)
at com.android.server.pm.PackageManagerService.deletePackageVersioned(PackageManagerService.java:24068)
at com.android.server.pm.PackageInstallerService.uninstall(PackageInstallerService.java:996)
at com.android.server.pm.PackageManagerShellCommand.runUninstall(PackageManagerShellCommand.java:912)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:134)
at android.os.ShellCommand.exec(ShellCommand.java:96)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:28745)
at android.os.Binder.shellCommand(Binder.java:581)
at android.os.Binder.onTransact(Binder.java:481)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:3209)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:5103)
at android.os.Binder.execTransact(Binder.java:682)

@KazuCocoa
Copy link
Member

The setting app is probably below in your path.

/usr/local/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk

Can you install it by manual via adb install command?

@ania-s
Copy link
Author

ania-s commented Jan 22, 2019

Please ignore my previous comment - this error was my fault. I fixed it. Now I only get
ERROR: connect ECONNREFUSED 127.0.0.1:4723

I will investigate it a little bit more as appium is not started at all.

@ania-s
Copy link
Author

ania-s commented Jan 24, 2019

I managed to get the most recent version of appium working, however, I still cannot take screenshots on android device. Still the same behavior as previously.

@KazuCocoa
Copy link
Member

With nativeWebScreenshot capability?

Can you share the appium log?
If you can, could you share your logcat as well?

@ania-s
Copy link
Author

ania-s commented Jan 24, 2019

With nativeWebScreenshot capability?

Can you share the appium log?
If you can, could you share your logcat as well?

I didn't use the capability. Now when I added it, it works fine. Thanks for the fix.

@ania-s ania-s closed this as completed Jan 24, 2019
@KazuCocoa
Copy link
Member

Thanks for the report :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants