Best Python code snippet using Airtest
adbclient.py
Source: adbclient.py
...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):...
adb.py
Source: adb.py
...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))...
Check out the latest blogs from LambdaTest on this topic:
Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.
The purpose of developing test cases is to ensure the application functions as expected for the customer. Test cases provide basic application documentation for every function, feature, and integrated connection. Test case development often detects defects in the design or missing requirements early in the development process. Additionally, well-written test cases provide internal documentation for all application processing. Test case development is an important part of determining software quality and keeping defects away from customers.
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!