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?
Related
The (Android) app we're working on is depended on it's plugged-in (AC) status.
Because we want to run the app on a real device connected to our buildserver we need a way to fake this behaviour in order to fully test the app without actually removing the device from power.
Now I've learned about adb shell dumpsys battery ac 0|1 which allowed me to set it.
But I was unable to get this working during the test itself with:
Process.run('adb', [
'shell',
'dumpsys',
'battery',
'set',
'ac',
'1',
]);
This results in the following error:
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞═════════════════
The following ProcessException was thrown running a test:
Permission denied
Command: adb shell dumpsys battery set ac 1
I also tried it with sudo, but that resulted in the same.
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.
I am running my app in emulator through command line referring this link. But i am not able to find any command through which i can take log of the app running on emulator.
The Command to receive the log buffers on commandline is:
[adb] logcat [<option>] ... [<filter-spec>] ...
There are several options that can be passed that can be found here.
For more informations continue reading here:
Logcat Documentation
Reading and Writing Logs
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".
We are currently working on an instrumentation test suite which runs on our build server, but while the tests pass on a dev machine using a normal Android emulator, the builds fail on the build server since there we only run a headless emulator with the -no-window flag.
The failure occurs when trying to invoke the InstrumentationTestCase.sendKeys() method to programmatically open the options menu. The error is:
Permission denied: injecting key event from pid 646 uid 10026 to window Window{43d55100 paused=false} owned by uid 1000
We then found out that there's a INJECT_EVENTS permission, but setting it in the manifest had no effect. In fact in the log we saw this output:
Not granting permission android.permission.INJECT_EVENTS to package com.qype.radar (protectionLevel=2 flags=0x6644)
Does that mean this permission is useless?
We also tried to let the instrumentation test app and the app under test share the same Linux user ID using android:sharedUserId and run in the same process (android:process -- we weren't sure if that was already the case), but still no luck.
Does this mean it's currently impossible to run instrumentations which contain key events on a headless emulator, or are we missing something?
I run the emulator without -no-window on headless machines by first running an Xvnc instance (i.e. fake X server) then starting the emulator in that DISPLAY.
More accurately, I get the Xvnc and Android Emulator Jenkins plugins to do this for me.
Unfortunately, unlocking the screen is still a concern before injecting UI events, but this is (hackily) resolved by automatically running a command like this (similar to this other answer you've seen):
echo "event send EV_KEY:KEY_MENU:1 EV_KEY:KEY_MENU:0" | nc -q1 localhost 5554
Edit:
I discovered that this method is far more reliable:
adb shell input keyevent 82
Some info about keycode 82.
I had similar problem with my test on the Hudson server. In my case the problem I solved by suggestion from Android SDK:
http://developer.android.com/guide/topics/testing/testing_android.html#UITestTroubleshooting
Important was that I had to enable permissions for main application too.