Best Python code snippet using robotframework-appiumlibrary_python
PicClassfyUtil.py
Source: PicClassfyUtil.py
...7import os8import shutil9from common import FilePathUtil, excel_util, Logger10from wxfriend import WxConfig11def execute_adb_shell(command, deviceId='98882048434756494f'):12 shell = f'adb -s {deviceId} {command}'13 exe_shell(shell)14def getImiDefault():15 shell = f' adb shell ime list -a'16 Logger.println(f"ãexec_shell().shell={shell}ã")17 linesStr = list(os.popen(shell).readlines())18 for line in linesStr:19 Logger.println(f"{line}")20 if 'IME' in line:21 replace = line.replace(':', '')22 Logger.println(f"ã().æ¾å°é»è®¤è¾å
¥æ³:{replace}ã")23 return replace24def setImiDefault():25 default = getImiDefault()26 shell = f' adb shell ime set {default}'27 Logger.println(f"ãexec_shell().shell={shell}ã")28 linesStr = list(os.popen(shell).readlines())29 for line in linesStr:30 Logger.println(f"{line}")31 if 'IME' in line:32 replace = line.replace(':', '')33 Logger.println(f"ã().å·²ç»æ¢å¤é»è®¤è¾å
¥æ³:{replace}ã")34 return replace35def exe_shell(shell):36 Logger.println(f"ãexec_shell().shell={shell}ã")37 linesStr = list(os.popen(shell).readlines())38 for line in linesStr:39 Logger.println(f"{line}")40def stop_server():41 shell = f'adb kill-server'42 Logger.println(f"ãexec_shell().shell={shell}ã")43 exe_shell(shell)44def start_server():45 shell = f'adb start-server '46 Logger.println(f"ãexec_shell().shell={shell}ã")47 exe_shell(shell)48def export():49 full_dir = FilePathUtil.get_full_dir('wxfriend', 'pic')50 weixinPath = FilePathUtil.get_full_dir('wxfriend', 'pic', 'WeiXin')51 if os.path.exists(weixinPath):52 try:53 shutil.rmtree(weixinPath)54 except:55 pass56 deviceId = WxConfig.getAppiumConfig()["deviceName"]57 if deviceId:58 execute_adb_shell(f'pull /sdcard/Pictures/WeiXin/ {full_dir}', deviceId=deviceId)59 else:60 Logger.println(f"ã().æªæ¾å°è®¾å¤ã")61def classify(full_dir):62 # 2.excelè·åæååææ说说çmd5以åå¾ççä¿åèµ·å§æ¶é´å¼63 Logger.println(f"ã().full_dir={full_dir}ã")64 array = excel_util.excel2array(full_dir)65 count = 066 for index, item in enumerate(array):67 content_md5 = item['content_md5']68 start = int(item['start'])69 end = int(item['end'])70 count = int(item['count'])71 if count > 0:72 # Logger.println(f"ãclassify().item={item}ã")73 # 3.æ ¹æ®èµ·å§æ¶é´å¼ä»¥åmd5å¼å类好å¾ç74 full_dir = FilePathUtil.get_full_dir('wxfriend', 'pic', 'WeiXin')75 des_dir = FilePathUtil.get_full_dir('wxfriend', 'pic', 'WeiXinCopy', content_md5)76 files = FilePathUtil.move_files_by_time(full_dir, des_dir, start, end)77def classify_from(source_full):78 # 2.excelè·åæååææ说说çmd5以åå¾ççä¿åèµ·å§æ¶é´å¼79 full_dir = FilePathUtil.get_lastmodify_file(80 FilePathUtil.get_full_dir("wxfriend", "excel", "pic"))81 Logger.println(f"ã().full_dir={full_dir}ã")82 array = excel_util.excel2array(full_dir)83 count = 084 for index, item in enumerate(array):85 content_md5 = item['content_md5']86 start = int(item['start'])87 end = int(item['end'])88 count = int(item['count'])89 if count > 0:90 # Logger.println(f"ãclassify().item={item}ã")91 # 3.æ ¹æ®èµ·å§æ¶é´å¼ä»¥åmd5å¼å类好å¾ç92 des_dir = FilePathUtil.get_full_dir('wxfriend', 'pic', 'WeiXinCopy', content_md5)93 files = FilePathUtil.move_files_by_time(source_full, des_dir, start, end)94 # Logger.println(f"ã{index}.{content_md5}(å¾çæ°é={count},å®é
å¾çæ°é={len(files)}ã")95 # startfile(FilePathUtil.get_full_dir('wxfriend', 'pic'))96def main():97 export()98 full_dir = FilePathUtil.get_lastmodify_file(99 FilePathUtil.get_full_dir("wxfriend", "excel", "pic"))100 classify(full_dir)101def deletePictures():102 Logger.println(f"ãdeletePictures===========å¼å§å é¤ææºå¾çç¼å========================ã")103 deviceId = WxConfig.getAppiumConfig()["deviceName"]104 if deviceId:105 execute_adb_shell('shell rm -r /sdcard/Pictures/WeiXin', deviceId=deviceId)106 Logger.println(f"ãdeletePictures===========å é¤å¾çç¼åæ§è¡å®æ=================ã")107if __name__ == '__main__':108 setImiDefault()109 # if __name__ == '__main__':110 # main()111 # execute_adb_shell('rm -r /sdcard/Pictures/WeiXin')112 # des_dir = FilePathUtil.get_full_dir('wxfriend', 'pic', 'WeiXinCopy')113 # if os.path.exists(des_dir):114 # shutil.rmtree(des_dir)115 # export()116 # full_dir = FilePathUtil.get_lastmodify_file(117 # FilePathUtil.get_full_dir("wxfriend", "excel", "pic"))...
adb_helper.py
Source: adb_helper.py
...21 self.adbstrategy = STFAdb(self.udid)22 else:23 self.adbstrategy = adb_local_helper(self.udid)24 pass25 def execute_adb_shell(self, cmd, timeout=30):26 return self.adbstrategy.execute_adb_shell(cmd, timeout)27 def pull_file(self, path_to_file, target_file, timeout=60):28 self.adbstrategy.adb_pull(path_to_file, target_file, timeout=timeout)29 def install_app(self, app_path, has_permission=False, timeout=30):30 self.adbstrategy.install_app(app_path, has_permission, timeout)31 def uninstall_app(self, package_name, timeout=30):32 self.adbstrategy.uninstall_app(package_name, timeout)33 def remove_sdkcard_apk(self):34 return self.execute_adb_shell("rm /sdcard/Download/*.apk")35 def start_page_by_schema(self, schema):36 return self.execute_adb_shell("am start -a android.intent.action.VIEW "37 "-d %s --activity-clear-task" % schema)38 def get_devices_ip_address(self):39 l = self.execute_adb_shell('ip addr | grep global')40 reg = re.compile('\d+\.\d+\.\d+\.\d+')41 return re.findall(reg, l[1])[0]42 def get_device_brand(self):43 cmd = "getprop ro.product.brand"44 # (execute_result, stdout, stderr) = self.adb_helper.adbstrategy.execute_adb_shell(cmd,timeout=30)45 (execute_result, stdout, stderr) = self.execute_adb_shell(cmd, timeout=30)46 Logger.INFO("brand type is: {}".format(stdout))47 # brand = stdout.split("\n")[0]48 brand=stdout.decode("utf-8")49 #brand = stdout.split("\n")50 brand = brand.split("\n")51 print(len(brand))52 if len(brand)<=2:53 brandname = brand[0]54 else:55 brandname = stdout.split("\r\n")[3]56 #.split("\r")[0]57 return brandname58if __name__ == '__main__':59 adb_helper = AdbHelper("1fa2b4c2", isSTF=False)...
adb_strategy.py
Source: adb_strategy.py
...17 self.udid = udid18 pass19 def adb_pull(self, path_to_file, target_file):20 pass21 def execute_adb_shell(self, cmd,timeout):22 pass23 def install_app(self, app_path, has_permission, timeout):24 pass25 def uninstall_app(self, package_name, timeout):26 pass27 def execute_local_shell(self, cmd, timeout=None):28 pass29 def _kill_proc_by_timer(self, proc):30 if proc is not None:31 proc.kill()...
Check out the latest blogs from LambdaTest on this topic:
Traditional software testers must step up if they want to remain relevant in the Agile environment. Agile will most probably continue to be the leading form of the software development process in the coming years.
Building a website is all about keeping the user experience in mind. Ultimately, it’s about providing visitors with a mind-blowing experience so they’ll keep coming back. One way to ensure visitors have a great time on your site is to add some eye-catching text or image animations.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Even though several frameworks are available in the market for automation testing, Selenium is one of the most renowned open-source frameworks used by experts due to its numerous features and benefits.
When software developers took years to create and introduce new products to the market is long gone. Users (or consumers) today are more eager to use their favorite applications with the latest bells and whistles. However, users today don’t have the patience to work around bugs, errors, and design flaws. People have less self-control, and if your product or application doesn’t make life easier for users, they’ll leave for a better solution.
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!!