Best Python code snippet using pyatom_python
automateMac.py
Source:automateMac.py  
...90            graphlist.reverse()91        92        return graphlist93    def get_appref(bundleid):94        instrument = atomac.getAppRefByBundleId(bundleid)95        return instrument96    97    98    # å¼å§instrumentsè®°å½99    def start_record():100        # atomac.launchAppByBundleId("com.apple.dt.Instruments")101        # time.sleep(2)102        instrument = atomac.getAppRefByBundleId("com.apple.dt.Instruments")103        recordbutton = instrument.windows()[0].toolbars()[0].checkboxs()[0]104        recordbutton.Press()105        return instrument106        107     108    # åæ¢è®°å½109    def stop_record():110        start_record()111           112    113# windowsä¸å®è£
atomac失败ï¼ä¾¿äºè°è¯å
¶ä»å½æ°114else:115    def start_record():116        pass117    def stop_record():118        pass119    def get_systeminfo(instrument, appname):120        return ['1','2','3']121    def get_graphinfo(instrument):122        return [['1','2','3']]123    def get_appref(bundleid):124        pass125    def jump_page(a, b):126        pass127        128if __name__ == "__main__":129    #print(get_graphinfo("aa"))130    instrument = atomac.getAppRefByBundleId("com.apple.dt.Instruments")131    print(get_systeminfo(instrument, "test"))132        ...calculator_sample.py
Source:calculator_sample.py  
2import atomacos3# ê³ì°ê¸° ì´íì bundle id를 íµí´ì ì¤íí4atomacos.launchAppByBundleId('com.apple.calculator')5# ì¤íë ê³ì°ê¸° ì´í Bundle id를 íµí´ì 찾고 ê°ì²´íí기6calculator = atomacos.getAppRefByBundleId('com.apple.calculator')7try:8    # ë§ì½ ê³ì°ê¸° ì±ì´ ì ììíëì§ ìì ê²½ì° AXTitle ê°ì´ ê°ì²´ì ìê² ëë¤.9    getattr(calculator, 'AXTitle')10except:11    # ì´ë´ê²½ì° Exceptionì´ ë°ìíëë° ë°ìíë©´ 3ì´ë¥¼ ë기í í ë¤ìëìì ìííëë¡ íë¤.12    import time13    time.sleep(3)14    calculator = atomacos.getAppRefByBundleId('com.apple.calculator')15# ì ìì ì¼ë¡ ê°ì²´ ì ë³´ê° ë°ìëìëì§ íì¸16print(calculator)17# AXRoleì´ AXButtonì´ê³  AXTitleì´ 1ì¸ ê° ì°¾ê¸°18one_button = calculator.findFirstR(AXRole='AXButton', AXTitle='1')19# 1ë²í¼ ìì±ê° íì¸í기20print(one_button.getActions())21# 1ë²í¼ í´ë¦í기...atomac-test.py
Source:atomac-test.py  
1import atomac2import time3atomac.launchAppByBundleId('com.apple.calculator')4calc = atomac.getAppRefByBundleId('com.apple.calculator')5time.sleep(2)6window = calc.windows()[0]7print window8print window.AXTitle9print window.getAttributes()10print window.getActions()11print window.AXIdentifier12print window.AXChildren13print window.buttons()14window.sendKeys ("234*2")15widget = window.findFirstR(AXIdentifier='_NS:98')16print widget17# atomac.launchAppByBundleId('com.apple.Automator')18# automator = atomac.getAppRefByBundleId('com.apple.Automator')19# print automator.windows()20# window = automator.windows()[0]21# print window.AXTitle22# print window.getAttributes()23# print window.AXIdentifier24# print window.sheets()25# #print window.AXChildren26# sheet = window.sheets()[0]27# print sheet28# print sheet.AXIdentifier29# #print sheet.AXTitle30# print sheet.AXChildren31# print sheet.buttons()32# close = sheet.buttons('Close')[0]...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!!
