def initialStore(self):
        print "initialing iTunesStore"
        atomac.launchAppByBundleId(self.bundle_name)
        pattern = re.compile(u'No role')
        trytime = self.tryTime

        while pattern.search(str(atomac.getAppRefByBundleId(
                self.bundle_name))):
            print "step 1 sleep 5 sec..."
            time.sleep(self.shortSleepTime)

        appStoreRef = atomac.getAppRefByBundleId(self.bundle_name)
        # print appStoreRef
        pattern = re.compile('None')

        # print appStoreRef.AXMainWindow.AXFrame
        while trytime > 0 and (pattern.search(str(appStoreRef.AXMainWindow))
                               or pattern.search(str(appStoreRef.AXMainWindow))
                               or pattern.search(
                                   str(
                                       appStoreRef.AXMainWindow.findFirst(
                                           AXRole='AXSplitGroup').findAll()))
                               or len(
                                   appStoreRef.AXMainWindow.findFirst(
                                       AXRole='AXSplitGroup').findAll()) == 0):
            print "network excetion!try again in {}s, try_time remain {} times".format(
                self.shortSleepTime, trytime)
            time.sleep(self.shortSleepTime)
            trytime -= 1

        return appStoreRef
 def launch_restore_manager():
     import atomac
     atomac.launchAppByBundleId('com.mozy.restoremanager')
     time.sleep(2)
     app = atomac.getAppRefByBundleId('com.mozy.restoremanager')
     if app:
         app.activate()
示例#3
0
文件: a.py 项目: d910aa14/atomac
def main():
    pos = 64, 170
    launchAppByBundleId('com.apple.Automator')
    automator = getAppRefByBundleId('com.apple.Automator')
    sleep(3)
    automator.doubleClickMouse(pos)
    sleep(3)
    automator.clickMouseButtonLeftWithMods(pos, ['<control_l>'])
示例#4
0
def launch_app():
    global automator, currentWindow
    atomac.launchAppByBundleId('us.zoom.ringcentral')
    time.sleep(1)
    automator = atomac.getAppRefByBundleId('us.zoom.ringcentral')
    currentWindow = automator.windows()[0]
    signInBtn = currentWindow.findFirstR(AXRole='AXButton', AXTitle='Sign In')
    signInBtn.Press()
    wait_login_screen(15)
示例#5
0
def launchApplication(Cbundleid):
    try:
        atomac.launchAppByBundleId(Cbundleid)
        logging.info('Application launched successfully')
        ldtp.wait(3)
    except Exception as er:
        logging.info(
            'Not able to launch Application, Please check Application added in Accessbility'
        )
示例#6
0
def open_app(cbundID):
    ''' To open the App '''
    try:
        logger("[+] Opening the "+cbundID+"app")
        atomac.launchAppByBundleId(cbundleID)
        time.sleep(3)
        app = atomac.getAppRefByBundleId(cbundleID)
        app.activate()
    except Exception as er:
        logger("[-] Exception while opening the app")
        logger("[-] Error @open_app is "+str(er))
def open_app(bundle_id=None):
	""" to open the application using the bundle ids """
	if not bundle_id:
			log.debug('BundleId value is empty - %s' % bundle_id)
			return 0
	try:
		atomac.launchAppByBundleId(bundle_id)
		time.sleep(5)
		app_ref = atomac.getAppRefByBundleId(bundle_id)
		app_ref.activate()
		log.info('Bundle Id - %s is opened now' % bundle_id)
		return app_ref
	except Exception:
		log.error('Exception caught while opening app', exc_info=True)
		return 0
示例#8
0
 def launch(self):
     if self.isRunning():
         self.sim = atomac.getAppRefByBundleId(self.bid)
         return self.sim
     else:
         atomac.launchAppByBundleId(self.bid)
         init_time = time.time()
         timeout = 20
         thinktime = 0.2
         
         while(time.time() - init_time < timeout):
             sim = atomac.getAppRefByBundleId(self.bid)
             if sim.windows():
                 self.sim = sim
                 return self.sim
             time.sleep(thinktime)
         raise Exception("Simulator launching time out!")
示例#9
0
 def __init__(self, required_capabilities, desired_capabilities):
     self._required_capabilities = required_capabilities
     self._desired_capabilities = desired_capabilities
     self._async_script_timeout = self.get_default_timeout()
     self._implicit_wait = self.get_default_implicit_wait()
     self._timeouts = {}
     self._bundle_id = desired_capabilities.get("bundleId", "")
     self._should_launch_app = desired_capabilities.get("shouldLaunch", True) == True
     self._should_terminate_app = desired_capabilities.get("shouldTerminate", True) == True
     if self._should_launch_app:
         atomac.launchAppByBundleId(self._bundle_id)
         time.sleep(2) #FIXME: wait until app up or timeout
     self._app = atomac.getAppRefByBundleId(self._bundle_id)
     self._current_window = None
     self._active_element = None
     self._update_current_window_to_be_the_first()
     self._cache_of_elements_by_id = {} #FIXME: need to limit the cache and also purge on new windows etc
     self._cache_of_element_ids_by_element_name = {} #FIXME: need to limit the cache and also purge on new windows etc
示例#10
0
def login_app(cbundleID):
    '''login application with username and password'''
    try:
        atomac.launchAppByBundleId(cbundleID)
        app = atomac.getAppRefByBundleId(cbundleID)
        login_window = app.windows()[0]
        time.sleep(2)
        username  = login_window.textFields()[0]
        click_left(username)
        username.sendKeys("YOUR-USERNAME")
        time.sleep(2)
        password = login_window.textFields()[1]
        click_left(password)
        password.sendKeys("YOUR-PASSWORD")
        login_checkbox = login_window.findFirst(AXRole=object_repo['login_checkbox']['AXRole'],AXIdentifier=object_repo['login_checkbox']['AXIdentifier'])
        login_checkbox.Press()
    except Exception as er:
        print "[-] Error @login_app"
        print "[-] Error is "+str(er)
 def restart_appium_server():
     LogHelper.info('===========Now Restarting Appium Server===========')
     print('===========Now Restarting Appium Server===========')
     atomac.launchAppByBundleId('com.appium.Appium')
     app = atomac.getAppRefByBundleId('com.appium.Appium')
     time.sleep(2)
     exec_button = app.findFirstR(AXRole='AXButton', AXIdentifier='_NS:15')
     dustbin_button = app.findFirstR(AXRole='AXButton',
                                     AXIdentifier='_NS:215')
     status = exec_button._getAttribute('AXTitle')
     if status == 'Stop':
         exec_button.Press()
         time.sleep(2)
     dustbin_button.Press()
     exec_button.Press()
     time.sleep(15)
     LogHelper.info(
         '===========Appium Server is launched successfully===========')
     print('===========Appium Server is launched successfully===========')
示例#12
0
 def __init__(self, matcher, index=0, wait_time=1):
     if self.app == None:
         atomac.launchAppByBundleId('com.mozy.restoremanager')
         time.sleep(2)
         self.app = atomac.getAppRefByBundleId('com.mozy.restoremanager')
         self.app.activate()
         self.restore_manager = self.app.findFirstR(AXRole='AXWindow',
                                                    AXIdentifier='_NS:6')
     kwargs = {}
     for (attr, value) in matcher.items():
         kwargs[attr] = value
     time.sleep(wait_time)
     if index == 0:
         self.element = self.restore_manager.findFirstR(**kwargs)
         if self.element == None:
             self.element = self.app.findFirstR(**kwargs)
     else:
         self.element = self.restore_manager.findAllR(**kwargs)[index]
         if self.element == None:
             self.element = self.app.findAllR(**kwargs)[index]
    def launch_mozy_application():
        """
        launch app
        :return:
        """
        bundleId = MacController().spbundleid
        WindowName = 'MozyPro'
        try:
            atomac.launchAppByBundleId(bundleId)
        except RuntimeError as e:
            print e.message
        mozy_window = None

        app = atomac.getAppRefByBundleId(bundleId)
        window = MacUIUtils.wait_element(app, AXRole='AXWindow')
        app.activate()
        btn_showall = MacUIUtils.wait_element(window,
                                              AXRole='AXButton',
                                              AXTitle='Show All')
        MacUIUtils.click_button(btn_showall)
        window = MacUIUtils.wait_element(app, AXRole='AXWindow')

        title = window.AXTitle
        if title == 'MozyPro':  # it is already mozy window
            mozy_window = window
        elif title == "System Preferences":
            btn_mozypro = MacUIUtils.wait_element(app,
                                                  AXRole='AXButton',
                                                  AXTitle=WindowName)
            btn_mozypro.Press()
            mozy_window = MacUIUtils.wait_element(app,
                                                  AXRole='AXWindow',
                                                  AXTitle=WindowName)
        else:
            raise Exception('Not implemented yet')

        if mozy_window.AXRole:
            MacMozyUIBase.mozy_window = mozy_window
            return mozy_window
        else:
            return False
示例#14
0
 def get_root(bundle_id=bundle_id, kwargs=kwargs, wait_time=root_wait_time):
     try:
         atomac.launchAppByBundleId(bundle_id)
         app = atomac.getAppRefByBundleId(bundle_id)
         app.activate()
     except ValueError as e:
         atomac.launchAppByBundleId(bundle_id)
         app = atomac.getAppRefByBundleId(bundle_id)
         app.activate()
     current_wait_second = 0
     parent = app.findFirstR(**kwargs)
     while (parent is None) and current_wait_second < wait_time:
         sleep_time = 5
         time.sleep(sleep_time)
         parent = app.findFirstR(**kwargs)
         current_wait_second += sleep_time
     if parent is None:
         print "error: parent is not find for kwargs %s in %d" % (kwargs, wait_time)
     else:
         parent.activate()
     return parent
示例#15
0
    def initialStore(self):
        """
        start AppleStore
        :return:
        """
        print "initialing appStore"
        atomac.launchAppByBundleId(self.bundle_name)
        pattern = re.compile(u'No role')
        trytime = self.tryTime

        while pattern.search(str(atomac.getAppRefByBundleId(self.bundle_name))):
            print "step 1 sleep 5 sec..."
            time.sleep(self.shortSleepTime)

        appStoreRef = atomac.getAppRefByBundleId(self.bundle_name)
        # print appStoreRef
        pattern = re.compile('None')
        while trytime > 0 and pattern.search(str(appStoreRef.AXMainWindow.findAll()[0])):
            print "network excetion!try again in {}s,trytime remain {} times".format(self.shortSleepTime, self.tryTime)
            time.sleep(self.shortSleepTime)
            trytime -= 1

        return appStoreRef
示例#16
0
    def getApp(bundleName):
        ax = None
        try:
            ax = atomac.getAppRefByBundleId(bundleName)
        except ValueError:
            ax = atomac.launchAppByBundleId(bundleName)
            if ax is None:
                ax = atomac.getAppRefByBundleId(bundleName)

        while ax.AXTitle is None:
            ax = atomac.getAppRefByBundleId(bundleName)

        ax.activate()
        return UIApp(ax)
示例#17
0
    def start_mac_mozy(self):
        """
            launch app
            :return:
            """
        import atomac
        from apps.mac.mac_lib.mac_ui_util import MacUIUtils
        bundleId = MacController().spbundleid
        WindowName = 'MozyPro'
        try:
            atomac.launchAppByBundleId(bundleId)
        except RuntimeError as e:
            print e.message

        app = atomac.getAppRefByBundleId(bundleId)
        app.activate()

        window = MacUIUtils.wait_element(app, AXRole='AXWindow')
        btn_showall = MacUIUtils.wait_element(window,
                                              AXRole='AXButton',
                                              AXTitle='Show All')
        MacUIUtils.click_button(btn_showall)

        title = window.AXTitle
        if title == 'MozyPro':  # it is already mozy window
            mozy_window = window
        elif title == "System Preferences":
            btn_mozypro = MacUIUtils.wait_element(app,
                                                  AXRole='AXButton',
                                                  AXTitle=WindowName)
            btn_mozypro.Press()
            mozy_window = MacUIUtils.wait_element(app,
                                                  AXRole='AXWindow',
                                                  AXTitle=WindowName)

        return mozy_window
示例#18
0
def verify(statement):
    if statement:
        print "passed"
    else:
        print "failed"


# defs
bundleId = "com.kapralos.Unbelievable"
appTitle = "Unbelievable"
upperCaseRadioTitle = "Upper case"
lowerCaseRadioTitle = "Lower case"
transformButtonTitle = "Transform text"

at.launchAppByBundleId(bundleId)
app = at.getAppRefByBundleId(bundleId)

# there is no notification app finish launch notification in atomac, so set a 1-sec sleep
sleep(1)
appWindow = app.windows()[0]
print "App title: " + appWindow.AXTitle

print appWindow.findAll()

inputTextLabel = appWindow.findFirst(AXRole="AXStaticText")
print inputTextLabel

inputTextField = appWindow.findFirst(AXRole="AXTextField")
prefixCheckBox = appWindow.findFirst(AXRole="AXCheckBox")
upperCaseRadio = appWindow.findFirst(AXRole="AXRadioGroup").findFirst(AXTitle=upperCaseRadioTitle)
示例#19
0
 def force_quit_system():
     test = atomac.launchAppByBundleId('com.apple.Preview')
     test
    window.sendKey('<cursor_down>')
    time.sleep(0.5)
    window.sendKey('<num_enter>')
    time.sleep(0.5)
    group.groups()[7].groups()[0].textFields()[0].setString("AXValue", lastName)
    group.groups()[7].groups()[1].textFields()[0].setString("AXValue", firstName)
    group.groups()[8].groups()[0].textFields()[0].setString("AXValue", street)
    group.groups()[9].groups()[0].textFields()[0].setString("AXValue", index)
    group.groups()[9].groups()[1].textFields()[0].setString("AXValue", city)
    group.groups()[10].groups()[0].textFields()[0].setString("AXValue", cityCode)
    group.groups()[10].groups()[1].textFields()[0].setString("AXValue", phoneNumber)
    time.sleep(0.5)
    getContent(window).buttons('Create Apple ID')[0].Press()


atomac.launchAppByBundleId('com.apple.iTunes')
time.sleep(10)
itunes = atomac.getAppRefByBundleId('com.apple.iTunes')
window = itunes.windows()[0]

signOut = itunes.menuItem('Account', 'Sign Out')
if(signOut):
    signOut.Press()
    time.sleep(7)

itunes.menuItem('Account', 1).Press()
time.sleep(7)
signIn(itunes.windows()[0])
time.sleep(7)
if itunes.windows()[0].AXIdentifier == "_NS:15":
    itunes.windows()[0].findFirst(AXRole = "AXButton", AXSubrole = "AXCloseButton").Press()
示例#21
0
    group.groups()[7].groups()[0].textFields()[0].setString(
        "AXValue", lastName)
    group.groups()[7].groups()[1].textFields()[0].setString(
        "AXValue", firstName)
    group.groups()[8].groups()[0].textFields()[0].setString("AXValue", street)
    group.groups()[9].groups()[0].textFields()[0].setString("AXValue", index)
    group.groups()[9].groups()[1].textFields()[0].setString("AXValue", city)
    group.groups()[10].groups()[0].textFields()[0].setString(
        "AXValue", cityCode)
    group.groups()[10].groups()[1].textFields()[0].setString(
        "AXValue", phoneNumber)
    time.sleep(0.5)
    getContent(window).buttons('Create Apple ID')[0].Press()


atomac.launchAppByBundleId('com.apple.iTunes')
time.sleep(10)
itunes = atomac.getAppRefByBundleId('com.apple.iTunes')
window = itunes.windows()[0]

signOut = itunes.menuItem('Account', 'Sign Out')
if (signOut):
    signOut.Press()
    time.sleep(7)

itunes.menuItem('Account', 1).Press()
time.sleep(7)
signIn(itunes.windows()[0])
time.sleep(7)
if itunes.windows()[0].AXIdentifier == "_NS:15":
    itunes.windows()[0].findFirst(AXRole="AXButton",
示例#22
0
import atomac
import time
bundle_name = 'com.apple.iTunes'
atomac.launchAppByBundleId(bundle_name)
appStoreRef = atomac.getAppRefByBundleId(bundle_name)
_searchTextField = appStoreRef.AXMainWindow.findFirst(AXRole='AXTextField')

x, y = _searchTextField.AXPosition
width, height = _searchTextField.AXSize
_searchTextField.AXValue = '1111'
time.sleep(5)
_searchTextField.clickMouseButtonLeft((x + width / 2, y + height / 2))
time.sleep(5)
_searchTextField.sendKey('<cursor_right>')
_searchTextField.sendKey('<space>')
_searchTextField.sendKey('<backspace>')
_searchTextField.sendKey('\r')

print appStoreRef.AXMainWindow.AXSize
示例#23
0
文件: auto.py 项目: zbo/AutoPyMac
import atomac
import time

atomac.launchAppByBundleId('us.zoom.ringcentral')
time.sleep(1)
automator = atomac.getAppRefByBundleId('us.zoom.ringcentral')
window = automator.windows()[0]
print window.AXTitle
all=window.findAll()
all_in_group=all[0].findAll()
sign_in_button=all_in_group[2]
sign_in_button.Press()
time.sleep(10)
window = automator.windows()[0]
all=window.findAll()
print len(all)
#all[3].Press() #3 is close
#all[4].Press() #4 is max
#all[5].Press() #5 is min
web_area=all[0].findAll()[0]
web_all=web_area.findAll()
for i in range(len(web_all)):
    group_all=web_all[i].findAll()
    for j in range(0,len(group_all)):
        print '=================='+str(j)+'================'
        print group_all[j]
        print group_all[j].getActions()


示例#24
0
import atomac
atomac.launchAppByBundleId('com.apple.Automator')
示例#25
0
import atomac
import time
import pyscreeze
atomac.launchAppByBundleId('com.apple.calculator')
calc = atomac.getAppRefByBundleId('com.apple.calculator')
time.sleep(2)
window = calc.windows()[0]
print window.getAttributes()
print window.AXPosition
print window.AXSize
rect = [window.AXPosition[0], window.AXPosition[1], window.AXSize[0], window.AXSize[1]]
print rect
calc_img = pyscreeze.screenshot(region=rect)
calc_img.load() #important!!!!!
calc_img.save("calc.png", "PNG")
print calc_img
from base64 import encodestring, b64encode
from StringIO import StringIO
buffer_in_memory = StringIO()
calc_img.save(buffer_in_memory, 'PNG')
buffer_in_memory.seek(0)
img_base_64 = b64encode(buffer_in_memory.getvalue())
print img_base_64
示例#26
0
 def launch():
     atomac.launchAppByBundleId(BUNDLE)
     time.sleep(3)