0

I'm trying to write a monkeyrunner script that will automate the installation of mdm software for enterprise users. The script will be executed with multiple devices and thus multiple screen sizes and densities.

Is there a way to take a reference coordinate from device A and scale it so that it can be applied to other devices? I started off taking the initial touch coordinates from a reference device, in this case a Samsung Galaxy S2 with a 480 x 800 display with a screen density of 1.5, and calculating a scaled coordinate based on the device at runtime. However, the RAZR Maxx HD with a screen display of 720 x 1184 (some height removed for the soft keys) and a screen density of 2 doesn't work with this method.

Does anyone have more insight to the packing algorithm so that the coordinates from one device can be used for any device?

I did look at using AndroidViewClient to access the buttons of the view directly, but since the script is intended for enterprise end users, it couldn't be used due to the devices being secure.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
  • AndroidViewClient can be used on secure devices if API > 15 (UiAutomator back end) – Diego Torres Milano Jan 09 '13 at 04:55
  • Thanks. I acquired an API > 15 device. What I am encountering now appears to be issues with os.access finding the path to adb.exe as executable. os.access(r'C:\Android\android-sdk\platform-tools\adb.exe', os.F_OK) returns true but os.access(r'C:\Android\android-sdk\platform-tools\adb.exe', os.X_OK) returns false. It returns true when executed through the interpreter in interactive mode, but returns false as a part of a script and launched via monkeyrunner.bat. Thus, ViewClient always fails as it thinks ANDROID_HOME isn't set. – user1959606 Jan 15 '13 at 22:11

1 Answers1

0

Unfortunate Windows behavior. You can short-circuit the test modifying these lines in viewclient.py (around line 952):

@staticmethod
def __obtainAdbPath():
    '''
    Obtains the ADB path attempting know locations for different OSs
    '''

    osName = java.lang.System.getProperty('os.name')
    ...

by

@staticmethod
def __obtainAdbPath():
    '''
    Obtains the ADB path attempting know locations for different OSs
    '''

    return """C:\Android\android-sdk\platform-tools\adb.exe"""
    osName = java.lang.System.getProperty('os.name')
    ...

While a temporary workaround it will solve your problem (until Windows is fixed :-).

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
  • That is one way around it :) Do you have more details on the windows bug? Since Windows treats read access as read and executable, is the bug actually in windows or in Jython as a part of the mapping of the function to the OS? – user1959606 Jan 18 '13 at 22:28
  • BTW, have you thought about making the serialno an optional argument? Just for the case where there's only one device connected? This is probably the norm while developing the test case itself (as opposed to executing the test cycle where more devices will be in use). – user1959606 Jan 18 '13 at 22:36
  • Has anyone interacted with a NAF (Not Accessibility Friendly) Node yet? Since there's no identifiers to the view, I tried reverting to the MonkeyDevice.type(), which enters text in correctly, but then attempts to continue with existing/new view clients appear to fail afterwords. – user1959606 Jan 18 '13 at 22:41
  • You should ask a new question about how to select the serial number using AVC, so I can explain it to you. – Diego Torres Milano Jan 19 '13 at 03:10