Exemplo n.º 1
0
    def testDeletePicture(self):
        """
        Summary:testCapturePictureAndDelete: Take a picture, then view and delete the picture.
        Steps:1. Open Camera app
              2. Touch thumbnail to view the picture
              3. Touch setting menu
              4. Touch Delete button to delete the picture
              5. Exit Camera app
        """
        #step1
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(description = 'Shutter button').wait.exists(), 'Camera launch failed'

        BEFORE_DELETE = commands.getoutput(QUERY_PICTURE_COUNT_COMMANDS)

        #step2
        d.swipe(startX, startY, endX, endY, steps = 10)
        time.sleep(2)
        d.click(274,482)

        #step3
        d.press('menu')
        assert d(text = 'Delete').wait.exists()

        #step4
        d(text = 'Delete').click.wait()
        d(text = 'OK').click.wait(timeout = 2000)

        AFTER_DELETE = commands.getoutput(QUERY_PICTURE_COUNT_COMMANDS)
        assert int(AFTER_DELETE) == int(BEFORE_DELETE) - 1, 'Picture delete failed'
 def gallery_delete(self):
     """Delete one pictures or some pictures or all pictures in gallery
     """
     self._logger.debug("Begin to delete pictures in gallery app.")
     if device(text='Camera roll',
               resourceId='com.tct.gallery3d:id/actionbar_title').exists:
         self._logger.debug(
             "Now is in the  Camera roll,can select the item")
         device(description='Open navigation drawer').click()
         device.delay(1)
         if device(text='Camera roll',
                   resourceId='com.tct.gallery3d:id/tx').wait.exists(
                       timeout=10000):
             self._logger.debug(
                 "Enter the item to select the Camera roll,Albums...")
             device(text='Camera roll',
                    resourceId='com.tct.gallery3d:id/tx').click()
             device.delay(1)
             device.long_click(80, 200)
             if device(description='Delete').wait.exists(timeout=10000):
                 self._logger.debug(
                     "Success enter to select the ablum,There is some pictures"
                 )
                 device.click(80, 200)
             else:
                 self._logger.warning(
                     "There isn't pictures,please import some pictures")
         else:
             self._logger.debug(
                 "Fail to enter the item to select the Camera roll,Alums..."
             )
     else:
         self._logger.debug("Fail enter to gallery interface")
Exemplo n.º 3
0
def runtest(serialno, loop, musicname):
    if serialno:
        from uiautomator import Device
        d = Device(serialno)
    else:
        from uiautomator import device as d

    print "总共 %d 次循环" %loop

    for i in range(1, loop+1):
        print "第 %d 次循环" %i
        d.screen.on()
        d.press.home()
        removeRecentList(d, "File Manager")
        d(description="Apps").click()
        d(text="File Manager").click()
        d(text="sdcard").click()
        d(text="Music").click()
        d(text=musicname).click()
        d(text="Google Play Music").click()
        if d(text="Just once").exists:
            d(text="Just once").click()

        for i in range(1,20):
            x = random.randint(200, 600)
            d.click(x,464)
            time.sleep(3)
        d.press.back()
        d.press.home()
        i += 1
    
    print "***** test end ********"
Exemplo n.º 4
0
def changeBTHFP(num):
    lc.fileLog().info('start changeBTHFP...')
    x_index = 476 + num * 7
    lc.fileLog().info('BTHFP_x_index... ' + str(x_index) + ' => +' + str(num))
    d.click(x_index, 357)
    # lc.fileLog().info(d(className='android.widget.SeekBar', resourceId='com.imotor.settings:id/seekbar').info)
    lc.fileLog().info('start changeBTHFP...')
def runtest(serialno, loop):
    if serialno:
        from uiautomator import Device
        d = Device(serialno)
        #d = Device("860424734447f8e0109")
    else:
        from uiautomator import device as d

    print "总共 %d 次循环" %loop
    for i in range(1, loop):
        print "第 %d 次循环" %i
        d.screen.on()
        d.press.home()
        d(description="Apps").click()
        d(text="Camera").click()
        d(description="Menu button").click()
        d.click(302,412)
        time.sleep(2)
        d(description="Camera, video, or panorama selector").click()
        d(description="Switch to photo").click()
        d(description="Shutter button").click()
        d(description="Camera, video, or panorama selector").click()
        d(description="Switch to video").click()
        d(description="Shutter button").click()
        time.sleep(30)
        d(description="Shutter button").click()
        d(description="Menu button").click()
        d.click(306,409)
        time.sleep(2)
        d.press.back()
        d.press.home()
        i += 1
    
    print "***** test end ********"
Exemplo n.º 6
0
def upgradeCity():
    d.click(617, 365)
    sleep(1)
    if isSame("city"):
        print "upgradeCity"
        menu(3)
        upgradeButton()
Exemplo n.º 7
0
def setSoundEffect():
    lc.fileLog().info('start setSoundEffect...')
    swipeUpRightItems()
    swipeUpRightItems()
    d.click(600, 390)
    d(resourceId='android:id/title', text='SOUND EFFECT').click()
    lc.fileLog().info('stop setSoundEffect...')
Exemplo n.º 8
0
    def testdeletecontact(self):
	"""
	Summary:testAddContact: Add a contact.
	Steps:
	    1. Open Contacts app
	    2. Delete contact
	    3. Exit Contacts app
	"""
	#get contact number before delete
	beforeNO = self.getcontactnumber()
	#step 2 if beforeNO=0
	if beforeNO == 0:
	    d(text='Create a new contact').click.wait()
	    if d.exists(text='Keep local'):
		d(text='Keep local').click.wait()
	    self.inputcontactinfo()
	    d(resourceId='android:id/up').click.wait()
	    time.sleep(3)
	    beforeNO = self.getcontactnumber()
	#single tap the first contact 
	d.click(338,478)
	#delete contact
	d(description='More options',index='1').click.wait()
	d(text='Delete').click.wait()
	d(text='OK').click.wait()
	time.sleep(3)
	afterNO = self.getcontactnumber()
	#assert afterNO = beforeNO - 1
	assert afterNO == beforeNO - 1
Exemplo n.º 9
0
def changeSoundStyle(item, num):
    lc.fileLog().info('start changeSoundStyle...')
    listOfItems = ['60', '100', '200', '500', '1.5K', '2.5K', '10K', '15K', '17.5K']  # 音轨
    x_index = {
        '60': 150,
        '100': 240,
        '200': 330,
        '500': 420,
        '1.5K': 510,
        '2.5K': 600,
        '10K': 690,
        '15K': 780,
        '17.5K': 870
    }  # 音轨对应横坐标、纵坐标[529.3,190.3] 每当11.3 共30档

    if num < -15 or num > 15:  # 参数检验
        lc.fileLog().info('num is not in [-15, 15]')
    else:
        if item in listOfItems:
            x = x_index.get(item)
            y = 190.3 + abs(num - 15) * 11.3  # y轴坐标 其实点位190.3
            lc.fileLog().info('x :' + str(x) + ' y : ' + str(y))  # 点击位置
            d.click(x, y)
        else:
            lc.fileLog().info('item is not exits')
    lc.fileLog().info('stop changeSoundStyle...')
Exemplo n.º 10
0
    def testDeleteVideo(self):
        """
        Summary:testRecordVideoAndDelete: Record a video, then play and delete the video.
        Steps:1. Open Camera app
              2. Record a video
              3. Touch thumbnail to view the video
              4. Touch Delete button to delete the video
              5. Exit Camera app
        """
        BEFORE_DELETE=commands.getoutput(QUERY_VIDEO_COUNT_COMMANDS)

        #step1,2
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(description = 'Shutter button').wait.exists(), 'Camera launch failed'
        d(description = 'Camera, video, or panorama selector').click.wait()
        d(description = 'Switch to video').click.wait()
        assert d(description = 'Shutter button').wait.exists(), 'Video Camera launch failed'

        #step3
        d.swipe(startX, startY, endX, endY, steps = 10)
        time.sleep(2)
        d.click(274,482)

        #step4
        d.press('menu')
        assert d(text = 'Delete').wait.exists()
        d(text = 'Delete').click.wait()
        d(text = 'OK').click.wait(timeout = 2000)

        AFTER_DELETE = commands.getoutput(QUERY_VIDEO_COUNT_COMMANDS)

        assert int(AFTER_DELETE) == int(BEFORE_DELETE) - 1, 'Video record failed'
Exemplo n.º 11
0
  def SendContactsviaSMS(self,numsend,sendnum):

    device.screen.on()
    device.press.home()

#device log info("move to contacts")
    device(text="Contacts").click()
    device(text = "All contacts").click()
    #device(scrollable=True).scroll.to(text=name)

#device log info("number to send")
    device(scrollable=True).scroll.to(text=numsend)
    device(text = numsend).click()
    device.press.menu()
    device(text="Send contact via SMS").click()
    device.click(640,242)

#device log info("send message")
    #device(text="To").set_text(str3)
    #mb=raw_input
    device(scrollable=True).scroll.to(text=sendnum)
    device(text = sendnum).click()
    device.click(552,58)
    device.press.menu()
    device(text="Send").click()
    device.press.back()
    device.press.back()
    device.press.home()
Exemplo n.º 12
0
  def SendSMSFromContacts(self,name,message):
#    device = Device('4a25b8a')
    device.screen.on()
    device.press.home()

#device log info("move to contacts")
    device(scrollable=True).scroll.horiz.forward()
    device(scrollable=True).scroll.vert.backward()
    device(text="Contacts").click()

#device log info("select contact")
    device(scrollable=True).scroll.to(text=name)
    device(text = name).click()

#device log info("create message")
    device(className="android.widget.ImageView",resourceId="com.android.contacts:id/icon_alternate").click()

#device log info("input message")
    #device.input ("Test message")
    device(text="Type message").set_text(message)
    mb=raw_input

#device log info("send message")
    #device(className="android.widget.ImageView",resourceId="com.android.mms:id/send_button_sms").click()
    device.click(544,1176)
    device.press.home()
Exemplo n.º 13
0
    def testCallFromPhoneBook(self):
        """
        Summary:testCallFromPhoneBook: Make a call from phonebook.
        Steps:1. Launch phone app
              2. Touch Contacts tab
              3. Touch the first contact
              4. Touch call button to make a call
              5. End the call
              6. Exit Phone app
        """
        #step1
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(description = 'Favorites and all contacts').wait.exists(), 'Phone launch failed'
        #step2
        d(description = 'Favorites and all contacts').click.wait()
        #step3,4
        for i in range (random.randint(1,5)):
            d.swipe(196,700,196,180,steps = 10)
      
        for i in range (random.randint(1,5)):
            d.swipe(196,180,196,700,steps = 10)

        d.click(random.randint(130,370),random.randint(217,871))
        assert d(text = 'Dialing').wait.exists(timeout = 15000), 'Not start to call'
        assert d(textContains = '0:').wait.exists(timeout = 15000), 'Call is not connected'
        #step5
        d(description = 'End').click.wait()
        assert d(description = 'Favorites and all contacts').wait.exists(), 'Call end failed'
Exemplo n.º 14
0
def runtest(serialno, loop, videoname):
    if serialno:
        from uiautomator import Device
        d = Device(serialno)
    else:
        from uiautomator import device as d

    print "总共 %d 次循环" %loop

    for i in range(1, loop+1):
        print "第 %d 次循环" %i
        d.screen.on()
        d.press.home()
        removeRecentList(d, "File Manager")
        d(description="Apps").click()
        d(text="File Manager").click()
        time.sleep(0.5)
        d(text="sdcard").click()
        d(text="Movies").click()
        d(text=videoname).click()
        for i in range(1,20):
            x = random.randint(100, 600)
            d.click(x, 80)
            time.sleep(3)
        
        d.press.back()
        d.press.home()
        i += 1

    print "***** test end ********"
Exemplo n.º 15
0
def jd_samsung():
    d.screen.on()
    d.press.home()
    #解锁,没有密码的情况下
    sx = 560
    sy = 1700
    ex = 560
    ey = 900
    #d.swipe(sx,sy,ex,ey,steps=2)

    #d(scrollable=True).fling.horiz.forward()
    home_swipe_sx = 627
    home_swipe_sy = 900
    home_swipe_ex = 120
    home_swipe_ey = 900
    while not d(text=u"手机京东").exists:
        d.swipe(home_swipe_sx,
                home_swipe_sy,
                home_swipe_ex,
                home_swipe_ey,
                steps=2)
        time.sleep(3)
    d(text=u'手机京东').click()
    if not d(text=u'领京豆').wait.exists(timeout=20 * 1000):
        print "Failed to get the page"
        return
    d(text=u'领京豆').click()
    dou_x = 853
    dou_y = 400

    #glaxy_x=yun_x*gallery*full/cuizi_full
    time.sleep(15)
    d.click(dou_x, dou_y)
    print "JD done"
Exemplo n.º 16
0
def taobao_samsung():
    d.screen.on()
    d.press.home()
    #解锁,没有密码的情况下
    sx = 560
    sy = 1700
    ex = 560
    ey = 900
    #d.swipe(sx,sy,ex,ey,steps=2)

    #d(scrollable=True).fling.horiz.forward()
    home_swipe_sx = 627
    home_swipe_sy = 900
    home_swipe_ex = 120
    home_swipe_ey = 900
    while not d(text=u"手机淘宝").exists:
        d.swipe(home_swipe_sx,
                home_swipe_sy,
                home_swipe_ex,
                home_swipe_ey,
                steps=2)
        time.sleep(3)
    d(text=u'手机淘宝').click()
    if d(text=u'领金币').wait.exists(timeout=12 * 1000):
        print "Dismiss update"
        d(text=u'领金币').click()
    #登录账号,刷新下即可

    time.sleep(15)
    jb_x = 900
    jb_y = 370
    d.click(jb_x, jb_y)
Exemplo n.º 17
0
def alipay():
    activity_name = 'com.eg.android.AlipayGphone/.AlipayLogin'
    launch_app(activity_name)
    time.sleep(10)
    track_list = [
        (987, 1840),
        (563, 491),
        (155, 983),
        (544, 686),  # 连续点击
        (544, 686),
        (544, 686),
        (544, 686),
        (544, 686),
        (544, 686),
        (544, 686),
        (544, 686),
        (544, 686),
        (544, 686),
        (544, 686),
        (544, 686),
        (544, 686)
    ]
    for step in track_list:
        d.click(step[0], step[1])
        print('click')
        time.sleep(5)
Exemplo n.º 18
0
def autoJob(tv, sleep_time, sum=6, click=True):
    count_click = 0
    count = 0
    drag_str = 'adb shell input swipe ' + str(Width * 0.5) + ' ' + str(
        Height * 0.88) + ' ' + str(Width * 0.5) + ' ' + str(Height * 0.3)
    for _ in range(100):
        text_lists = driver(className='android.widget.TextView')
        try:
            for i in range(len(text_lists)):
                txt = text_lists[i].text
                if len(txt) > 11 and txt not in all_of_list and count < sum:
                    driver(text=txt,
                           className='android.widget.TextView').click()
                    #分享,收藏,评论
                    if click and count_click < 2:
                        #分享
                        time.sleep(4)
                        driver.click(0.94 * Width, 0.975 * Height)
                        time.sleep(2)
                        driver(text="分享到学习强国").click()
                        time.sleep(2)
                        driver.press.back()
                        #收藏
                        driver.click(0.84 * Width, 0.975 * Height)
                        #评论
                        time.sleep(1)
                        driver(text="欢迎发表你的观点").click()
                        time.sleep(2)
                        os.system(
                            "adb shell am broadcast -a ADB_INPUT_TEXT --es msg '中国加油,武汉加油!'"
                        )
                        os.system("adb shell input keyevent 66"
                                  )  #不知道为什么输入一个回车,点击发布才有反应
                        time.sleep(2)
                        driver(text="发布").click()
                        count_click = count_click + 1
                        '''
                        @liuzhijie443
                        #收藏
                        time.sleep(5)
                        driver.click(0.84*Width, 0.975*Height)
                        time.sleep(1)
                        driver.click(0.84*Width, 0.975*Height)
                        #删除发布的评论
                        time.sleep(2)
                        driver(text="删除").click()
                        time.sleep(2)
                        driver(text="确认").click()
                        '''
                    count = count + 1
                    all_of_list.append(txt)
                    print("正在" + tv + "...", txt)
                    time.sleep(sleep_time)
                    driver.press.back()
        except BaseException:
            print("抛出异常,程序继续执行...")
        if count >= sum:
            break
        os.system(drag_str)
Exemplo n.º 19
0
def tb_coin():
    #completed this function
    launch_tb_activity()
    time.sleep(10)
    d.click(700, 860)
    time.sleep(9)
    print("TaoBao Coin")
    exit_tb()
Exemplo n.º 20
0
def fanye(inprogress):
    d.screen.on()
    d.click(700, 1200)
    time.sleep(interval)
    inprogress += interval
    print(inprogress)
    print('本次已经观看 {} 秒'.format(inprogress))
    return inprogress
Exemplo n.º 21
0
def tb_coin():
    #completed this function
    launch_tb_activity()
    time.sleep(10)
    d.click(700, 860)
    time.sleep(9)
    print("TaoBao Coin")
    exit_tb()
Exemplo n.º 22
0
def not_found_handler(DEVICE):
    logger.debug('[not_found_handler]')
    if DEVICE(text='Não foi possível exportar a conversa.').exists:
        logger.error('Não foi possível exportar a conversa anterior')
        DEVICE(text='OK').click()
    else:
        logger.warning(f'[CLICK] x={NEUTRAL_POS[0]}, y={NEUTRAL_POS[1]}')
        DEVICE.click(
            *NEUTRAL_POS)  # Clica num local "neutro" para fechar popup
Exemplo n.º 23
0
def findTP():
    element = Element()
    ls = element.findElementsById("com.tencent.mm:id/mi")
    print(ls)
    # for i in list:
    d.click(ls[3][0], ls[3][1])
    pl = element.findElementById("com.tencent.mm:id/e38")
    print(pl)
    d.click(pl[0], pl[1])
Exemplo n.º 24
0
def set_date():
    d(text="设置日期").click()#点击设置日期
    time.sleep(1)
    d.swipe(890,1440,890,1280,step = 10)#向上滚动一天
    time.sleep(1)
    d.click(800,1800)#确定
    time.sleep(1)

    up_keybroad()
Exemplo n.º 25
0
 def test_lock_unlock(self):
     for i in xrange(2):
         self.checkScreen()
         d.click(1380, 800)
         time.sleep(2)
         self.inputCode()
         time.sleep(2)
         d.sleep()
         time.sleep(2)
Exemplo n.º 26
0
def setDisplay(num):
    lc.fileLog().info('start setDisplay...')
    d(text='DISPLAY').click()
    d(text='BACKLIGHT BRIGHTNESS').click()
    x = 259 + num * 28
    y = 340.5
    d.click(x, y)
    lc.fileLog().info('lc.fileLog().info [' + str(x) + ', ' + str(y) + ']')
    lc.fileLog().info('stop setDisplay...')
Exemplo n.º 27
0
def cmcc():
    activity_name = 'com.kingpoint.gmcchh/.newui.main.skeleton.view.SkeletonActivity'
    launch_app(activity_name)
    time.sleep(15)

    track_list = [(123, 1865), (651, 338), (520, 957)]
    for step in track_list:
        d.click(step[0], step[1])
        print('click')
        time.sleep(5)
Exemplo n.º 28
0
def yunsanfu():
    activity_name = 'com.unionpay/.activity.UPActivityWelcome'
    launch_app(activity_name)
    time.sleep(8)

    track_list = [(981, 1389), (541, 782)]
    for step in track_list:
        d.click(step[0], step[1])
        time.sleep(5)
    print('云闪付签到完成')
Exemplo n.º 29
0
def changeLoundnessValue(num):
    lc.fileLog().info('start setLoundnessValue...')
    if num < -15 or num > 0:  # 参数检验
        lc.fileLog().info('num is not in [-15, 0]')
    else:
        x = 860 + num * 28
        y = 295.5  # y轴坐标 其实点位295.5
        lc.fileLog().info('x :' + str(x) + ' y : ' + str(y))  # 点击位置
        d.click(x, y)
    lc.fileLog().info('stop setLoundnessValue...')
Exemplo n.º 30
0
def htzq():
    activity_name = 'com.lphtsccft/com.lphtsccft.zhangle.startup.SplashScreenActivity'
    launch_app(activity_name)
    time.sleep(8)

    track_list = [(979, 1855), (950, 296)]
    for step in track_list:
        d.click(step[0], step[1])
        time.sleep(5)

    print('华泰签到完成')
Exemplo n.º 31
0
def liuliang():
    d(text=u'全部').click()
    time.sleep(4)
    d(text=u'领流量').click()
    time.sleep(5)
    #这个签到好像找不到
    #d(text=u'签到').click()
    d.click(271, 813)
    time.sleep(1)
    d.click(271, 813)
    time.sleep(5)
    print("get liu liang")
Exemplo n.º 32
0
def liuliang():
    d(text=u'全部').click()
    time.sleep(4)
    d(text=u'领流量').click()
    time.sleep(5)
    #这个签到好像找不到
    #d(text=u'签到').click()
    d.click(271, 813)
    time.sleep(1)
    d.click(271, 813)
    time.sleep(5)
    print "get liu liang"
Exemplo n.º 33
0
def gdyd_cuizi():
    d.screen.on()
    d.press.home()
    # 解锁,没有密码的情况下
    sx = 560
    sy = 1700
    ex = 560
    ey = 900
    # d.swipe(sx,sy,ex,ey,steps=2)

    # d(scrollable=True).fling.horiz.forward()
    home_swipe_sx = 950
    home_swipe_sy = 1350
    home_swipe_ex = 450
    home_swipe_ey = 1350
    while not d(text=u"广东移动").exists:
        d.swipe(home_swipe_sx,
                home_swipe_sy,
                home_swipe_ex,
                home_swipe_ey,
                steps=2)
        time.sleep(3)
    d(text=u'广东移动').click()
    if d(text=u'版本更新').wait.exists(timeout=12 * 1000):
        print("Dismiss update")
        d(text=u'取消').click()
    # 登录账号,刷新下即可
    s_x = 544
    s_y = 367
    e_x = 544
    e_y = 1438
    time.sleep(8)
    d.swipe(s_x, s_y, e_x, e_y, steps=4)

    while not d(text=u"签到赢话费").exists:
        d.swipe(home_swipe_sx,
                home_swipe_sy,
                home_swipe_ex,
                home_swipe_ey,
                steps=2)
        time.sleep(3)
    d(text=u'签到赢话费').click()
    time.sleep(10)
    yd_x = 540
    yd_y = 1100
    d.click(yd_x, yd_y)
    print("GDYD done")
    d.press.back()
    d(text=u'全部').click()
    time.sleep(8)
    d(text=u'零流量').click()
    time.sleep(8)
    d(text='签到')
Exemplo n.º 34
0
def main():
    #base_info()



    #base_info()

    #op_test()

    print("Go")
    #t=Device('0331416080186')
    print("Start")

    #print(t.info)



    #d.press.home()
    #d.swipe(200,500,700,500)

    #d.press.home()
    #click_test()

    #scroll_test()

    '''
    d.press.home()
    d.swipe(200,500,700,500)

    #d.press.home()
    click_test()
    '''
    #liuliang()
    #d(text=u'数码科技').click()
    #if d(text=u'腾讯体育').exists:
    #print("Existed")
    #d.dump("hierarchy.xml")
    #d.swipe(500,1570,500,400)
    delta_each = 400
    time.sleep(3)

    for dragtime in range(20):
        print('dragtime')
        for i in range(3):
            d.click(919, 420 + i * delta_each)
            print('click')
            time.sleep(8)
            #each_dianpu()
            each_dianpu()
            time.sleep(8)
        d.swipe(919, 420 + delta_each * 3, 919, 400)
        time.sleep(5)
Exemplo n.º 35
0
def now(wait_time):
    x = 943
    # y=
    y = 742
    while wait_time > 0:
        time.sleep(1)
        wait_time -= 1
    count = 100
    while count > 0:
        print "Clicking......."
        d.click(x, y)
        time.sleep(0.001)
        count -= 1
Exemplo n.º 36
0
def login():
    try:
        driver(text="登录").click()
        driver.click(0.5*Width, 0.42*Height)
        time.sleep(1)
        os.system("adb shell am broadcast -a ADB_INPUT_TEXT --es msg '你自己的密码'")
        time.sleep(1)
        driver(text="登录").click()
        time.sleep(2)
    except BaseException:
        print("已登录")
    else:
        print('正在登录')
Exemplo n.º 37
0
 def try_to_switch_normal_incognito():
     if d(resourceId=CHROME_OPTION_RESID).exists:
         options_info = d(resourceId=CHROME_OPTION_RESID).info
     else:
         options_info = d(resourceId=CHROME_EMPTY_OPTION_RESID).info
     control_info = d(resourceId=CHROME_CONTROL_CONTAINER_RESID).info
     options_bounds = Bounds(options_info)
     control_bounds = Bounds(control_info)
     switcher_x = (options_bounds.left + options_bounds.right) / 2
     switcher_y = (control_bounds.top + options_bounds.top) / 2
     # print switcher_x, switcher_y
     d.click(switcher_x, switcher_y)
     time.sleep(2)
Exemplo n.º 38
0
def fxsc():
    activity_name = 'com.phicomm.fxmall/com.phicomm.fxmall.view.MainActivity'
    launch_app(activity_name)
    time.sleep(15)
    me_X = 1002
    me_Y = 1865
    d.click(me_X, me_Y)
    time.sleep(8)

    qiandao_X = 400
    qiandao_Y = 300
    d.click(qiandao_X, qiandao_Y)
    time.sleep(8)
Exemplo n.º 39
0
def performEventsOnApp():
    max_iterations = 5
    i = 1
    print("Current Package")

    while (i <= max_iterations):
        d.dump("Output3.xml")
        doc = minidom.parse("Output3.xml")
        nodes = doc.getElementsByTagName("node")
        package = doc.getElementsByTagName("node")[0].getAttribute("package")
        length = nodes.length
        print(d(text="START").exists)
        num_events_iteration = 50
        for x in range(num_events_iteration):
            print(package)
            print(getCurrentPackageName())
            if (package != getCurrentPackageName()):
                d.press.back()
            node = nodes[random.randint(1, length - 1)]
            print(node.getAttribute("class"))
            axisCoordinates = node.getAttribute("bounds").split("]")
            xAxis = axisCoordinates[0].replace('[', '').split(",")
            xCoordinate = (int(xAxis[0]) + int(xAxis[1])) / 2
            yAxis = axisCoordinates[1].replace('[', '').split(",")
            yCoordinate = (int(yAxis[0]) + int(yAxis[1])) / 2
            #screenshot before event --ss1
            #d.click(xCoordinate, yCoordinate)
            randomEvent = loadRandomEvent()
            eventMessage = "No Event"
            #d.screenshot("BeforeEvent.png")
            if randomEvent == 'click':
                d.click(xCoordinate, yCoordinate)
                eventMessage = "Performed click at", str(xCoordinate), str(
                    yCoordinate)
            elif randomEvent == 'swipe':
                d.swipe(xAxis[0], xAxis[1], yAxis[0], yAxis[1])
                eventMessage = "Performed Swipe at", xAxis, yAxis
            elif randomEvent == 'press':
                d.press(xCoordinate, yCoordinate)
                eventMessage = "Performed press at", str(xCoordinate), str(
                    yCoordinate)
            elif randomEvent == 'freeze':
                d.freeze_rotation()
                eventMessage = "Performed freeze rotation"
            #d.screenshot("AfterEvent.png")
            compareImage(eventMessage)
        #screenshot after event -ss2
        #use some kind of image similarity algorithm: open cv(computer vision library) for
        #comparing these screenshots
        #identify threshold %
        i = i + 1
Exemplo n.º 40
0
def manual_shiyong():
    delta_each = 400
    time.sleep(3)

    for dragtime in range(20):
        print("dragtime")
        for i in range(3):
            d.click(919, 420 + i * delta_each)
            print('click')
            time.sleep(8)
            each_dianpu()
            time.sleep(8)
        d.swipe(919, 420 + delta_each * 3, 919, 400)
        time.sleep(5)
Exemplo n.º 41
0
def select_product(product_x, product_y):
    # #########################
    # You to change here to select which branch to try
    #here i select Tech
    #d.click(kind_x, kind_y)  #Problem here
    #time.sleep(5)
    ###select  product
    print product_x
    print product_y
    time.sleep(5)
    d.click(product_x, product_y)
    time.sleep(10)

    d.click(575, 1828)
    time.sleep(5)

    d.click(560, 820)
    time.sleep(8)

    d.click(560, 1855)
    time.sleep(8)
    ##finish for once

    d.press("back")
    time.sleep(1)
    d.press("back")
    time.sleep(1)
    d.press("back")
    print("Done")
Exemplo n.º 42
0
def wjjf():
    activity_name = 'com.hxwj.wjjf/.act.SplashActivity'
    launch_app(activity_name)
    time.sleep(15)

    me_x = 969
    me_y = 1854
    d.click(me_x, me_y)
    time.sleep(9)

    qiandao_x = 371
    qiandao_y = 414
    d.click(qiandao_x, qiandao_y)
    time.sleep(9)
Exemplo n.º 43
0
    def testOpenMail(self):
        """
        Summary:testOpenMail: test open mail.
        Steps:1.Launch email app
              2.Clear up all mailbox 
              3.Create a new mail with attachment(image)
              4.Check mail context
              5.Save as draft
              6.Open the draft mail
              7.Check mail context,subject and so on
              8.Delete all mail
              9.Exit mail app
        """
        #step1
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(description = 'Compose').wait.exists(), 'Email launch failed'

        #step2
        d(description = 'Show all folders').click.wait()
        d(text = 'Drafts').click.wait()
        while d(descriptionContains = 'Subject').wait.exists():
            d.click(30,170)
            d(description = 'Delete').click.wait(timeout = 1000)

        #step3
        commands.getoutput('adb shell am start -a android.intent.action.SEND -d mailto:' + RECEIVER_ADDRESS + ' --eu android.intent.extra.STREAM file:///mnt/sdcard/001/300K/Picture.jpg --es android.intent.extra.SUBJECT ' + SUBJECT + ' --es android.intent.extra.TEXT ' + CONTEXT + ' -n com.android.email/.activity.MessageCompose')
        assert d(text = 'Compose').wait.exists(), 'Email with attachment create failed'

        #step4
        d.press('back')
        d.press('back')

        #step5
        d(description = 'Show all folders').click.wait()
        d(text = 'Drafts').click.wait()

        #step6
        assert d(descriptionContains = 'Subject').wait.exists(), 'No Email in Drafts'

        #step7
        d(descriptionContains = 'Subject').click.wait()
        assert d(description = 'Send').wait.exists(), 'Email open failed'

        #step8
        d.press('back')
        d.press('back')
        d(descriptionContains = 'Subject').long_click().wait()
        assert d(description = 'Delete').wait.exists(), 'Email did not selected'
        d(description = 'Delete').click.wait()
        assert d(text = 'No messages').wait.exists, 'Email delete failed'
Exemplo n.º 44
0
def select_product(product_x, product_y):
    # #########################
    # You to change here to select which branch to try
    #here i select Tech
    #d.click(kind_x, kind_y)  #Problem here
    #time.sleep(5)
    ###select  product
    print product_x
    print product_y
    time.sleep(5)
    d.click(product_x, product_y)
    time.sleep(10)

    d.click(575, 1828)
    time.sleep(5)

    d.click(560, 820)
    time.sleep(8)

    d.click(560, 1855)
    time.sleep(8)
    ##finish for once

    d.press("back")
    time.sleep(1)
    d.press("back")
    time.sleep(1)
    d.press("back")
    print("Done")
Exemplo n.º 45
0
    def test_game(self):
        try:
            print("AutoTest, while in DeadByDaylight")
            i = 1000
            while i >= 0:
                print("AutoTest, click in DeadByDaylight, i = ", i)
                d.click(2066, 942)
                time.sleep(3.2)
                d.click(1238, 667)
                time.sleep(3.2)
                i = i - 1

        except Exception as e:
            print("AutoTest, test_game encounter exception: %s" % e)
Exemplo n.º 46
0
  def SMSviaNotification(self,message):

#device log info ("open notification")
    device.open.notification() 

#device log info ("select number to send message")
    device(text="Missed call").swipe.down()
    device(text="Message").click()

#device log info ("Type Message")
    device(text="Type message").set_text(message)
    mb=raw_input

#device log info ("send message")
    device.click(544,1176)
    device.press.home()
Exemplo n.º 47
0
  def deleteSMS(self,name):
    device.screen.on()
    device.press.home()

#device log info ("select message field")
    device(text ="Messaging").click()

#device log info ("select message for delete")
    device(scrollable=True).scroll.to(text=name)
    device(text=name).long_click()
    device.click(552,58)
    #device.orientation="l"

#device log info ("Delete the message")
#(In the place of "Cancel" use "Delete")
    device(text="Cancel").click()
    device.press.home()
Exemplo n.º 48
0
    def testOpenPicture(self):
        """
        Summary:testCapturePictureAndDelete: Take a picture, then view and delete the picture.
        Steps:1. Open Camera app
              2. Touch thumbnail to view the picture
              3. Exit Camera app
        """
        #step1
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(description = 'Shutter button').wait.exists(), 'Camera launch failed'

        #Step2
        d.swipe(startX, startY, endX, endY, steps = 10)
        time.sleep(2)
        d.click(274,482)
        d.press('menu')
        assert d(text = 'Delete').wait.exists()
Exemplo n.º 49
0
def apply_one(kind_x, kind_y):
    # apply for 4 production
    dis_x = 540
    dis_y= 784.5
    base_x = 270
    base_y = 743.25
    d.click(kind_x, kind_y)
    time.sleep(5)
    select_product(base_x, base_y)
    select_product(base_x + dis_x, base_y)
    select_product(base_x, base_y + dis_y)
    select_product(base_x + dis_x, base_y + dis_y)
    #add drag down action
    d.drag(270,1527.75,270,743.25,steps=200)
    select_product(base_x, base_y)
    select_product(base_x + dis_x, base_y)
    select_product(base_x, base_y + dis_y)
    select_product(base_x + dis_x, base_y + dis_y)
Exemplo n.º 50
0
    def testPlayMusicFile(self):
        """
        Summary:testPlayMusicFile: Play the music one by one till 50 cycles.
        Steps:1. Open Music app in background
              2. Touch Next button
              3. Touch HOME to run music on background
              4. Repeat Step 1,2,3 for 50 cycles
        """ 
        #step1
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(text = 'Listen Now').wait.exists(), 'Music player launch failed'
        assert d(description = 'Pause').wait.exists(), 'No music is palying' 

        d.click(130,900)

        #step2
        assert d(description = 'Next').wait.exists()
        d(description = 'Next').click.wait()
Exemplo n.º 51
0
  def SMSfromMessaging(self,number,message):
    device.screen.on()
    device.press.home()

#device log info ("select message field")
    device(text ="Messaging").click()
    device(className="android.widget.ImageButton",index="0").click()
    device.click(576,1136)

#device log info ("select the number")
    device(text="To").set_text(number)
    nb=raw_input

#device log info ("write the message")
    device(text="Type message").set_text(message)
    mb=raw_input
    device.click(544,595)
    device.press.home()
Exemplo n.º 52
0
    def testMailSendwithAttachment(self):

        """
        Summary:testSendMailWithAttach: send mail with attachment.
        Steps:1.Launch email app
              2.Clear up all mailbox 
              3.Create a new mail with attachment(image)
              4.Send mail
              5.Check send succesfully
              6.Delete the sended mail
              7.Exit email app
        """
        #step1
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(description = 'Compose').wait.exists(), 'Email launch failed'

        #step2
        d(description = 'Show all folders').click.wait()
        d(text = 'Sent').click.wait()
        while d(descriptionContains = 'Subject').wait.exists():
            d.click(30,170)
            d(description = 'Delete').click.wait(timeout = 1000)

        #step3
        commands.getoutput('adb shell am start -a android.intent.action.SEND -d mailto:' + RECEIVER_ADDRESS + ' --eu android.intent.extra.STREAM file:///mnt/sdcard/001/300K/Picture.jpg --es android.intent.extra.SUBJECT ' + SUBJECT + ' --es android.intent.extra.TEXT ' + CONTEXT + ' -n com.android.email/.activity.MessageCompose')
        assert d(text = 'Compose').wait.exists(), 'Email with attachment create failed'

        #step4
        d(description = 'Send').click.wait(timeout = 3000)

        #step5
        d(description = 'Show all folders').click.wait()
        d(text = 'Sent').click.wait()
        assert d(descriptionContains = 'Subject').wait.exists(timeout = 90000), 'Email sent failed'

        #step6
        d(descriptionContains = 'Subject').long_click().wait()
        assert d(description = 'Delete').wait.exists(), 'Email did not selected'
        d(description = 'Delete').click.wait()
        assert d(text = 'No messages').wait.exists, 'Email delete failed'
Exemplo n.º 53
0
    def testPlayVideo(self):
        """
        Summary:testRecordVideoAndDelete: Record a video, then play and delete the video.
        Steps:1. Open Camera app
              2. Record a video
              3. Touch thumbnail to view the video
              4. Tocuh screen center to play the video
              5. Exit Camera app
        """
        #step1,2
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(description = 'Shutter button').wait.exists(), 'Camera launch failed'
        d(description = 'Camera, video, or panorama selector').click.wait()
        d(description = 'Switch to video').click.wait()
        assert d(description = 'Shutter button').wait.exists(), 'Video Camera launch failed'

        #step3
        d.swipe(startX, startY, endX, endY, steps = 10)
        time.sleep(2)
        d.click(274,482)
        d.press('menu')
        assert d(text = 'Delete').wait.exists()

        #step4
        d.press('back')
        d.click(274,482)
        time.sleep(10)
        d.click(274,482)
        # assert playing progress bar exist
        assert d(index = 2, className = 'android.view.View').wait.exists(), 'Video play failed'
Exemplo n.º 54
0
def runtest(serialno, loop):
    if serialno:
        from uiautomator import Device
        d = Device(serialno)
    else:
        from uiautomator import device as d

    print "总共 %d 次循环" %loop

    for i in range(1, loop+1):
        print "第 %d 次循环" %i
        d.screen.on()
        d.press.home()
        d(description="Apps").click()
        d(text="3DMark").click()
        time.sleep(2)
        
        d.click(600,460)
        d.press.home()
        i += 1

    print "***** test end ********"
Exemplo n.º 55
0
    def testOpenMusicPlayer(self):
        """
        Summary:testOpenMusicPlayer: Open music player.
        Steps: 1. Open music app
               2. Touch All tab
               3. Play a music file
               4. Back to home screen, run music on background
        """
        #step1
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(text = 'Listen Now').wait.exists(), 'Music player launch failed'

        #step2
        d.swipe(0,400,400,400,steps=10)
        assert d(text = 'Playlists').wait.exists(), 'Option bar launch failed'

        d(text = 'Playlists').click.wait()
        assert d(text = 'Last added').wait.exists(), 'Playlists launch failed'

        #step3
        d(text = 'Last added').click.wait()
        d.click(120,400)
        assert d(description = 'Pause').wait.exists(), 'Music play failed'
Exemplo n.º 56
0
    def testCloseMusicPlayer(self):
        """
        Summary:testCloseMusicPlayer: Close music player.
        Steps:1. Open Music app
              2. Touch Next button
              3. Touch Pause button
              4. Exit Music app
        """
        #step1
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(text = 'Listen Now').wait.exists(), 'Music player launch failed'
        assert d(description = 'Pause').wait.exists(), 'No music is palying' 

        d.click(130,900)

        #step2
        assert d(description = 'Next').wait.exists()
        d(description = 'Next').click.wait()

        #step3
        d(description = 'Pause').click.wait()
        assert d(description = 'Play').wait.exists(), 'Music pause failed'
        print('case4 finish')
Exemplo n.º 57
0
def launch_tb():  # cling position method
    d.screen.on()
    time.sleep(1)
    os.system("adb shell am force-stop com.taobao.taobao")
    time.sleep(1)
    d.press("home")
    d.swipe(120, 1110, 900, 1110)

    d(text="shopping").click()
    time.sleep(1)
    # launch TB
    d.click(225, 1300)
    time.sleep(8)

    #click Trial
    d.click(950, 900)
    time.sleep(8)
    #click Te She Dao Gou
    d.click(300, 300)
    time.sleep(8)
    #click Free to try
    d.click(930, 1105)
    time.sleep(10)
Exemplo n.º 58
0
def each_dianpu():
    mid_x = 1080 / 2
    #d.click(919,566)
    time.sleep(3)

    d.click(mid_x, 1868)
    #点击免费试用
    time.sleep(3)
    d.click(mid_x, 1311)
    time.sleep(2)
    d.click(mid_x, 1555)
    time.sleep(3)
    d.press.back()
    time.sleep(5)
    d.press.back()
    time.sleep(5)
Exemplo n.º 59
0
def launch_tb_activity():  # using activity method
    d.screen.on()
    time.sleep(1)
    os.system("adb shell am force-stop com.taobao.taobao")
    time.sleep(3)
    os.system("adb shell am start -n com.taobao.taobao/com.taobao.tao.welcome.Welcome")
    time.sleep(10)
    # click Trial
    d.click(950, 900)
    time.sleep(8)
    #click Te She Dao Gou
    d.click(300, 300)
    time.sleep(8)
    #click Free to try
    d.click(930, 1105)
    #d.click()
    time.sleep(10)
    print ("finish launch")
Exemplo n.º 60
0
def runtest(serialno, loop):
    if serialno:
        from uiautomator import Device
        d = Device(serialno)
    else:
        from uiautomator import device as d

    print "总共 %d 次循环" %loop

    for i in range(1, loop+1):
        print "第 %d 次循环" %i
        d.screen.on()
        d.press.home()
        removeRecentList(d, "UHD Player")
        d(description="Apps").click()
        d(text="UHD Player").click()
        time.sleep(0.5)
        d.click(300, 520) #d.click(380,530)
        time.sleep(0.5)
        d.click(190, 210) #d.click(260,160)
        time.sleep(1)
        d.click(310, 520) #d.click(380,500)
        time.sleep(1)

        goToCtlButton(d)
        for i in range(1, 10):
            print "第 %d 次循环 in button" %i
            index = random.randint(0, 2)
            print "index: %d" %index
            d(className="android.widget.ImageButton")[index].click()
            time.sleep(2)

        d(className="android.widget.SeekBar").click()
        d.press.back()
        d.press.home()
        i += 1
    
    print "***** test end ********"