How to use findFirstR method in pyatom

Best Python code snippet using pyatom_python

logic.py

Source:logic.py Github

copy

Full Screen

...70 inspectors = [71 x72 for x in logic.windows()[0].AXChildren73 if "AXDescription" in x.getAttributes()74 and x.findFirstR(AXValue="Transpose:") != None75 ]76 if len(inspectors) == 0:77 logic.sendGlobalKey("i")78 inspectors = [79 x80 for x in logic.windows()[0].AXChildren81 if "AXDescription" in x.getAttributes()82 and x.findFirstR(AXValue="Transpose:") != None83 ]84 print("Transposing the regions...")85 inspectors[0].findFirstR(AXValue="Transpose:").AXParent.findFirst(86 AXRole="AXSlider"87 ).AXValue = interval88 print("Regions transposed")89def bounce(filepath, bounce_format="MP3"):90 # Adapted from https://gist.github.com/psobot/81635e6cbc933b7e886291 print("Opening bounce window...")92 logic.activate()93 time.sleep(0.1) # To make sure the command works94 logic.sendGlobalKeyWithModifiers("b", ["command"])95 windows = []96 while len(windows) == 0:97 time.sleep(0.1)98 windows = [99 window100 for window in logic.windows()101 if ("Output 1-2" in window.AXTitle) or ("Bounce" in window.AXTitle)102 ]103 bounce_window = windows[0]104 print("Selecting output formats...")105 quality_table = bounce_window.findFirst(AXRole="AXScrollArea").findFirst(106 AXRole="AXTable"107 )108 for row in quality_table.findAll(AXRole="AXRow"):109 row_name = row.findFirst(AXRole="AXTextField").AXValue110 checkbox = row.findFirst(AXRole="AXCheckBox")111 if row_name == bounce_format:112 if checkbox.AXValue == 0:113 print(f"Selecting {bounce_format} output format...")114 checkbox.Press()115 else:116 print(f"{bounce_format} format already selected.")117 elif checkbox.AXValue == 1:118 print(f"Deselecting {row_name} format...")119 print("Pressing bounce...")120 bounce_window.findFirst(AXRole="AXButton", AXTitle="OK").Press()121 print("Waiting for save window...")122 windows = []123 while len(windows) == 0:124 time.sleep(0.1)125 windows = [126 window127 for window in logic.windows()128 if ("Output 1-2" in window.AXTitle) or ("Bounce" in window.AXTitle)129 ]130 save_window = windows[0]131 print("Entering file path...")132 logic.activate()133 logic.sendGlobalKeyWithModifiers("g", ["command", "shift"])134 logic.sendKeys(f"{filepath}\n")135 print("Waiting for file path window to close...")136 logic.activate()137 windows = []138 while len(windows) != 1:139 time.sleep(0.1)140 windows = [141 window142 for window in logic.windows()143 if ("Output 1-2" in window.AXTitle) or ("Bounce" in window.AXTitle)144 ]145 save_window = windows[0]146 print("Pressing bounce on save window...")147 try:148 save_window.buttons("Bounce")[0].Press()149 except atomacos.errors.AXErrorAttributeUnsupported as e:150 print(f"Error when clicking bounce: {str(e)}")151 time.sleep(0.1)152 # Deal with case where file already exists153 for dialog in [154 window for window in logic.windows() if window.AXRoleDescription == "dialog"155 ]:156 print("Overwriting previous file...")157 btns = dialog.AXChildren[-1].buttons("Replace")158 for btn in btns:159 btn.Press()160 time.sleep(0.1)161 # Deal with extra messages that could pop up162 dialogs = [163 window164 for window in logic.windows()165 if window.AXRoleDescription == "dialog"166 ]167 while len(dialogs) > 0:168 replace_btn = dialogs[0].buttons("Replace")169 if len(replace_btn) == 0:170 break171 replace_btn[0].Press()172 time.sleep(0.1)173 dialogs = [174 window175 for window in logic.windows()176 if window.AXRoleDescription == "dialog"177 ]178 print("Bouncing...")179 # time.sleep(2)180 logic.activate() # Required for some reason181 still_going = True182 while still_going:183 try:184 still_going = len(logic.windows()) > 1185 except atomacos.errors.AXErrorInvalidUIElement:186 still_going = True187 time.sleep(0.1)188 print("File saved")189def close():190 print("Closing project...")191 logic.sendGlobalKeyWithModifiers("w", ["command"])192 print("Waiting for the save changes window...")193 windows = []194 for _ in range(20):195 time.sleep(0.1)196 windows = [197 window198 for window in logic.windows()199 if "AXDescription" in window.getAttributes()200 and window.AXDescription == "alert"201 ]202 if len(windows) > 0:203 break204 if len(windows) > 0:205 windows[0].buttons("Don’t Save")[0].Press()206 while len(logic.windows()) > 0:207 time.sleep(0.1)208 print("Project closed")209def importMidi(midiFile):210 print(midiFile)211 selectLastTrack()212 print("Opening up midi selection window...")213 logic.menuItem("File", "Import", "MIDI File…").Press()214 windows = []215 while len(windows) == 0:216 time.sleep(0.1)217 windows = [218 window219 for window in logic.windows()220 if "AXTitle" in window.getAttributes() and window.AXTitle == "Import"221 ]222 import_window = windows[0]223 print("Navigating to folder...")224 logic.activate()225 logic.sendGlobalKeyWithModifiers("g", ["command", "shift"])226 logic.sendKeys(midiFile)227 logic.sendKeys("\n")228 print("Pressing import...")229 time.sleep(0.1)230 import_window.buttons("Import")[0].Press()231 print("Waiting for tempo import message...")232 windows = []233 while len(windows) == 0:234 time.sleep(0.1)235 windows = [236 window237 for window in logic.windows()238 if "AXDescription" in window.getAttributes()239 and window.AXDescription == "alert"240 ]241 alert = windows[0]242 print("Importing tempo...")243 alert.buttons("Import Tempo")[0].Press()244 print("Midi file imported")245"""246old_instrument is the old instrument's name (like 'Sampler')247new_instrument_arr is an array like ['AU Instruments', 'Native Instruments', 'Kontakt', 'Stereo']248(it has the hierarchy of items to find in the menu).249"""250def selectInstrument(new_instrument_arr):251 print("Opening the appropriate window...")252 window = [253 window254 for window in logic.windows()255 if "AXTitle" in window.getAttributes() and "Tracks" in window.AXTitle256 ][0]257 print("Finding the instrument to change...")258 # It's at window.AXChildren[-2].AXChildren[0].AXChildren[-1].AXChildren[0].AXChildren[0]...259 # The one below could be used if we know the name of the instrument260 # strip = window.findFirstR(AXRoleDescription='channel strip group').findFirstR(AXDescription=old_instrument).AXChildren[-1]261 strip = (262 window.findFirstR(AXRoleDescription="channel strip group")263 .findAllR(AXDescription="open")[-1]264 .AXParent.AXChildren[-1]265 )266 # Manually click because Press() throws errors267 time.sleep(0.1)268 atomacos.mouse.click(x=strip.AXPosition.x + 1, y=strip.AXPosition.y + 1)269 print("Walking through the menu items...")270 menuitem = window271 for item in new_instrument_arr:272 if menuitem.AXChildren[0].AXRole == "AXMenu":273 menuitem = menuitem.AXChildren[0]274 menuitem = menuitem.findFirstR(AXRole="AXMenu*Item", AXTitle=item)275 while menuitem.AXPosition.x == 0:276 time.sleep(0.1)277 atomacos.mouse.moveTo(x=menuitem.AXPosition.x + 1, y=menuitem.AXPosition.y + 1)278 print("Clicking the instrument name...")279 atomacos.mouse.click(x=menuitem.AXPosition.x + 1, y=menuitem.AXPosition.y + 1)280 print("Waiting for the instrument screen...")281 windows = []282 i = 0283 while len(windows) < 1 and i < 20:284 time.sleep(0.1)285 i += 1286 windows = [287 window288 for window in logic.windows()289 if "AXTitle" not in window.getAttributes() or "Tracks" not in window.AXTitle290 ]291 if i >= 20:292 print("Failed to open instrument screen")293 raise Exception("Failed to open instrument screen")294 print("Closing the instrument screen...")295 for window in windows:296 window.AXChildren[0].Press()297 print("Done selecting instrument")298def selectPresetSound(sound):299 print("Opening the appropriate window...")300 window = [301 window302 for window in logic.windows()303 if "AXTitle" in window.getAttributes() and "Tracks" in window.AXTitle304 ][0]305 closeLibrary()306 strip = (307 window.findFirstR(AXRoleDescription="channel strip group")308 .findAllR(AXDescription="open")[-1]309 .AXParent.AXChildren[0]310 )311 print("Opening the presets for the instrument")312 atomacos.mouse.click(x=strip.AXPosition.x - 20, y=strip.AXPosition.y + 1)313 print("Waiting for search text field to appear...")314 fields = []315 while len(fields) == 0:316 time.sleep(0.1)317 try:318 fields = window.findAllR(319 AXRole="AXTextField", AXRoleDescription="search text field"320 )321 except Exception:322 print("Error finding search library field")323 fields = []324 search_field = fields[0]325 row = window.findFirstR(AXValue=sound)326 print("Double clicking the sound")327 logic.activate()328 atomacos.mouse.click(329 x=row.AXPosition.x + 30, y=row.AXPosition.y + 10, clicks=1, interval=0.1330 )331 time.sleep(0.05)332 atomacos.mouse.click(333 x=row.AXPosition.x + 30, y=row.AXPosition.y + 10, clicks=2, interval=0.01334 )335def selectLastTrack():336 closeMixer()337 print("Moving selection down by 5")338 logic.activate()339 for i in range(5):...

Full Screen

Full Screen

simauto.py

Source:simauto.py Github

copy

Full Screen

...17 names.append(window.AXTitle)18 # Get the full name of the window where the click will be performed19 for name in names:20 if device_info.name in name:21 window = simulator.findFirstR(AXTitle=name)22 window.activate()23 sleep(1)24 element = window.findFirstR(AXTitle=text)25 if element is not None:26 return element27 element2 = window.findFirstR(AXValue=text)28 if element2 is not None:29 return element230 element3 = window.findFirstR(AXDescription=text)31 if element3 is not None:32 return element333 element4 = window.findFirstR(AXIdentifier=text)34 if element4 is not None:35 return element436 return None37 except Exception:38 return None39 @staticmethod40 def is_text_visible(device_info, text):41 element = SimAuto.find(device_info=device_info, text=text)42 if element is not None:43 return True44 return False45 @staticmethod46 def click(device_info, text):47 element = SimAuto.find(device_info=device_info, text=text)...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

...7 window = None8 for w in window_list:9 if "门诊地址列表" in str(w):10 window = w11 refreshButton = window.findFirstR(AXHelp='刷新')12 count = 113 while True:14 print("第{}次刷新:".format(count))15 refreshButton.Press()16 time.sleep(5)17 bookableText = window.findFirstR(AXValue='可预约')18 if bookableText:19 print("可预约!")20 requests.get("https://sctapi.ftqq.com/XXXXXXXXXXXXXXXXXX.send?title=GotVaccine!")21 # 上面这是个方糖推送,你可以改成自己的key 或者 换成飞书、钉钉之类的推送方式22 else:23 print("已约满。。。。。")24 count = count + 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 pyatom 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