How to use get_androidversion_name method in Airtest

Best Python code snippet using Airtest

myscript.py

Source:myscript.py Github

copy

Full Screen

...65 if isNullOrEmptyString(package_name, True) :66 raise Exception("package_name_empty", "Package name is empty (File: " + path + ").")67 return null6869 if not isNullOrEmptyString(a.get_androidversion_name()):70 try :71 #print("package_version_name", str(a.get_androidversion_name()), "Package Version Name")72 packageversionname=str(a.get_androidversion_name())73 except :74 #print("package_version_name", a.get_androidversion_name().encode('ascii', 'ignore'), "Package Version Name")75 packageversionname=a.get_androidversion_name().encode('ascii', 'ignore')7677 if not isNullOrEmptyString(a.get_androidversion_code()):78 # The version number shown to users. This attribute can be set as a raw string or as a reference to a string resource. 79 # The string has no other purpose than to be displayed to users. 80 try :81 packageversioncode=int(a.get_androidversion_code())82 except ValueError :83 packageversioncode=a.get_androidversion_code()8485 if len(a.get_dex()) == 0:86 raise Exception("classes_dex_not_in_apk", "Broken APK file. \"classes.dex\" file not found (File: " + apk_Path + ").")87 return null8889 try: ...

Full Screen

Full Screen

apk_information_extractor.py

Source:apk_information_extractor.py Github

copy

Full Screen

1import hashlib2import os3import ssdeep4class AndroguardAnalysis (object):5 def __init__(self, app_path):6 self.app_path = app_path7 from androguard.core.bytecodes.apk import APK8 self.a = APK (app_path)9 self.d = None10 self.dx = None11 self.cert = None12 if (self.a.is_signed ()):13 signatures = self.a.get_signature_names ()14 for signature in signatures:15 self.cert = self.a.get_certificate (signature)16 def get_detailed_analysis(self, app_path):17 from androguard.misc import AnalyzeAPK18 self.a, self.d, self.dx = AnalyzeAPK (app_path)19 def get_developer_name(self):20 if self.cert is not None:21 return self.cert['tbs_certificate']['issuer'].native.get('organization_name','Unknown')22 else:23 return "Unknown"24def get_hashes(app_path, block_size=2 ** 8):25 md5 = hashlib.md5 ()26 sha1 = hashlib.sha1 ()27 sha256 = hashlib.sha256 ()28 f = open (app_path, 'rb')29 while True:30 data = f.read (block_size)31 if not data:32 break33 md5.update (data)34 sha1.update (data)35 sha256.update (data)36 return [md5.hexdigest (), sha1.hexdigest (), sha256.hexdigest ()]37def get_sha256(app_path, block_size=2 ** 8):38 sha256 = hashlib.sha256 ()39 f = open (app_path, 'rb')40 while True:41 data = f.read (block_size)42 if not data:43 break44 sha256.update (data)45 return sha256.hexdigest ()46def get_fuzzy_hash(path_to_apk):47 return ssdeep.hash_from_file (path_to_apk)48def extract_info_apk(path_to_apk):49 androguard = AndroguardAnalysis (app_path=path_to_apk)50 hashes = get_hashes (path_to_apk)51 ssdeep = get_fuzzy_hash (path_to_apk)52 if androguard.a.get_androidversion_name ():53 d = androguard.a.get_androidversion_name ()54 else:55 d = 'sdk_v_' + str (androguard.a.get_effective_target_sdk_version ())56 info_dict = {57 'name': androguard.a.get_app_name (),58 'package': androguard.a.get_package (),59 'developer': androguard.get_developer_name (),60 'displayed_version': d,61 'size': os.path.getsize (path_to_apk),62 'md5': hashes[0],63 'sha1': hashes[1],64 'sha256': hashes[2],65 'ssdeep': ssdeep,66 'targetsdk': androguard.a.get_effective_target_sdk_version ()67 }68 return info_dict, androguard.a69# from androguard.core.analysis import analysis70# from pfe_plateforme_web.settings import APK_DIR71# path_to_apk = os.path.join(APK_DIR,'skygofree.apk')...

Full Screen

Full Screen

apk_adapter.py

Source:apk_adapter.py Github

copy

Full Screen

...17 logger.warn("Heuristic identified: %s", self)18 def __str__(self):19 if self.package == "":20 return self.filename21 return "package=%s, version=%s" % (self.package, self.get_androidversion_name())22 def get_basename(self):23 return os.path.basename(self.filename)24 def get_dirname(self):25 return os.path.dirname(self.filename)26 def get_apk_name_as_directory_name(self):27 if self.package == "":28 data = self.filename.replace('.apk', '')29 else:30 data = '%s_v%s' % (self.package, self.get_androidversion_name().replace('.', '_'))31 if '(' in data:32 start = data.index('(')33 end = data.index(')')34 data = data[:start - 1] + data[end + 1:]...

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