當前位置: 首頁>>代碼示例>>Python>>正文


Python easy.By類代碼示例

本文整理匯總了Python中com.android.monkeyrunner.easy.By的典型用法代碼示例。如果您正苦於以下問題:Python By類的具體用法?Python By怎麽用?Python By使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了By類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: send_msg

    def send_msg(self,data):
        print '\n------------ send_msg ------------'
        if not data.get('msg'):
            return -1        
        if self.is_current_group() != 0:
            return -1

        utils.get_encoded_character(deviceid, data['msg'].decode('utf8'))
        self.restart_qq_monkey()

        self.easy_device.touch(By.id("id/input"), self.easy_device.DOWN)
        # self.device.touch(500,1700,'DOWN')
        sleep(0.5)
        self.easy_device.touch(By.id("id/input"), self.easy_device.UP)
        # self.device.touch(500,1700,'UP')
        # sleep(1)
        self.touchByMonkeyPixel(270,1590)

        inputid = self.get_hierarchy_view_by_id('id/input')
        if inputid:
            text = self.getTextByMonkeyView(inputid)
            print "Info : get msg %s from clipboard !" % text
            if text.strip().split() == data['msg'].strip().split():
                if self.touchByMonkeyId('id/fun_btn') != 0:
                # if self.touchByMonkeyPixel(970,1700) != 0:
                    return -1
        print "Info : send msg %s !" % data['msg']
        return 0
開發者ID:nc1989,項目名稱:monkey,代碼行數:28,代碼來源:monkeyDaemon.py

示例2: addFirstContact

def addFirstContact():
    
    easy_device.touch(By.id('id/create_contact_button'),MonkeyDevice.DOWN_AND_UP)
    MonkeyRunner.sleep(6)
    if easy_device.visible(By.id('id/content')):
        easy_device.touch(By.id('id/left_button'),MonkeyDevice.DOWN_AND_UP)
        trace( 'select contact information keep local')
    else:
        MonkeyRunner.sleep(6)
開發者ID:faure999,項目名稱:autoPy,代碼行數:9,代碼來源:easy_add.py

示例3: case_login

 def case_login(self):
     self.device.startActivity( component=self.apk_name_activity )
     mr.sleep(3.0)
     self.easy_device.touch(By.id('id/username'),md.DOWN_AND_UP)
     text = self.easy_device.getText(By.id('id/username'))
     self.device.press('KEYCODE_MOVE_END', md.DOWN_AND_UP)
     for i in range(len(text)):
         self.device.press('KEYCODE_DEL', md.DOWN)
     self.device.type(self.data[0])
     self.easy_device.touch(By.id('id/password'),md.DOWN_AND_UP)
     self.device.type(self.data[1])
     self.easy_device.touch(By.id('id/login'),md.DOWN_AND_UP)
     print "case_login"
開發者ID:majf2015,項目名稱:android_SDK,代碼行數:13,代碼來源:android_SDK_test.py

示例4: getElementCenterById

 def getElementCenterById(self, str_id):
     try:
         return self.easy_device.getElementCenter(By.id("id/" + str_id))
     except Exception, e:
         msg = "[%s] Failed to get element center by Id: [%s]" %(self.class_name, str(e))
         self.m_logger.error(msg)
         return None
開發者ID:Bludge0n,項目名稱:apk-view-tracer,代碼行數:7,代碼來源:EasyDeviceImpl.py

示例5: getExistById

 def getExistById(self, str_id):
     try:
         return self.easy_device.exists(By.id("id/" + str_id))
     except Exception, e:
         msg = "[%s] Failed to get exist by Id: [%s]" %(self.class_name, str(e))
         self.m_logger.error(msg)
         return None
開發者ID:Bludge0n,項目名稱:apk-view-tracer,代碼行數:7,代碼來源:EasyDeviceImpl.py

示例6: touchById

 def touchById(self, str_id, action_type="DOWN_AND_UP"):
     try:
         return self.easy_device.touch(By.id("id/" + str_id), self.action_type_dict[action_type])
     except Exception, e:
         msg = "[%s] Failed to touch by Id: [%s]" %(self.class_name, str(e))
         self.m_logger.error(msg)
         return None
開發者ID:Bludge0n,項目名稱:apk-view-tracer,代碼行數:7,代碼來源:EasyDeviceImpl.py

示例7: addContactDetail

def addContactDetail(name,phoneNumber):  
    easy_device.type(By.id('id/0x3'),name)
    MonkeyRunner.sleep(3)
    easy_device.type(By.id('id/0x17'),phoneNumber)
    easy_device.touch(By.id('id/save_menu_item'),MonkeyDevice.DOWN_AND_UP)
    MonkeyRunner.sleep(7)
    s= easy_device.getText(By.id('id/data'))
    trace('contact add success,phone number:' + s)
    phoneInfo= s.replace('-','').replace(' ','').replace('(','').replace(')','')
    if phoneInfo == phoneNumber:
        trace('contact information check success')
    else:
        trace('contact information add wrong')
        
    device.shell('am force-stop com.android.contacts')
    trace('destroy current contacts application')
開發者ID:faure999,項目名稱:autoPy,代碼行數:16,代碼來源:easy_add.py

示例8: do_check

 def do_check(self, str_arg):
     printLog(self.threadName+"[running command 'check %s']" % str_arg)
     arg=self.__validateString(str_arg)
     ret=arg.split(' ', 1)
     compID=None
     #check id, just check existing or not
     try:
         compID=By.id(ret[0])
         #all our checked items, must be visible
         if not self.ed.visible(compID):
             self.resultFlag=False
             printLog(self.threadName+'%s is not visible.' % compID,logging.ERROR)
             return
         if len(ret)==2:
             #get element text, and compare it with the given text value
             text_on_screen=self.ed.getText(compID).strip()
             target=ret[1].strip()
             printLog(self.threadName+'[text on screen: %s]' % text_on_screen)
             #have GBK problem, need to solve, or text1 is always gbk in chinese machine
             if not text_on_screen==target.decode('utf-8'):
                 self.resultFlag=False
     except java.lang.RuntimeException:
         self.resultFlag=False
         printLog(self.threadName+'Runtime Exception! %s not found.' % compID, logging.ERROR)
     except Exception, e:
         #gbk problem
         self.resultFlag=False
         printLog(self.threadName+'Exception in do_check: %s' % e.message, logging.ERROR)
開發者ID:xinquanking,項目名稱:test4u,代碼行數:28,代碼來源:AndroidDevice.py

示例9: addContact

def addContact(name,phoneNumber):
    
    device.startActivity(component = 'com.android.contacts/.activities.PeopleActivity')
    MonkeyRunner.sleep(3)
    if  easy_device.visible(By.id('id/create_contact_button')):
        trace('add contact first time')
        addFirstContact()
    
    elif  easy_device.visible(By.id('id/menu_add_contact')):
        
        trace("Location of add contact menu:" + str(easy_device.locate(By.id('id/menu_add_contact'))))
    
        easy_device.touch(By.id('id/menu_add_contact'), MonkeyDevice.DOWN_AND_UP)
        MonkeyRunner.sleep(7)
    else:
        raise Error('Could not find the "menu_add_contact" button')
    addContactDetail(name,phoneNumber)
開發者ID:faure999,項目名稱:autoPy,代碼行數:17,代碼來源:easy_add.py

示例10: typeInViewById

 def typeInViewById(self, str_id, str_msg):
     try:
         self.easy_device.type(By.id("id/" + str_id), str_msg)
         return True
     except Exception, e:
         msg = "[%s] Failed to type in view [%s]" %(self.class_name, str(e))
         self.m_logger.error(msg)
         return False
開發者ID:Bludge0n,項目名稱:apk-view-tracer,代碼行數:8,代碼來源:EasyDeviceImpl.py

示例11: case_order_select

 def case_order_select(self, s):
     mr.sleep(1.0)
     self.easy_device.touch(By.id("id/toolbar_right"),md.DOWN_AND_UP)
     mr.sleep(1.0)
     if s == "order":
         self.device.touch(400,222,md.DOWN_AND_UP)
     elif s == "accepted":
         self.device.touch(400,293,md.DOWN_AND_UP)
     print "case_order_select"
開發者ID:majf2015,項目名稱:android_SDK,代碼行數:9,代碼來源:android_SDK_test.py

示例12: case_order_drag

 def case_order_drag(self):
     mr.sleep(2.0)
     self.easy_device.touch(By.id("id/order_manage"),md.DOWN_AND_UP)
     for i in range(3):
         self.device.drag((190, 770), (190, 130),0.1,  5)
         mr.sleep(1.0)
     for i in range(5):
         self.device.drag((190, 130), (190, 770),0.1,  5)
     print "case_order_drag"
開發者ID:majf2015,項目名稱:android_SDK,代碼行數:9,代碼來源:android_SDK_test.py

示例13: touchByMonkeyId

 def touchByMonkeyId(self,id):
     # print '------------ touchByMonkeyId %s -------------' % id
     try:
         self.screenUsing = 1
         self.easy_device.touch(By.id(id), self.easy_device.DOWN_AND_UP)
         sleep(0.5)
         self.screenUsing = 0
         return 0
     except:
         print 'Error : failed to dump view : %s !' % id
         return -1
開發者ID:nc1989,項目名稱:monkey,代碼行數:11,代碼來源:monkeyDaemon.py

示例14: select_menu

 def select_menu(self, item,id = "id/title"):
     """select menu option.
     
     argv: (str)item -- option display in menu list.
     return void
     author: Zhihao.Gu
     """
     self._logger.debug("Select menu option: %s." % item)
     self._device.press("KEYCODE_MENU", MDAU)
     MonkeyRunner.sleep(1)
     self._easy_device.touchtext(By.id(id), item, MDAU)
     MonkeyRunner.sleep(1)
開發者ID:LiZoRN,項目名稱:flyadb,代碼行數:12,代碼來源:monkeyUser.py

示例15: jisuanji

def jisuanji():

    # 滑動解鎖
    jiesuo()

    # 打開計算器
    device.startActivity(component="com.tencent.qrom.calculator/com.tencent.qrom.calculator.Calculator")
    time.sleep(1)
    print ("ok")

    # 將device對象包裝成EasyMonkeyDevice類對象

    ed = EasyMonkeyDevice(device)
    print ("okok")

    # 96*3=
    ed.touch(By.id("id/digit9"), MonkeyDevice.DOWN_AND_UP)

    ed.touch(By.id("id/digit6"), MonkeyDevice.DOWN_AND_UP)

    ed.touch(By.id("id/mul"), MonkeyDevice.DOWN_AND_UP)

    ed.touch(By.id("id/digit3"), MonkeyDevice.DOWN_AND_UP)

    ed.touch(By.id("id/equal"), MonkeyDevice.DOWN_AND_UP)

    print ("ok2")

    # 通過ID獲取mText
    h = ed.getText(By.id("id/digit9"))

    print (h)
開發者ID:ctro15547,項目名稱:test,代碼行數:32,代碼來源:test.py


注:本文中的com.android.monkeyrunner.easy.By類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。