Skip to content

Commit

Permalink
Verify screenshot content
Browse files Browse the repository at this point in the history
  • Loading branch information
lpusok committed Sep 5, 2022
1 parent 4eb0657 commit 1ad67ad
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions e2e/bitrise.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
format_version: "11"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git

app:
envs:
- TEST_APP_URL: https://github.com/bitrise-io/Bitrise-Android-Sample
- TEST_APP_BRANCH: BE-231-screenshot

workflows:
test_emulator_start_23:
envs:
Expand Down Expand Up @@ -71,18 +76,38 @@ workflows:

_take_screenshot:
steps:
- change-workdir:
- script:
inputs:
- content: |-
#!/bin/env bash
set -ex
rm -rf ./_tmp
- git::https://github.com/bitrise-steplib/bitrise-step-simple-git-clone.git:
inputs:
- path: $BITRISE_DEPLOY_DIR
- repository_url: $TEST_APP_URL
- clone_into_dir: ./_tmp
- branch: $TEST_APP_BRANCH
- gradle-runner:
inputs:
- gradle_file: ./_tmp/build.gradle
- gradle_task: connectedDebugAndroidTest
- gradlew_path: ./_tmp/gradlew
- script:
inputs:
- content: |
#!/bin/bash
set -euxo pipefail
sleep 15
cd $BITRISE_DEPLOY_DIR
$ANDROID_HOME/platform-tools/adb -s $BITRISE_EMULATOR_SERIAL shell "screencap -p /sdcard/screen.png"
$ANDROID_HOME/platform-tools/adb -s $BITRISE_EMULATOR_SERIAL pull "/sdcard/screen.png" "./screen_$EMU_VER.png"
cp ./_tmp/app/screenshots/test_screenshot.png $BITRISE_DEPLOY_DIR/screen_$EMU_VER.png

if [[ "$OSTYPE" == "darwin"* ]]; then
brew install tesseract
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt install tesseract-ocr libtesseract-dev tesseract-ocr-eng
fi

tesseract -l eng test_screenshot.png out.txt
cat ./out.txt | grep 'Hello World!'

_kill-emulator:
steps:
Expand Down

0 comments on commit 1ad67ad

Please sign in to comment.