Enable screenshot for physical devices

Summary: Uses idb to get screenshot for physical devices.

Reviewed By: jknoxville

Differential Revision: D24017656

fbshipit-source-id: 89ffd17259d6f94d03a1442ffb341b79797f260b
This commit is contained in:
Pritesh Nandgaonkar
2020-09-30 10:08:47 -07:00
committed by Facebook GitHub Bot
parent a92aa126ae
commit 7358711e07
2 changed files with 8 additions and 2 deletions

View File

@@ -56,7 +56,10 @@ export default class IOSDevice extends BaseDevice {
const tmpImageName = uuid() + '.png';
const tmpDirectory = (electron.app || electron.remote.app).getPath('temp');
const tmpFilePath = path.join(tmpDirectory, tmpImageName);
const command = `xcrun simctl io booted screenshot ${tmpFilePath}`;
const command =
this.deviceType === 'emulator'
? `xcrun simctl io booted screenshot ${tmpFilePath}`
: `idb screenshot --udid ${this.serial} ${tmpFilePath}`;
return promisify(exec)(command)
.then(() => promisify(fs.readFile)(tmpFilePath))
.then((buffer) => {