appium / java-client

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol
Apache License 2.0
1.21k stars 756 forks source link

On Android: getScreenshotAs returns com.google.common.collect.Maps$TransformedEntriesMap instead of byte array #1596

Open darkfrog26 opened 2 years ago

darkfrog26 commented 2 years ago

Description

On Android, when I'm attempting to call getScreenshotAs(OutputType.BYTES), under certain situations, it fires:

java.lang.RuntimeException: Unexpected result for screenshot command: com.google.common.collect.Maps$TransformedEntriesMap instance
        at org.openqa.selenium.remote.RemoteWebDriver.getScreenshotAs(RemoteWebDriver.java:357)

This is running against BrowserStack on a Samsung Galaxy S21 Ultra. It appears to be related to switching contexts to Native before.

Environment

Code To Reproduce Issue [ Good To Have ]

driver.getScreenshotAs(OutputType.BYTES)

Exception Stacktraces

See above

Link To Appium Logs

I would be happy to send a link to the BrowserStack Appium logs directly, but it appears to include some of the credential information, so I wouldn't want to post it here. I've seen other references to this problem in other tickets though, so I'm assuming this isn't a new problem.

darkfrog26 commented 2 years ago

Looking at the Appium logs, it appears to be related to a timeout:

2021-11-22 14:34:31:373 - [debug] [WD Proxy] Matched '/wd/hub/session/4a4698ea-f25f-469e-8e31-90a201990172/screenshot' to command name 'getScreenshot'
2021-11-22 14:34:31:373 - [debug] [WD Proxy] Proxying [GET /wd/hub/session/4a4698ea-f25f-469e-8e31-90a201990172/screenshot] to [GET http://127.0.0.1:18083/wd/hub/session/87dbe5230dbd298abe010d16ea927c6b/screenshot] with no body
2021-11-22 14:35:31:450 - [WD Proxy] Got response with status 500: {"value":{"error":"timeout","message":"timeout: Timed out receiving message from renderer: 10.000\n  (Session info: chrome=94.0.4606.61)","stacktrace":"#0 0x55d54fabf8f3 <unknown>\n#1 0x55d54f5a4ba8 <unknown>\n#2 0x55d54f5907eb <unknown>\n#3 0x55d54f58f4c3 <unknown>\n#4 0x55d54f58f91c <unknown>\n#5 0x55d54f5ac057 <unknown>\n#6 0x55d54f61751e <unknown>\n#7 0x55d54f5f7e72 <unknown>\n#8 0x55d54f60adac <unknown>\n#9 0x55d54f5f7d63 <unknown>\n#10 0x55d54f5ce144 <unknown>\n#11 0x55d54f5cf135 <unknown>\n#12 0x55d54faeec3e <unknown>\n#13 0x55d54fb046b7 <unknown>\n#14 0x55d54faefb95 <unknown>\n#15 0x55d54fb05b05 <unknown>\n#16 0x55d54fae42ab <unknown>\n#17 0x55d54fb20248 <unknown>\n#18 0x55d54fb203c8 <unknown>\n#19 0x55d54fb3b33d <unknown>\n#20 0x7fac6a78be9e start_thread\n"}}
2021-11-22 14:35:31:451 - [debug] [W3C] Matched W3C error code 'timeout' to TimeoutError
2021-11-22 14:35:31:453 - [HTTP] <-- GET /wd/hub/session/4a4698ea-f25f-469e-8e31-90a201990172/screenshot 408 60081 ms - 778
darkfrog26 commented 2 years ago

I'm able to grab screenshots at earlier stages, but I'm in the process of trying to natively select a file to upload, and after I select and click: By.xpath(s"//android.widget.FrameLayout[@clickable=\"true\" and @content-desc=\"$firstImage\"]") in the native context, it can't seem to grab a screenshot.

mykola-mokhnach commented 2 years ago

Duplicate of https://github.com/search?q=org%3Aappium+%22Timed+out+receiving+message+from+renderer%22&type=issues