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

fix: proxy request to the espresso server with nativeWebScreenshot #978

Merged
merged 2 commits into from
Feb 6, 2024

Conversation

KazuCocoa
Copy link
Member

@KazuCocoa KazuCocoa commented Feb 6, 2024

Fixes appium/appium-inspector#1273

With nativeWebScreenshot, we want to proxy requests to the espresso server instead of the chromedriver. To handle it, we should add getScreenshot explicitly to prevent not implemented error.

if (this.opts.nativeWebScreenshot) {
this.jwpProxyAvoid = /**@type {import('@appium/types').RouteMatcher[]} */([
...this.jwpProxyAvoid,
['GET', new RegExp('^/session/[^/]+/screenshot')]

It looks like the removal of getScreenshot occurred in the appium-android-driver major version update as appium/appium-inspector#1273 (comment), but the implementation also raised throw new errors.NotImplementedError('Not implemented'); so I guess somewhere overridend before.

Tested with "appium:nativeWebScreenshot": true and without it.

e.g.

[HTTP] --> GET /session/b71600c9-5df2-4b1c-8620-aebe7a42824c/screenshot
[HTTP] {}
[EspressoDriver@fdec (b71600c9)] Calling AppiumDriver.getScreenshot() with args: ["b71600c9-5df2-4b1c-8620-aebe7a42824c"]
[EspressoDriver@fdec (b71600c9)] Matched '/screenshot' to command name 'getScreenshot'
[EspressoDriver@fdec (b71600c9)] Proxying [GET /screenshot] to [GET http://127.0.0.1:8300/session/5bfd9d79-6f5b-4b81-b0bb-c6ab17687a75/screenshot] with no body
[EspressoDriver@fdec (b71600c9)] Got response with status 200: {"id":"d7d7bace-940f-4977-923e-ae7404f64b7e","sessionId":"5bfd9d79-6f5b-4b81-b0bb-c6ab17687a75","value":"iVBORw0KGgoAAAANSUhEUgAABDgAAAlgCAIAAADieBCCAAAAAXNSR0IArs4c6QAAAANzQklUCAgI2+FP4AAAIABJREFUeJzs3Xl8TPfi//EzSSQiu4QQEVuI2EI2WxCEUrVXS2kpqlRxWy1fpa22FG1vq9L91i29lP7aqqVFxR6VhZAIEkGQzZJN9k1mfn/M4zvfuedMJpOZSXLwev7Rx8yZcz7nkxnn3s/7nM+i8Pb2FgAAAABATiwauwIAAAAAIEZQAQAAACA7BBUAAAAAskNQAQAAACA7BBUAAAAAskNQAQAAACA7BBUAAAAAskNQAQAAACA7BBUAAAAAskNQAQAAACA7BBUAAAAAsmPV2BXAw83S0tLd3X3EiBGDBg3y9vZu3ry5IAj5+fmpqamnTp06ePDgnTt3qqurG7uaAAAAeMgovL29G7sOePgoFIouXbqsXbu2e/fulpaWCoVC524qlUqpVCYlJb377ruJiYkqlaqB66lHkyZN2rVrJwjCrVu3qqqqGrs6AAAA+C8EFdRZmzZtjh07JghCTflESh1RfH195fB0pVmzZp06dZo4ceKwYcMEQTh27NiuXbuuX79eWlra2FUDAACy5ujo2LVrV19fX0dHR/V/1dsLCwuTkpLU/01OTi4sLGzceor4+vomJSWZq6iVK1fq/Gjt2rXmOosaQUWOXFxcwsLCAgICRNsTExMPHz589+7dRqmVIAhNmzbdsWNHt27dLCyMGd20d+/epUuXmr1WhrO0tBw0aND06dMDAgLs7OzUf4VSqSwpKYmLi9u+fXtkZKQcopSGnZ3d5MmTPT09Ddn5/v37J0+evHr1akVFRX1XDACAx0qbNm3CwsJGjBjRt29fQ/aPiYmJiIg4fPhwZmZmfdetVpMmTZo8efL06dPNUlrf...
[EspressoDriver@fdec (b71600c9)] Responding to client with driver.getScreenshot() result: "iVBORw0KGgoAAAANSUhEUgAABDgAAAlgCAIAAADieBCCAAAAAXNSR0IArs4c6QAAAANzQklUCAgI2+FP4AAAIABJREFUeJzs3Xl8TPfi//EzSSQiu4QQEVuI2EI2WxCEUrVXS2kpqlRxWy1fpa22FG1vq9L91i29lP7aqqVFxR6VhZAIEkGQzZJN9k1mfn/M4zvfuedMJpOZSXLwev7Rx8yZcz7nkxnn3s/7nM+i8Pb2FgAAAABATiwauwIAAAAAIEZQAQAAACA7BBUAAAAAskNQAQAAACA7BBUAAAAAskNQAQAAACA7BBUAAAAAskNQAQAAACA7BBUAAAAAskNQAQAAACA7BBUAAAAAsmPV2BXAw83S0tLd3X3EiBGDBg3y9vZu3ry5IAj5+fmpqamnTp06ePDgnTt3qqurG7uaAAAAeMgovL29G7sOePgoFIouXbqsXbu2e/fulpaWCoVC524qlUqpVCYlJb377ruJiYkqlaqB66lHkyZN2rVrJwjCrVu3qqqqGrs6AAAA+C8EFdRZmzZtjh07JghCTflESh1RfH195fB0pVmzZp06dZo4ceKwYcMEQTh27NiuXbuuX79eWlra2FUDAACy5ujo2LVrV19fX0dHR/V/1dsLCwuTkpLU/01OTi4sLGzceor4+vomJSWZq6iVK1fq/Gjt2rXmOosaQUWOXFxcwsLCAgICRNsTExMPHz589+7dRqmVIAhNmzbdsWNHt27dLCyMGd20d+/epUuXmr1WhrO0tBw0aND06dMDAgLs7OzUf4VSqSwpKYmLi9u+fXtkZKQcopSGnZ3d5MmTPT09Ddn5/v37J0+evHr1akVFRX1XDACAx0qbNm3CwsJGjBjRt29fQ/aPiYmJiIg4fPhwZmZmfdetVpMmTZo8efL06dPNUlrfvn23bdum86MZM2bExMSY5SxqjFGRo+7du0+YMKFnz56i7d7e3nfu3GmsoOLp6Xno0KEmTZoYXUJYWJhCoVCpVLa2tmVlZWasm36Wlpbq...
[HTTP] <-- GET /session/b71600c9-5df2-4b1c-8620-aebe7a42824c/screenshot 200 216 ms - 93256
[HTTP]
[HTTP] --> DELETE /session/b71600c9-5df2-4b1c-8620-aebe7a42824c

cc @eglitise

@eglitise
Copy link

eglitise commented Feb 6, 2024

I noticed that the UiA2 version of this method also has handling for MJPEG streaming. Not sure how difficult would it be to add here. Older Espresso driver versions (2.25.9) also don't seem to work with MJPEG, so I guess it's not necessary to add here, but still, would be nice to have.

@mykola-mokhnach
Copy link
Contributor

typo in the PR title

@KazuCocoa KazuCocoa changed the title fix: proxy resuest to the espresso server with nativeWebScreenshot fix: proxy request to the espresso server with nativeWebScreenshot Feb 6, 2024
@KazuCocoa KazuCocoa merged commit 172ce35 into master Feb 6, 2024
14 of 17 checks passed
@KazuCocoa KazuCocoa deleted the fix-proxy-screenshot branch February 6, 2024 15:59
github-actions bot pushed a commit that referenced this pull request Feb 6, 2024
## [2.34.4](v2.34.3...v2.34.4) (2024-02-06)

### Bug Fixes

* proxy request to the espresso server with nativeWebScreenshot ([#978](#978)) ([172ce35](172ce35))
Copy link

github-actions bot commented Feb 6, 2024

🎉 This PR is included in version 2.34.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

bug: screenshot is not loaded with Espresso driver
3 participants