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__":...
Check out the latest blogs from LambdaTest on this topic:
One of the most important tasks of a software developer is not just writing code fast; it is the ability to find what causes errors and bugs whenever you encounter one and the ability to solve them quickly.
As part of one of my consulting efforts, I worked with a mid-sized company that was looking to move toward a more agile manner of developing software. As with any shift in work style, there is some bewilderment and, for some, considerable anxiety. People are being challenged to leave their comfort zones and embrace a continuously changing, dynamic working environment. And, dare I say it, testing may be the most ‘disturbed’ of the software roles in agile development.
Estimates are critical if you want to be successful with projects. If you begin with a bad estimating approach, the project will almost certainly fail. To produce a much more promising estimate, direct each estimation-process issue toward a repeatable standard process. A smart approach reduces the degree of uncertainty. When dealing with presales phases, having the most precise estimation findings can assist you to deal with the project plan. This also helps the process to function more successfully, especially when faced with tight schedules and the danger of deviation.
Automating testing is a crucial step in the development pipeline of a software product. In an agile development environment, where there is continuous development, deployment, and maintenance of software products, automation testing ensures that the end software products delivered are error-free.
The key to successful test automation is to focus on tasks that maximize the return on investment (ROI), ensuring that you are automating the right tests and automating them in the right way. This is where test automation strategies come into play.
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!!