lovelysystems / robotframework-androidlibrary

Robot Framework Automation Library for Android
29 stars 22 forks source link

"Wait for Devices" keyword is throwing WindowsError: [Error 5] Access is denied. #46

Open srib4ufrnd opened 11 years ago

srib4ufrnd commented 11 years ago

We started runniing a simple test where we are trying to wait for android device and install an apk

The "wait for device" is thorwing the below error

unable to open socket to "localhost:50086" error: [Errno 10061] No connection could be made because the target machine actively refused it
WindowsError: [Error 5] Access is denied. 

FYI the procedure and logs are as below.

Test Script we are running is:
*************************************************************************
*** Settings ***
Library           AndroidLibrary

*** Test Cases ***
Install
    Wait For Device
    Install Application    xxxxxxx.apk
*************************************************************************

Error We got in RIDE:
*************************************************************************
unable to open socket to "localhost:50086" error: [Errno 10061] No connection could be made because the target machine actively refused it
===================================================================================================================================
AndroidClientAuto                                                                                                                  
===================================================================================================================================
Install                                                                                                                    | FAIL |
WindowsError: [Error 5] Access is denied.
-----------------------------------------------------------------------------------------------------------------------------------
AndroidClientAuto                                                                                                          | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
===================================================================================================================================
Output:  c:\users\prakas~1\appdata\local\temp\RIDE1pjcdf.d\output.xml
Log:     c:\users\prakas~1\appdata\local\temp\RIDE1pjcdf.d\log.html
Report:  c:\users\prakas~1\appdata\local\temp\RIDE1pjcdf.d\report.html

test finished 01/22/13 11:36:23

*************************************************************************

we also tried running in CMD prompt using the the command
pybot AndroidClientAuto.txt and we got the same error as below
*************************************************************************
Full Name: AndroidClientAuto.Install 
Start / End / Elapsed: 20130122 11:40:50.114 / 20130122 11:40:50.130 / 00:00:00.016 
Status: FAIL (critical) 
Message: WindowsError: [Error 5] Access is denied. 

-KEYWORD: AndroidLibrary.Wait For Device Expand All 
Documentation: Wait for the device to become available

Start / End / Elapsed: 20130122 11:40:50.116 / 20130122 11:40:50.129 / 00:00:00.013 
11:40:50.128 FAIL WindowsError: [Error 5] Access is denied. 
*************************************************************************
peritus commented 11 years ago

Could you run this again with -L TRACE ? I might be able to help you then.

srib4ufrnd commented 11 years ago

hello peritus

Thanks for the reply. we ran RIDE with -L TRACE arguments passed to Pybot. The below is the error log.

Starting test: AndroidClientAuto.Install 20130122 15:34:30.313 : TRACE : Arguments: [ ] 20130122 15:34:30.314 : DEBUG : $> E:\Android\android-sdk-windows\platform-tools\adb.exe wait-for-device # with timeout 40s 20130122 15:34:30.327 : FAIL : WindowsError: [Error 5] Access is denied. 20130122 15:34:30.327 : DEBUG : Traceback (most recent call last): File "C:\Python27\lib\site-packages\AndroidLibraryinit.py", line 207, in wait_for_device rc, output, errput = self._execute_with_timeout([self._adb, 'wait-for-device'], max_timeout=timeout / 3, max_attempts=3) File "C:\Python27\lib\site-packages\AndroidLibraryinit.py", line 138, in _execute_with_timeout p = killableprocess.Popen(cmd, stdout=out, stderr=err) File "C:\Python27\lib\subprocess.py", line 679, in init errread, errwrite) File "C:\Python27\lib\site-packages\AndroidLibrary\killableprocess.py", line 156, in _execute_child winprocess.AssignProcessToJobObject(self._job, hp) File "C:\Python27\lib\site-packages\AndroidLibrary\winprocess.py", line 37, in ErrCheckBool raise WinError() Ending test: AndroidClientAuto.Install

peritus commented 11 years ago

Could you see if E:\Android\android-sdk-windows\platform-tools\adb.exe exists and is executable ?

srib4ufrnd commented 11 years ago

ya, adb.exe exists and is executable.

one small observation is when we ran with CMD prompt in admin mode, we are not getting error for "wait for device" but we are getting error for Install application saying "Installing application failed: 1, '' " "

One more serious issue i feel is once we are using RIDE and the Robot Android library, i see so many adb.exe process running in task manager. This is a big issue i feel which is creating resource blocks e.t.c

srib4ufrnd commented 11 years ago

Peritus, strictly speaking there should be always one adb process to run right, running multiple adb.exe is not a safe way to communicate with the device.

We observed in the the Python files of robot android library, in Killableprocess.py -> def Popen(subprocess.Popen) in the condition if mswindows: def _execute_child(

The process kill and reopening is not happening as we expect. what do u feel?

srib4ufrnd commented 11 years ago

hello peritus some time the "install apllication" is throwing an error saying [Error 5] access denied.

But once i restart the machine, it seems working fine.

but after some executions i am getting the errors again and again

saying [Error 5] access denied And after that "Installing application failed: 1, '' " "

when i saw in task manager i saw multiple adb.exe processes running

i think some where subprocess.Popen is opening multiple adb.exe process without kiling the old adb.exe this will leading top problems while executin adb install comand internally i guess?

srib4ufrnd commented 11 years ago

Hello peritus,

i restarted my machine, now i executed the below script Wait For Device Install Application xxxxxxx.apk Start Testserver With Apk xxxxxxx.apk

no keyword has failed , all the keywords got succeded and test case is pass. apk is successfully installed, but i am not able to launch the apk in the device i got the below error, can u help me?

INSTRUMENTATION_STATUS: id=ActivityManagerService INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: Component I D:\Official\ROBOT_Prerequisites\Android_Automation\apidemos>nfo{sh.calaba.androi d.test/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner} INSTRUMENTATION_STATUS_CODE: -1 android.util.AndroidException: INSTRUMENTATION_FAILED: sh.calaba.android.test/sh .calaba.instrumentationbackend.CalabashInstrumentationTestRunner at com.android.commands.am.Am.runInstrument(Am.java:616) at com.android.commands.am.Am.run(Am.java:118) at com.android.commands.am.Am.main(Am.java:81) at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:237) at dalvik.system.NativeStart.main(Native Method)

srib4ufrnd commented 11 years ago

I read in the below link saying we need to install the test server seperatley, but i dont know where the test server is located.

https://groups.google.com/group/calabash-android/tree/browse_frm/month/2012-9/75c68e2f8ffb8116?rnum=321&start=250&_done=/group/calabash-android/browse_frm/month/2012-9?start%3D250%26sa%3DN%26&pli=1

after reading this i went to the location "C:\Ruby193\lib\ruby\gems\1.9.1\gems\calabash-android-0.3.2\test-server" and tried building the test server using ant command " ant package" no i got the below error, so i cannot build the test server also, so that i can install the test server manually on device and run.

the error i got is? C:\Ruby193\lib\ruby\gems\1.9.1\gems\calabash-android-0.3.2\test-server>ant packa ge Buildfile: C:\Ruby193\lib\ruby\gems\1.9.1\gems\calabash-android-0.3.2\test-serve r\build.xml

-check.preconditions:

package:

-compile:

-stage:

-prepare.testserver: [javac] C:\Ruby193\lib\ruby\gems\1.9.1\gems\calabash-android-0.3.2\test-serv er\build.xml:89: warning: 'includeantruntime' was not set, defaulting to build.s ysclasspath=last; set to false for repeatable builds [javac] Compiling 511 source files to C:\Ruby193\lib\ruby\gems\1.9.1\gems\ca labash-android-0.3.2\test-server\bin

BUILD FAILED C:\Ruby193\lib\ruby\gems\1.9.1\gems\calabash-android-0.3.2\test-server\build.xml :95: The following error occurred while executing this line: C:\Ruby193\lib\ruby\gems\1.9.1\gems\calabash-android-0.3.2\test-server\build.xml :89: D:\Official\Projects\xxx\SupportSoftwares\Android\android_sdk_win dows\platforms\android-${android.api.level} does not exist.

Total time: 2 seconds

srib4ufrnd commented 11 years ago

i really did not undesratnd why it is aying the api level doesnot exist D:\Official\Projects\xxxxx\SupportSoftwares\Android\android_sdk_win dows\platforms\android-${android.api.level} does not exist.

i have all the folders with api levels satrting from 3 to 16(like android-3 to android -16) in the folder "D:\Official\Projects\xxxx\SupportSoftwares\Android\android_sdk_win dows\platforms"