I am trying to run android test with Espresso and getting this error "android.support.test.espresso.PerformException: Error performing ‘single click’ on view ‘with id: …’.
at android.support.test.espresso.PerformException$Builder.build(PerformException.java:83)"
Everything works locally on Android emulator, real device and genymotion. Trying to find solution I also implemented code to wakeup, unlock device and remove tutorial message:
private void prepareDevice() {
try {
device.wakeUp();
} catch (RemoteException e) {
e.printStackTrace();
}
try {
new UiObject(new UiSelector().className("android.widget.Button").text("OK")
).click();
} catch (UiObjectNotFoundException e) {
e.printStackTrace();
}
int dHeight = device.getDisplayHeight();
int dWidth = device.getDisplayWidth();
device.click(dWidth / 2, dHeight / 2);
}
This didn’t help so I implemented code to get device screenshot but the same problem - it works only locally and doesn’t work on emulator:
- wget http://imgur.com/tools/imgurbash.sh
- chmod a+x imgurbash.sh
- adb shell screencap -p | sed 's/\r$//' > alua.png
- ./imgurbash.sh alua.png
It seems I spent about several days to run android tests on circle without success. Please help!
P. S. My circle.yml:
machine:
environment:
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
PATH: "~/$CIRCLE_PROJECT_REPONAME/gradle-2.9/bin:$PATH"
TERM: "dumb"
ADB_INSTALL_TIMEOUT: "10"
java:
version: oraclejdk7
general:
branches:
only:
- master
dependencies:
pre:
- wget "https://services.gradle.org/distributions/gradle-2.9-bin.zip"; unzip gradle-2.9-bin.zip
- echo y | android update sdk --no-ui --all --filter tool,extra-android-m2repository,extra-android-support,extra-google-google_play_services,extra-google-m2repository,android-23
- echo y | android update sdk --no-ui --all --filter build-tools-23.0.2
test:
pre:
- emulator -avd circleci-android22 -no-audio -no-window:
background: true
parallel: true
- circle-android wait-for-boot
- sleep 70
- adb shell input keyevent 82
- wget http://imgur.com/tools/imgurbash.sh
- chmod a+x imgurbash.sh
- adb shell screencap -p | sed 's/\r$//' > alua.png
- ./imgurbash.sh alua.png
- sleep 5
- fb-adb shell input touchscreen swipe 370 735 371 735
- sleep 5
override:
- ./gradlew connectedAndroidTest -PdisablePreDex --stacktrace
- ./gradlew assembleRelease -PdisablePreDex --stacktrace
- ./gradlew testDevReleaseUnitTest --continue --stacktrace
- ./gradlew testStageReleaseUnitTest --continue --stacktrace
post:
- cp -r app/build/reports $CIRCLE_ARTIFACTS
- cp -r app/build/outputs $CIRCLE_ARTIFACTS
- cp -r app/build/outputs/androidTest-results/* $CIRCLE_TEST_REPORTS
- mkdir $CIRCLE_TEST_REPORTS/junit
- find */build/test-results -name "*.xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;