当前位置: 首页>>代码示例>>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;未经允许,请勿转载。