Skip to content

Commit

Permalink
fix: proxy request to the espresso server with nativeWebScreenshot (#978
Browse files Browse the repository at this point in the history
)
  • Loading branch information
KazuCocoa authored Feb 6, 2024
1 parent 619d177 commit 172ce35
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/commands/screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,21 @@ export async function mobileScreenshots (opts = {}) {
}
return infos;
}

/**
* Return the base 64 encoded screenshot data.
* This method is called only when `appium:nativeWebScreenshot` is enabled
* to avoid proxying requests to the chromedriver.
* Without `appium:nativeWebScreenshot` or disabled, espresso driver
* proxies screenshot endpoint requests to the espresso server directly.
*
* @this {import('../driver').EspressoDriver}
* @returns {Promise<String>}
*/
export async function getScreenshot() {
return String(
await /** @type {import('../espresso-runner').EspressoRunner} */ (
this.espresso
).jwproxy.command('/screenshot', 'GET')
);
}
1 change: 1 addition & 0 deletions lib/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ export class EspressoDriver extends AndroidDriver implements ExternalDriver<
mobileStartService = servicesCmds.mobileStartService;
mobileStopService = servicesCmds.mobileStopService;

getScreenshot = screenshotCmds.getScreenshot;
mobileScreenshots = screenshotCmds.mobileScreenshots;

mobileRegisterIdlingResources = idlingResourcesCmds.mobileRegisterIdlingResources;
Expand Down

0 comments on commit 172ce35

Please sign in to comment.