Skip to content

Commit

Permalink
take compressed screenshots for maestro studio and add a small pollin…
Browse files Browse the repository at this point in the history
…g delay
  • Loading branch information
artem888 committed Aug 16, 2023
1 parent 3cdbfaf commit b744122
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ object MaestroCommandRunner {
val result = kotlin.runCatching {
val out = File.createTempFile("screenshot-${System.currentTimeMillis()}", ".png")
.also { it.deleteOnExit() } // save to another dir before exiting
maestro.takeScreenshot(out)
maestro.takeScreenshot(out, false)
debugScreenshots.add(
ScreenshotDebugMetadata(
screenshot = out,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class TestSuiteInteractor(
val result = kotlin.runCatching {
val out = File.createTempFile("screenshot-${System.currentTimeMillis()}", ".png")
.also { it.deleteOnExit() } // save to another dir before exiting
maestro.takeScreenshot(out)
maestro.takeScreenshot(out, false)
debugScreenshots.add(
ScreenshotDebugMetadata(
screenshot = out,
Expand Down
4 changes: 2 additions & 2 deletions maestro-client/src/main/java/maestro/Maestro.kt
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ class Maestro(private val driver: Driver) : AutoCloseable {
driver.close()
}

fun takeScreenshot(outFile: File) {
fun takeScreenshot(outFile: File, compressed: Boolean) {
LOGGER.info("Taking screenshot: $outFile")

val absoluteOutFile = outFile.absoluteFile
Expand All @@ -472,7 +472,7 @@ class Maestro(private val driver: Driver) : AutoCloseable {
.sink()
.buffer()
.use {
ScreenshotUtils.takeScreenshot(it, false, driver)
ScreenshotUtils.takeScreenshot(it, compressed, driver)
}
} else {
throw MaestroException.DestinationIsNotWritable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ class Orchestra(
?.let { File(it, pathStr) }
?: File(pathStr)

maestro.takeScreenshot(file)
maestro.takeScreenshot(file, false)

return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ object DeviceScreenService {
val screenshotFile = SCREENSHOT_DIR.resolve(name).toFile()
screenshotFile.deleteOnExit()
try {
maestro.takeScreenshot(screenshotFile)
maestro.takeScreenshot(screenshotFile, true)
} catch (ignore: Exception) {
// ignore intermittent screenshot errors
}
Expand Down
1 change: 1 addition & 0 deletions maestro-studio/web/src/pages/InteractPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const InteractPage = () => {
try {
const deviceScreen = await API.getDeviceScreen();
setDeviceScreen(deviceScreen);
await wait(250);
} catch (e) {
console.error(e);
await wait(1000);
Expand Down

0 comments on commit b744122

Please sign in to comment.