Best Python code snippet using pyatom_python
OSXUIFunc.py
Source:OSXUIFunc.py
...14 ws = AppKit.NSWorkspace.sharedWorkspace()15 apps = ws.runningApplications()16 return apps17 @classmethod18 def getAppRefByPid(cls, pid):19 return _a11y.getAppRefByPid(atomac.AXClasses.NativeUIElement, pid)20 @classmethod21 def getAppRefByBundleId(cls, bundleId):22 """23 Get the top level element for the application with the specified24 bundle ID, such as com.vmware.fusion.25 """26 ra = AppKit.NSRunningApplication27 # return value (apps) is always an array. if there is a match it will28 # have an item, otherwise it won't.29 apps = ra.runningApplicationsWithBundleIdentifier_(bundleId)30 if len(apps) == 0:31 raise ValueError(('Specified bundle ID not found in '32 'running apps: %s' % bundleId))33 pid = apps[0].processIdentifier()34 return cls.getAppRefByPid(pid) 35 @classmethod36 def getAppRefByLocalizedName(cls, name):37 apps = cls.getRunningApps()38 for app in apps:39 if fnmatch.fnmatch(app.localizedName(), name):40 pid = app.processIdentifier()41 return cls.getAppRefByPid(pid)42 raise ValueError('Specified application not found in running apps.')43 @staticmethod44 def press(x, y, button=1):45 event = Quartz.CGEventCreateMouseEvent(None, pressID[button], (x, y), button - 1)46 Quartz.CGEventPost(Quartz.kCGHIDEventTap, event)47 @staticmethod48 def release(x, y, button=1):49 event = Quartz.CGEventCreateMouseEvent(None, releaseID[button], (x, y), button - 1)50 Quartz.CGEventPost(Quartz.kCGHIDEventTap, event)51 @staticmethod52 def click(x, y, button=1):53 theEvent = Quartz.CGEventCreateMouseEvent(None, pressID[button], (x, y), button - 1)54 Quartz.CGEventPost(Quartz.kCGHIDEventTap, theEvent) 55 Quartz.CGEventSetType(theEvent, Quartz.kCGEventLeftMouseUp) ...
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!!