How to use getRestrictedScreen method in Airtest

Best Python code snippet using Airtest

adbclient.py

Source:adbclient.py Github

copy

Full Screen

...235 # sout = self.socket.makefile("r")236 # return (sin, sin)237 sout = adbClient.socket.makefile("r")238 return sout239 def getRestrictedScreen(self):240 ''' Gets C{mRestrictedScreen} values from dumpsys. This is a method to obtain display dimensions '''241 rsRE = re.compile('\s*mRestrictedScreen=\((?P<x>\d+),(?P<y>\d+)\) (?P<w>\d+)x(?P<h>\d+)')242 for line in self.shell('dumpsys window').splitlines():243 m = rsRE.match(line)244 if m:245 return m.groups()246 raise RuntimeError("Couldn't find mRestrictedScreen in dumpsys")247 def __getProp(self, key, strip=True):248 prop = self.shell('getprop %s' % key)249 if strip:250 prop = prop.rstrip('\r\n')251 return prop252 def __getDisplayWidth(self, key, strip=True):253 (x, y, w, h) = self.getRestrictedScreen()254 return int(w)255 def __getDisplayHeight(self, key, strip=True):256 (x, y, w, h) = self.getRestrictedScreen()257 return int(h)258 def getSystemProperty(self, key, strip=True):259 return self.getProperty(key, strip)260 def getProperty(self, key, strip=True):261 ''' Gets the property value for key '''262 import collections263 MAP_KEYS = collections.OrderedDict([264 (re.compile('display.width'), self.__getDisplayWidth),265 (re.compile('display.height'), self.__getDisplayHeight),266 (re.compile('.*'), self.__getProp),267 ])268 '''Maps properties key values (as regexps) to instance methods to obtain its values.'''269 for kre in MAP_KEYS.keys():270 if kre.match(key):...

Full Screen

Full Screen

adb.py

Source:adb.py Github

copy

Full Screen

...79 tmpname = '/sdcard/test.png'80 subprocess.call('adb shell screencap -p '+tmpname)81 subprocess.call('adb pull /sdcard/test.png ' +filename)82#得到手机的分辨率83def getRestrictedScreen():84 ''' Gets C{mRestrictedScreen} values from dumpsys. This is a method to obtain display dimensions '''85 print 'in getRestrictedScreen'86 p = subprocess.Popen('adb shell dumpsys window ', stdout=subprocess.PIPE)87 out_p =p.communicate()88 outlines = out_p[0]89 outlines= outlines.splitlines()90 # print outlines91 import re92 rsRE = re.compile('\s*mRestrictedScreen=\((?P<x>\d+),(?P<y>\d+)\) (?P<w>\d+)x(?P<h>\d+)')93 for line in outlines:94 m = rsRE.match(line)95 if m:96 return m.groups()97 # in order to competiable with android-2.3.598 dsRE = re.compile('\s*DisplayWidth=(?P<x>\d+) DisplayHeight=(?P<y>\d+)')99 for line in outlines:100 m = dsRE.match(line)101 if m:102 return (0, 0) + m.groups()103 raise RuntimeError("Couldn't find mRestrictedScreen in dumpsys")104def adbmain(apk_path='now.apk'):105 pacs = adb_package('tdg')106 print pacs107 if pacs:108 #卸载掉对应的apk109 for oneapk in pacs:110 if 'netease' in oneapk:111 adb_uinstall(oneapk)112 adb_snap()113 adb_install(apk_path)114 adb_touch(365,775)115 adb_keyevent(4)116 adb_swipe(140,650,200,650)117 print 'start app'118 tdg_pac = adb_package('tdg')119 app_name = tdg_pac[0]120 adb_start(app_name)121 122if __name__ =="__main__":123 #print getDevices()124 apk_url = "http://192.168.10.116/binary/ios_ipa_publish/tdg_netease.apk"125 print 'start to download'126 #subprocess.call('wget -N '+apk_url+' -O now.apk -o wget.log') # -O tdg_netease.apk127 #print 'end download'128 # adbmain()129 #print getRestrictedScreen()130 print getDevices()131 # import socket132 # HOSTNAME = 'localhost'133 # TIMEOUT = 15134 # try:135 # PORT = int(os.environ['ANDROID_ADB_SERVER_PORT'])136 # except KeyError:137 # PORT = 5037138 # tsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)139 # tsocket.settimeout(TIMEOUT)140 # tsocket.connect((HOSTNAME, PORT))...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful