Skip to content

Commit 172ce35

Browse files
authored
fix: proxy request to the espresso server with nativeWebScreenshot (#978)
1 parent 619d177 commit 172ce35

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/commands/screenshot.js

+18
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,21 @@ export async function mobileScreenshots (opts = {}) {
7575
}
7676
return infos;
7777
}
78+
79+
/**
80+
* Return the base 64 encoded screenshot data.
81+
* This method is called only when `appium:nativeWebScreenshot` is enabled
82+
* to avoid proxying requests to the chromedriver.
83+
* Without `appium:nativeWebScreenshot` or disabled, espresso driver
84+
* proxies screenshot endpoint requests to the espresso server directly.
85+
*
86+
* @this {import('../driver').EspressoDriver}
87+
* @returns {Promise<String>}
88+
*/
89+
export async function getScreenshot() {
90+
return String(
91+
await /** @type {import('../espresso-runner').EspressoRunner} */ (
92+
this.espresso
93+
).jwproxy.command('/screenshot', 'GET')
94+
);
95+
}

lib/driver.ts

+1
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ export class EspressoDriver extends AndroidDriver implements ExternalDriver<
735735
mobileStartService = servicesCmds.mobileStartService;
736736
mobileStopService = servicesCmds.mobileStopService;
737737

738+
getScreenshot = screenshotCmds.getScreenshot;
738739
mobileScreenshots = screenshotCmds.mobileScreenshots;
739740

740741
mobileRegisterIdlingResources = idlingResourcesCmds.mobileRegisterIdlingResources;

0 commit comments

Comments
 (0)