question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

screenshot failed !

See original GitHub issue

When I do screenshots, it throws the following exception


selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: io.appium.uiautomator2.common.exceptions.TakeScreenshotException: Failed to capture a screenshot. Does the current view have 'secure' flag set?
	at io.appium.uiautomator2.utils.ScreenshotHelper.takeDeviceScreenshot(ScreenshotHelper.java:70)
	at io.appium.uiautomator2.utils.ScreenshotHelper.takeScreenshot(ScreenshotHelper.java:48)
	at io.appium.uiautomator2.utils.ScreenshotHelper.takeScreenshot(ScreenshotHelper.java:63)
	at io.appium.uiautomator2.handler.CaptureScreenshot.safeHandle(CaptureScreenshot.java:19)
	at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:36)
	at io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:250)
	at io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:241)
	at io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:44)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:611)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:514)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:468)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438)
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
	at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
	at java.lang.Thread.run(Thread.java:818)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
devyanib7commented, May 8, 2020

Yes. I tried everything vysor, screen mirror, capture the specific object using appium nothing worked. I wonder how AWS device farm was able to capture the video without any issues!. Anyways thanks for confirming that UIAutomator2 or appium doesn’t support capturing screens with secure flag set. On Tue, May 5, 2020 at 7:24 AM Kazuaki Matsuo @.***> wrote: secure source set to true. Do you mean https://developer.android.com/reference/android/view/WindowManager.LayoutParams#FLAG_SECURE ? Then, we can not get screenshot technically. It is the limitation of Android framework. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#275 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGLABG66PF2GDL4PVFCYSADRQAHRLANCNFSM4HNZXJ2A . – Thanks and Regards, Lavanya Bathina 303-676-7825

I was also facing same exception from last one week & tried out different ways for taking screenshots but nothing worked out. In between 2-3 times it worked but it took random screenshots of whatever was open on my laptop screen & not of the android application. So yea i agree with you appium doesn’t allow taking screenshots with FLAG_SECURE enabled for security purposes. Also i think DeviceFarm uses some different functionality for screen capture & recordings as it works fine over there.

0reactions
lbathinacommented, May 8, 2020

I was able to capture screen shots of video using scrcpy. record using scrcpy and then using opencv captured frames from the video. here is the Java code snippet for scrcpy:

String filename=path + "/video.mp4";
			List<String> list = new ArrayList<String>(); 
			list.add("scrcpy");
			list.add("-Nr");
			list.add(filename);
			ProcessBuilder build = new ProcessBuilder(list); 
			build.inheritIO();
	
			Process proc = build.start();
			Thread.sleep(durationMs);
			proc.destroy();

hope it helps anyone who might be interested to use it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Screenshot failed error? : r/ffxiv
I was able to take screenshots last night before the update, but after the update I've been getting "Screenshot failed." errors.
Read more >
FINAL FANTASY XIV Forum
Screenshots have appeared to have broken with today's patch. Verified the screenshot folder config "D:\Documents\My Games\FINAL FANTASY XIV ...
Read more >
"Failed to capture a screenshot" | Apple Developer Forums
For some reason with Xcode 9 and my iPhone X I continuously get the error "Failed to capture a screenshot" when attempting to...
Read more >
How to take Screenshot of Failed Test Cases in Cucumber
Screenshots provide better quality and flexibility while debugging failed scenarios. How to Set up a Cucumber Project. Let's first set up the ...
Read more >
How To Capture Screenshot of Failed Test Cases Using ...
Capture Screenshot of Failed Test Cases Using Selenium WebDriver - We use ITestResult Interface and capture screenshot of failed test cases.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found