Best Python code snippet using robotframework-appiumlibrary_python
android.py
Source:android.py
...124 if wait_activity:125 self.driver.start_activity(package, activity, app_wait_activity=wait_activity)126 else:127 self.driver.start_activity(package, activity)128 self.driver.wait_activity(activity, timeout=30)129 def reopen_app(self, package, activity=None, wait_activity=None):130 self.close_app(package)131 self.wait(1)132 self.open_app(package, activity=activity, wait_activity=wait_activity)133 def close_app(self, package: str = None):134 cmd = 'adb -s %s shell am force-stop %s' % (self.udid, package)...
antutu.py
Source:antutu.py
...22def antutu_start():23 printf('antutu_start')24 if driver.is_app_installed('com.antutu.ABenchMark'):25 driver.start_activity('com.antutu.ABenchMark','.ABenchMarkStart')26 if driver.wait_activity('com.antutu.benchmark.activity.MainActivity',10):27 return True28 else:29 return False30 else:31 #TODO:install aututu app32 printf('Not install aututu App')33def antutu_setup():34 printf("antutu_setup")35 if layout_content_find_text(driver,'å¼å§æµè¯') != None:36 printf('Finding å¼å§æµè¯...')37 els = layout_content_find_text(driver,'å¼å§æµè¯')38 if els:39 select_by_text(driver,'å¼å§æµè¯')40 return True41 elif layout_content_find_text(driver,'å®è£
æµè¯') != None:42 printf('å®è£
æµè¯...')43 select_by_text(driver,'å®è£
æµè¯')44 els = layout_content_find_text(driver,'ä¸è½½ä¸')45 if els:46 els.click()47 if driver.wait_activity('.ui.PackageInstallerActivity',200):48 select_by_text(driver,'å®è£
')49 if driver.wait_activity('.ui.InstallAppProgress'):50 select_by_text(driver,'å®æ')51 if driver.wait_activity('com.antutu.benchmark.activity.MainActivity',100) == False:52 return False53 else:54 return True55 else:56 return False57 else:58 return False59 else:60 return False61 else:62 printf('Finding éæ°æµè¯...')63 pos = find_object_by_image(driver,"image/retest.png")64 if(pos):65 tap_by_position(driver,pos)66 return True67 else:68 printf('Not found å¼å§æµè¯')69 return False70def antutu_3dtest():71 printf('antutu_3dtest')72 while True:73 if driver.wait_activity('.UnityPlayerActivity',3) == False:74 return True75def antutu_scoretest():76 printf('antutu_scoretest')77 while True:78 if driver.wait_activity('com.antutu.benchmark.activity.ScoreBenchActivity',3) == False:79 return True80def antutu_resulttest():81 printf('antutu_resulttest')82 if driver.wait_activity('com.antutu.benchmark.activity.TestResultActivity',300):83 print_layout_text(driver)84 driver.press_keycode(4)85 return True86 else:87 return False88method_key = {'com.antutu.benchmark.activity.MainActivity' : antutu_setup, '.UnityPlayerActivity' : antutu_3dtest,89 'com.antutu.benchmark.activity.ScoreBenchActivity' : antutu_scoretest,90 'com.antutu.benchmark.activity.TestResultActivity' : antutu_resulttest}91def run_antutu_method():92 method_key[driver.current_activity]()93def antutu_test():94 if antutu_start():95 while True:96 run_antutu_method()...
weChatApp.py
Source:weChatApp.py
...21 driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)22 # 设置éå½¢çå¾
æ¶é´ï¼åä½s23 driver.implicitly_wait(10)24 # çå¾
微信é¦é¡µæå¼25 driver.wait_activity('.ui.LauncherUI', 10)26 time.sleep(2)27 # è·åå±å¹å°ºå¯¸28 screem = driver.get_window_size()29 print(screem)30 # ä¸æå±å¹ï¼æå¼å¾®ä¿¡å°ç¨åºé¡µé¢31 driver.swipe(screem['width'] * 0.5, screem['width'] * 0.5,32 screem['height'] * 0.2, screem['height'] * 0.8, 1000)33 # ç¹å»é产äºå¹³å°å°ç¨åº34 mpcloudBtn = driver.find_element_by_id('com.tencent.mm:id/jq')35 mpcloudBtn.click()36 # çå¾
é产äºå¹³å°å°ç¨åºæå¼37 driver.wait_activity('.plugin.appbrand.ui.AppBrandUI', 10)38 time.sleep(2)39 # ç¹å»æ°æ®ç»è®¡40 dataBtn = driver.find_element_by_xpath('//*[@text="æ°æ®ç»è®¡"]')41 dataBtn.click()42 # ç¹å»è¿å43 backBtn = driver.find_element_by_xpath('//*[@text="åè½"]')44 backBtn.click()45 # çå¾
页é¢å·æ°46 driver.wait_activity('.plugin.appbrand.ui.AppBrandUI', 10)47 time.sleep(2)48 # ç¹å»æ¶æ¯ç®¡ç49 infoBtn = driver.find_element_by_xpath('//*[@text="æ¶æ¯ç®¡ç"]')50 infoBtn.click()51 # çå¾
页é¢å·æ°52 driver.wait_activity('.plugin.appbrand.ui.AppBrandUI', 10)53 time.sleep(2)54 # å
³éå°ç¨åº55 closeBtn = driver.find_element_by_accessibility_id('å
³é')56 closeBtn.click()57 # çå¾
è¿å微信é¦é¡µ58 driver.wait_activity('.ui.LauncherUI', 10)59 time.sleep(2)60 driver.quit()61if __name__ == "__main__":...
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!!