Robotium and Jenkins UI testing errors - android

I first ran into this problem when trying to run Robotium UI tests on a MacOS Mini with no monitor. I added Robotium code to test UI clicks on screen, since we want to add some UI automation to our regression testing. The error I get on the Jenkins server is when solo.clickInList(X) is run:
junit.framework.AssertionFailedError: AbsListView is not found!
[exec] at com.jayway.android.robotium.solo.Waiter.waitForAndGetView(Waiter.java:492)
[exec] at com.jayway.android.robotium.solo.Clicker.clickInList(Clicker.java:406)
[exec] at com.jayway.android.robotium.solo.Clicker.clickInList(Clicker.java:388)
[exec] at com.jayway.android.robotium.solo.Solo.clickInList(Solo.java:1081)
[exec] at com.cars.android.robotium.TestApplication.testSearch(TestApplication.java:29)
I found out that Jenkins needs Xvnc plugin to fake a UI so that the emulator can use it. Make sure to check "Show emulator window" in the specific job. Now doing that I currently get this error.
/Applications/RealVNC/VNC\ Server.app :$DISPLAY_NUMBER -localhost -geometry 1280x1024 -depth 24 -SecurityTypes None
I now get this error in Jenkins
Starting xvnc
[workspace] $ "/Applications/RealVNC/VNC Viewer.app" :77 -localhost -geometry 1280x1024 -depth 24 -SecurityTypes None
FATAL: Cannot run program "/Applications/RealVNC/VNC Viewer.app" (in directory "/Users/Shared/Jenkins/Home/jobs/Android/workspace"): error=13, Permission denied
java.io.IOException: Cannot run program "/Applications/RealVNC/VNC Viewer.app" (in directory "/Users/Shared/Jenkins/Home/jobs/Android/workspace"): error=13, Permission denied

You don't say whether the Robotium tests work on your local machine, so I don't know whether the Robotium code itself is correct.
But regarding the Xvnc setup, I see a couple of probable issues:
"VNC Viewer.app" sounds like a VNC client, rather than an X11 server.
As far as I know, you can't just run "/Applications/Foo.app" on the command line. You usually need to run the actual binary; something like "/Applications/Foo.app/Contents/MacOS/foo".

Related

Use "UiAutomator dump" command while Appium is running

I need to run Automated tests via Appium, while there is another application which is trying to take UiDump and calculate some statistics. However, once Appium session starts, the application encounters error, since it can no longer capture the UiDump. On executing command "uiautomator dump", following error is encountered
137|j7maxlte:/proc/24005 $ uiautomator dump
sh: resetreason: can't execute: Permission denied
Killed
I understand this is a known behavior, but is there any way or work around to execute command : "uiautomator dump" while Appium session is active?

Run AndroidTest on Android Emulator In Docker

I saw some links and posts about running AndroidTest in Docker. Like:
https://dzone.com/articles/running-android-tests-in-docker
https://github.com/ksoichiro/android-tests/tree/master/docker-emulator
And some more. However, they all seem inappropriate for AndroidTest in CI, since they require an actual VM, or simply they are too old.
I tried the following lines Docker Image (Partial):
RUN /opt/adk/tools/bin/sdkmanager "emulator" "build-tools;${BUILD_TOOLS}" "platforms;${ANDROID_PLATFORM}" "system-images;${ANDROID_PLATFORM};google_apis;armeabi-v7a" \
&& echo no | /opt/adk/tools/bin/avdmanager create avd -n "Android" -k "system-images;${ANDROID_PLATFORM};google_apis;armeabi-v7a" \
And then I run the emulator using:
/opt/adk/emulator/emulator #Android -writable-system -nocache -no-snapstorage &
However, when trying to run connectedAndroidTest there were some weird exceptions, like:
Caused by: com.android.ddmlib.InstallException: Unknown failure: Error: Could not access the Package Manager. Is the system running?
Or, if I try to manually install the test APK, and run am instrument:
android.util.AndroidException: Can't connect to activity manager; is the system running?
So my question: Is anyone is running AndroidTest on emulator as part of the CI on docker? Means, an image that you just need to mount your project and run gradle connectedAndroidTest, and everything works? Is there a working example for that?
I run AndroidTest on emulator as part of the CI on docker using this image: https://hub.docker.com/r/chrisss404/android-emulator
The problem you might encounter is that hardware acceleration is not available on your host because of missing nested KVM (just a guess, but that was the problem I was facing). In this case you have to use software rendering, which can take a significant amount of time.
With software rendering, the startup takes about 40 minutes until the emulator is usable (on my host). However, then you can run the instrumentation tests as usual in an acceptable timeframe.

An unknown server-side error occurred while processing the command. Original error: Can't stop process; it's not currently running

Getting this error on jenkins job console when my test cases is running with Appium and java.Checked that appium server is up and running
Appium version 1.8.1
org.openqa.selenium.WebDriverException: An unknown server-side error
occurred while processing the command. Original error: Can't stop
process; it's not currently running (cmd:
'D:\SDK\SDK\platform-tools\adb.exe') (WARNING: The server did not
provide any stacktrace information) Command duration or timeout: 1.83
seconds
When setting up Jenkins make sure that you have set all the 'dependancies' and environment variables on the machine hosting Jenkins.
login>Manage Jenkins>Configure System >Tick the env variables and add the paths there.
Once I did that my server started running and I had no issues . Also I would check that all the paths to the android sdk tools, Java JDK, nodeJS and appium.
Lastly I would see if I can kick off a job via command line on the machine to see if the machine hosting Jenkins is set up correctly.(If not then this will give you a better error message and indication as to what exactly the issue is)

connectedAndroidTest fails with "no connected devices" but am instrument works

I'm setting up a Jenkins node (on Mac OS X) running instrumentation tests for my Android app.
My Jenkins project starts an Android emulator and runs the Gradle task :app:connectedAndroidTest. But the task has always been unstable, sometimes being able to run the tests just fine, but most of the times failing with the following error:
:app:connectedAndroidTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:connectedAndroidTest'.
> com.android.builder.testing.api.DeviceException: No connected devices!
After some investigation, I found that:
The issue only occurs on that machine; on my machine (another Mac OS X), the task has always worked as expected, inside and outside Android Studio;
The issue occurs outside Jenkins, i.e. by manually starting the emulator and running the Gradle task from the command line;
Even though the Jenkins output warned about using nonstandard ports, the issue occurs even when using the more usual 5554-5555;
adb devices shows the emulator in online state;
adb shell am instrument works fine too;
Therefore I can say that the problem is that :app:connectedAndroidTest doesn't detect the running emulator.
I already half-made a shell script that installs the APKs and runs am instrument, but the latter doesn't produce a JUnit-compatible output.
So before doing additional work, I wonder how can I "repair" that Gradle task so that it detects the emulator.
I'm also happy to get advice to further pinpoint the problem, e.g. to find out why the Gradle task works on my machine.
firstly clean your project,and than recreate an Android emulator,execute a cmd commond adb start-service .if fail again you should to use other's emulator in markets.
I'm facing the exact same problem.
Any hint so far? In my former ant script, to ensure adb was connected to the device, we used to to do:
%ANDROID_SDK%-current\platform-tools\adb.exe devices
%ANDROID_SDK%-current\platform-tools\adb.exe root
%ANDROID_SDK%-current\platform-tools\adb.exe devices
%ANDROID_SDK%-current\platform-tools\adb.exe wait-for-device
This way we ensured the device would be available while testing.

"unknown-sdk" device when executing tests in Jenkins

I have a strange situation with Jenkins when trying to run the tests.
The configuration of the job clearly specifies to run the tests on this specific avd: "hudson_en-US_160_HVGA_android-18_armeabi-v7a", but for some odd reasons, during the build process, 2 devices are found. One of the devices is the previous one, but the other is called "unknown-sdk".
The tests are successfully executed on the specific avd, and fail on "unknown-sdk":
The relevant portion of the log:
[SR.runTests] Executing instrumentation suite on 2
device(s).
[SR.runTests] [emulator-8215] Starting
execution.
[SR.runTests] [localhost:8216] Starting
execution.
Running am instrument -w -r -e class com.smoke.tests.LoginTest
com.muume.dev.test/android.support.test.runner.AndroidJUnitRunner on
unknown-sdk-localhost:8216
2015-06-17 11:54:05 [SDR.printStream] [localhost:8216] STDOUT 11:54:05
I/InstrumentationResultParser: test run failed: 'Unable to find
instrumentation info for:
ComponentInfo{com.muume.dev.test/android.support.test.runner.AndroidJUnitRunner}
As you can see, it detected 2 devices: emulator-8215 which is the known avd, and localhost-8216 which is the unknown and causes the problems.
My question is how to restrict the tests to run only one single emulator, and from where did the "unknown-sdk-localhost" comes from.
"unknown-sdk" is what it tells adb while the emulator is still busy loading itself.

Categories

Resources