예제 #1
0
파일: camera.py 프로젝트: zuodapeng/falcon
    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'
예제 #2
0
def loop_sdn():
	if d(text="Service Dialing Numbers").wait.exists():
		d(text="Service Dialing Numbers").click()
		d.press("back")
	else:
		c.common.log("text=Service Dialing Numbers未找到,保存截图")
		c.common.save_fail_img()
 def open():
     d(text="Gmail").click()
     sleep(1)
     ##d(text="GOT IT").click()
     ##sleep(3)
     ##d(text="TAKE ME TO GMAIL").click()
     ##d(text="Next").click()
     ##d(text="OK").click()
     d(resourceId="com.google.android.gm:id/compose_button").click()
     sleep(1)
     ##d(text="Got it").click
     # get text info
     # d(className="android.widget.MultiAutoCompleteTextView").text
     # edit text
     d(className="android.widget.MultiAutoCompleteTextView").set_text(
         "*****@*****.**")
     d.click(463.0, 878.0)
     d.press(0x07)
     d.press(0x07)
     sleep(1)
     d(text="Subject").set_text("autotest1")
     sleep(1)
     d.click(463.0, 878.0)
     d.click(890.0, 140.0)
     sleep(2)
예제 #4
0
def watch_video():
    time.sleep(2)
    # 切换到电视台页面
    driver(resourceId="cn.xuexi.android:id/home_bottom_tab_button_contact"
           ).click()
    driver(text="联播频道").click()
    autoJob(tv="观看视频", sleep_time=20, click=False)
    driver(text="联播频道").click()

    news = None
    for v in driver(className='android.widget.TextView'):
        if "《新闻联播》" in v.text:
            news = v.text
            break
    driver(text=news).click()

    # 100天后删除最早一天的记录
    text_list = np.array(all_of_list)

    if len(text_list) > 2500:
        text_list = text_list[25:]
    # 存储已看视频和文章
    np.save('db.npy', text_list)

    print("正在观看新闻联播...")
    time.sleep(1050 + random.randint(0, 20))
    driver.press('back')
    print("观看视频结束.")
예제 #5
0
def test():
    launch_tb_activity()
    Facial_x = 338
    Facial_y = 270
    # apply_one(Facial_x,Facial_y)

    Cloth_x = 551
    Cloth_y = 270
    #apply_one(Cloth_x,Cloth_y)

    Tech_x = 820
    Tech_y = 270
    #apply_one(Tech_x,Tech_y)

    time.sleep(5)
    d.swipe(900, 270, 10, 270)
    time.sleep(8)

    Eletronic_x = 108
    Eletronic_y = 270
    apply_one(Eletronic_x, Eletronic_y)

    House_x = 270
    House_y = 270
    apply_one(House_x, House_y)

    time.sleep(2)
    d.press("home")
    print("Done")
예제 #6
0
파일: mail.py 프로젝트: zuodapeng/falcon
 def tearDown(self):
     d.press('back')
     d.press('back')
     d.press('back')
     d.press('back')
     d.press('home')
     super(MailTest, self).tearDown()
예제 #7
0
def loop_menu():
	if d(text="Off").wait.exists():
		d(text="Off").click()
	time.sleep(2)
	if d(text="Mode",enabled=True).wait.exists():
		d(text="Mode",enabled=True).click()
		oplist=["High accuracy","Battery saving","Device only"]
		#if d(text="Device only").right(resourceId="android:id/checkbox",checked=True).wait.exists():
		if d(text="Device only").wait.exists():
			d(text="Device only").click()
			time.sleep(2)
			if d(text="High accuracy").wait.exists():
				d(text="High accuracy").click()
				time.sleep(2)
				if d(text="Battery saving").wait.exists():
					d(text="Battery saving").click()
					time.sleep(2)
					d.press("back")
				else:
					c.common.log("控件未找到,保存截图")
					c.common.save_fail_img()
			else:
				c.common.log("控件未找到,保存截图")
				c.common.save_fail_img()	
		else:
			c.common.log("控件未找到,保存截图")
			c.common.save_fail_img()
	else:
		c.common.log("控件未找到,保存截图")
		c.common.save_fail_img()
	c.common.log("遍历完成")	
예제 #8
0
    def _input_user_name(self):
        time.sleep(2)
        #随机生成用户名和密码
        user_name = utils.get_one_letters() + utils.random_str(11)
        print("生成用户名: " + user_name)
        #填入用户名
        self._input_text(user_name)
        #点击下一步
        # d.screen.on()
        d(text="下一步").click()
        time.sleep(2)
        #检查用户名是否已被占用
        # d.screen.on()
        um_is_has = d(text="该邮箱地址已被注册")
        # print(um_is_has)
        # 邮箱已被注册
        if um_is_has.exists:
            #点击确定
            d(text="确定").click()
            #清空用户名
            for num in range(0, 20):
                d.press("delete")

            #重新执行注册逻辑
            self._input_user_name()

        else:
            #邮箱可以被注册
            self.user_name = user_name
            #点击下一步
            d(text="下一步").click()
예제 #9
0
파일: camera.py 프로젝트: zuodapeng/falcon
    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'
예제 #10
0
def watch_video():
    time.sleep(5)
    #切换到电视台页面
    driver(resourceId="cn.xuexi.android:id/home_bottom_tab_button_contact").click()
    time.sleep(5)
    driver(text="联播频道").click()
    time.sleep(5)
    autoJob(tv="观看视频",sleep_time=20,sum=6,click=False)
    driver(text="联播频道").click()
    time.sleep(5)
    
    news=None
    for v in driver(className='android.widget.TextView'):
        if "《新闻联播》" in v.text:
            news=v.text
            break
    driver(text=news).click()

    
    text_list=None
    #删除最早一天的记录
    if len(all_of_list)>350:
        text_list = np.array (all_of_list[25:])
    else:
        text_list = np.array (all_of_list)
    #存储已看视频和文章
    np.save ('jilu.npy',text_list)
    
    print("正在观看新闻联播...")
    time.sleep(1050)#1050
    driver.press('back')
    print("观看视频结束.")
예제 #11
0
파일: message.py 프로젝트: zuodapeng/falcon
    def testSendSMS(self):
        """
        Summary:testSendSMS: Send a SMS.
        #Init condition:Clear up all messagebox
        Steps:1. Open Messages app
              2. Touch Compose button
              3. Input deliver number and content
              4. Touch Send button
              5. Delete all messages
              6. Exit Messages app
        """
        #step1
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(text = 'Messaging').wait.exists(), 'Message launch failed'

        self._clearMessage()

        #step2,3
        commands.getoutput('adb shell am start -a android.intent.action.SEND  --es address ' + MESSAGE_RECEIVER_NUMBER + ' --es sms_body ' + SEND_MESSAGE_CONTENT + ' -n com.android.mms/.ui.ComposeMessageActivity')
        time.sleep(2)

        #step4
        d(description = 'Send').click.wait()
        assert d(textContains = ':', className = 'android.widget.TextView').wait.exists(timeout = 35000), 'Message send failed'

        #step5
        d.press('back')
        self._clearMessage()
예제 #12
0
파일: camera.py 프로젝트: zuodapeng/falcon
    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'
예제 #13
0
def loop_menu():
    if d(text="Off").wait.exists():
        d(text="Off").click()
    time.sleep(2)
    if d(text="Mode", enabled=True).wait.exists():
        d(text="Mode", enabled=True).click()
        oplist = ["High accuracy", "Battery saving", "Device only"]
        #if d(text="Device only").right(resourceId="android:id/checkbox",checked=True).wait.exists():
        if d(text="Device only").wait.exists():
            d(text="Device only").click()
            time.sleep(2)
            if d(text="High accuracy").wait.exists():
                d(text="High accuracy").click()
                time.sleep(2)
                if d(text="Battery saving").wait.exists():
                    d(text="Battery saving").click()
                    time.sleep(2)
                    d.press("back")
                else:
                    c.common.log("控件未找到,保存截图")
                    c.common.save_fail_img()
            else:
                c.common.log("控件未找到,保存截图")
                c.common.save_fail_img()
        else:
            c.common.log("控件未找到,保存截图")
            c.common.save_fail_img()
    else:
        c.common.log("控件未找到,保存截图")
        c.common.save_fail_img()
    c.common.log("遍历完成")
예제 #14
0
def test():
    launch_tb_activity()
    Facial_x = 338
    Facial_y = 270
    # apply_one(Facial_x,Facial_y)

    Cloth_x = 551
    Cloth_y = 270
    #apply_one(Cloth_x,Cloth_y)

    Tech_x = 820
    Tech_y = 270
    #apply_one(Tech_x,Tech_y)

    time.sleep(5)
    d.swipe(900, 270, 10, 270)
    time.sleep(8)

    Eletronic_x = 108
    Eletronic_y = 270
    apply_one(Eletronic_x, Eletronic_y)

    House_x = 270
    House_y = 270
    apply_one(House_x, House_y)

    time.sleep(2)
    d.press("home")
    print("Done")
예제 #15
0
파일: message.py 프로젝트: zuodapeng/falcon
    def testSendMMSWithVideo(self):
        """
        Summary:testSendMMSWithVideo: Send a mms with video attachment.
        #Init condition:Clear up all messagebox
        Steps:1. Open Messages app
              2. Touch Compose button
              3. Input deliver number and content
              4. Touch Attach button
              5. Select Gallery
              6. Enter 001 folder, select a video
              7. Touch Send button
              8. Delete all messages
              9. Exit Messages app
        """
        #step1
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(text = 'Messaging').wait.exists(), 'Message launch failed'

        self._clearMessage()

        #step2,3,4,5,6
        commands.getoutput('adb shell am start -a android.intent.action.SEND -t video/* --es address ' + MESSAGE_RECEIVER_NUMBER + ' --es sms_body ' + SEND_MESSAGE_CONTENT + ' --eu android.intent.extra.STREAM file:///mnt/sdcard/001/300K/Video.3gp -n com.android.mms/.ui.ComposeMessageActivity')
        assert d(text = 'View').wait.exists(), 'message create failed'

        #step7
        d(description = 'Send MMS').click.wait()
        assert d(textContains = ':', className = 'android.widget.TextView').wait.exists(timeout = 60000), 'Message send failed'

        #step8
        d.press('back')
        self._clearMessage()
예제 #16
0
파일: message.py 프로젝트: zuodapeng/falcon
    def _clearMessage(self):

        if d(text = 'No conversations.').wait.exists():
            assert True
        else:
            d.press('menu')
            d(text = 'Delete all threads').click.wait()
            d(text = 'Delete').click.wait()
            assert d(text = 'No conversations.').wait.exists(), 'message delete failed'
예제 #17
0
 def go_to_url(url_address, timeout=None):
     refresh_in_layout = d(resourceId=CHROME_REFRESH_BUTTON_RESID).exists
     d(resourceId=CHROME_ADDRESS_BAR_RESID).set_text(url_address)
     d.press("enter")
     d.wait.idle()
     if refresh_in_layout:
         d(resourceId=CHROME_REFRESH_BUTTON_RESID).wait.exists(
             timeout=60000)
     if timeout is not None:
         time.sleep(timeout)
예제 #18
0
파일: browser.py 프로젝트: zuodapeng/falcon
 def testBrowserLaunchAndClose(self):
     """
     Summary:testBrowserLaunchHomePage: Open and close Browser.
     Init Condition:
           1.Clear browser cache.
     Steps:1.Launch Browser and check launch successfully
     """
     #step1
     commands.getoutput('adb shell am start ' + self.runComponent)
     d.press('menu')
 	assert d(text = 'Bookmarks').wait.exists(), 'Browser launch failed'
예제 #19
0
def loop_voletsetting():
	if d(text="VoLTE setting").wait.exists():
		d(text="VoLTE setting").click()
		if d(text="VoLTE").wait.exists():
			d(text="VoLTE").click()
			d.press("back")
		else:
			c.common.log("text=VoLTE未找到,保存截图")
			c.common.save_fail_img()
	else:
		c.common.log("text=VoLTE setting未找到,保存截图")
		c.common.save_fail_img()		
예제 #20
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
예제 #21
0
파일: mobile_test2.py 프로젝트: tishyk/GoIT
def run_test():
    logging.info("--- Start Test ---")     
    sp.Popen('adb -s %s logcat -c' % device_id, shell=True)
    os.popen('adb -s %s install %s'%(device_id,apk_name))
    os.popen('adb -s %s shell am start -n %s/%s'%(device_id,package,activity))
    xml = d.dump()
    d.press(5)
    d.press.back()
    d(scrollable=True).fling()
    d(scrollable=True).fling.vert.backward()
    d(className='android.widget.RelativeLayout')[9].child(
        className='android.widget.CheckBox').click()
    d(text='viber').sibling(className='android.widget.CheckBox').click()
    logging.info("--- Test Finished! ---")
예제 #22
0
def test(apk, startActivity, packageName):
    print('!!!')
    d.press('home')
    subprocess.Popen(['adb', 'install', os.path.join(rootDir, apk)])
    subprocess.Popen([
        'adb', 'shell', 'am', 'start', '-n', packageName + '/' + startActivity
    ])
    time.sleep(10)

    #遍历5min
    traverse(1, os.path.join('/Users/xikaioliver/Desktop/Result', packageName))

    time.sleep(1000)
    subprocess.Popen(['adb', 'shell', 'am', 'force-stop', packageName])
    d.press('home')
예제 #23
0
def start_read():
    print("寻找新文章")
    click_new()
    # 开始阅读
    print("开始自动阅读阅读")
    while True:
        auto_read()
        if d(text='没有更多了').exists:
            d.press("back")
            # 滚动一次,否则一次阅读到同一文章
            d.swipe(500, 1000, 500, 100)
            break
        else:
            auto_read()
    # 重新阅读
    start_read()
예제 #24
0
파일: camera.py 프로젝트: zuodapeng/falcon
    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()
예제 #25
0
def loop_voicemail():
	options=["Voicemail","Fixed Dialing Numbers","Service Dialing Numbers","Call duration",
				"GSM call settings","VoLTE setting","Dual mic noise reduction"]
	if d(text="Voicemail").wait.exists():
		d(text="Voicemail").click()
		options=["Service","Setup","Sound","Vibrate"]
		for i in range(4):
			if d(text=options[i]).wait.exists():
				d(text=options[i]).click()
				time.sleep(1)
				d.press("back")
				time.sleep(1)
			else:
				c.common.log("text="+options[i]+"未找到,保存截图")
				c.common.save_fail_img()
	else:
		c.common.log("text=Voicemail未找到,保存截图")
		c.common.save_fail_img()
예제 #26
0
 def gamePlay(self, cycle=1):
     for i in range(cycle):
         print "%s, " % (i + 1),
         os.popen(
             'adb shell am start -n com.imangi.templerun2.bd/com.templerun2.SuperIdsSingleSplashActivity'
         )
         time.sleep(5)
         d.click(D_C_X, 1800)  # Tap to start
         time.sleep(2)
         for i in range(10):
             d.swipe(D_C_X, D_HEIGHT - 1, D_C_X, 0, 5)
         d.press('home')
         d.press('recent')
         while d(resourceId='com.android.systemui:id/dismiss_task'
                 ).wait.exists(timeout=2000):
             d(resourceId='com.android.systemui:id/dismiss_task'
               ).click.wait()
     print "\n"
예제 #27
0
파일: Message.py 프로젝트: zuodapeng/falcon
 def testSendSMS(self):
     '''
     1. Launch Message
     2. New a message
     3. Input receiver and content
     4. Send the sms
     5. Verify send successfully
     '''
     #step1
     os.system('adb shell am start ' + self.runComponent)
 	#d(text='Messaging').click.wait()
 	assert d(description = 'New message').wait.exists(), 'Message launch failed'
     #step2
 	d(description = 'New message').click.wait()
     #step3
     d(text = "To").set_text(SMS_RECEIVER)
     d(text = "Type message").set_text(SMS_CONTENT)
     d(description = "Send").click.wait()
     d.press('back')
     assert d(textContains = ':').wait.exists(timeout = 35000), 'SMS send failed'
예제 #28
0
def loop_callduration():
	if d(text="Call duration").wait.exists():
		d(text="Call duration").click()
		for i in range(5):
			if i!=4:
				if d(index=i,className="android.widget.TwoLineListItem").wait.exists():
					#swipe等于长按
					d(index=i,className="android.widget.TwoLineListItem").swipe.right(steps=100)
					
					if d(text="Cancel").wait.exists():
						d(text="Cancel").click()
					else:
						c.common.log("text=Cancel未找到,保存截图")
						c.common.save_fail_img()
				else:
					c.common.log("index="+i+"未找到,保存截图")
					c.common.save_fail_img()
		d.press("back")
	else:
		c.common.log("text=Call duration未找到,保存截图")
		c.common.save_fail_img()
예제 #29
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")
예제 #30
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")
예제 #31
0
파일: message.py 프로젝트: zuodapeng/falcon
    def testOpenSms(self):
        """
        Summary:testOpenSMS:open a sms
        #Init condition:Clear up all messagebox
        Precondition:
              1.Prepare a received sms.
        
        Steps:1.Launch Messages app
              2.Open a sms
              3.Delete message
              4.Exit message app
              
        """
        #step1
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(text = 'Messaging').wait.exists(), 'Message launch failed'

        self._clearMessage()

        commands.getoutput('adb shell am start -a android.intent.action.SEND  --es address ' + MESSAGE_RECEIVER_NUMBER + ' --es sms_body ' + SEND_MESSAGE_CONTENT + ' -n com.android.mms/.ui.ComposeMessageActivity')
        time.sleep(2)
        d.press('back')

        #step2
        d(textContains = 'test').click.wait()
        assert d(description = 'Send').wait.exists(), 'SMS open failed'

        #step3
        d.press('back')
        d.press('back')
        self._clearMessage()
예제 #32
0
파일: message.py 프로젝트: zuodapeng/falcon
    def testOpenMmsWithImage(self):
        """
        Summary:testOpenMmsWithVideo:open a mms with video
        #Init condition:Clear up all messagebox
        Precondition:
              1.There is a 600kb audio file in sdcard

        Steps:1.Launch message app
              2.Open a mms with audio 
              3.Delete message
              4.Exit message app      
        """
        #step1
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(text = 'Messaging').wait.exists(), 'Message launch failed'

        self._clearMessage()

        commands.getoutput('adb shell am start -a android.intent.action.SEND -t image/* --es address ' + MESSAGE_RECEIVER_NUMBER + ' --es sms_body ' + SEND_MESSAGE_CONTENT + ' --eu android.intent.extra.STREAM file:///mnt/sdcard/001/300K/Picture.jpg -n com.android.mms/.ui.ComposeMessageActivity')
        time.sleep(2)
        d.press('back')

        #step2
        d(textContains = 'subject').click.wait()
        assert d(description = 'Send MMS').wait.exists(), 'MMS open failed'

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

        self._clearMessage()
예제 #33
0
파일: mail.py 프로젝트: zuodapeng/falcon
    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'
예제 #34
0
 def firstLaunch(self):
     # for escape the devices' beginner's guide when first power up
     # need long-pressing back key before running
     # if d(text = u'确定').wait.exists(timeout = 2000):
     d(text=u'确定').click.wait()
     # To set up never sleep
     d(resourceId='com.android.launcher:id/hotseat').click.wait()
     if d(resourceId='com.android.launcher:id/cling_dismiss').wait.exists(
             timeout=2000):
         d(resourceId='com.android.launcher:id/cling_dismiss').click.wait()
     d(text=u'设置').click.wait()
     while d(text=u'关于手机').wait.gone(timeout=2000):
         # Slide up
         d.swipe(700, 2550, 700, 1)
     d(text=u'关于手机').click.wait()
     for i in range(10):
         d(text=u'版本号').click()
     d.press('back')
     d(text=u'开发者选项').click.wait()
     d(text=u'不锁定屏幕').right(
         resourceId='android:id/switchWidget').click.wait()
     self.backToDesktop()
예제 #35
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)
예제 #36
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)
예제 #37
0
 def firstBoot(self):
     d(text='OK').click.wait()
     d(resourceId='com.android.launcher:id/hotseat').click.wait()
     if d(resourceId='com.android.launcher:id/cling_dismiss').wait.exists(
             timeout=2000):
         d(resourceId='com.android.launcher:id/cling_dismiss').click.wait()
     self.launchSettings()
     t = 0
     while d(text='About phone').wait.gone(timeout=2000):
         d.swipe(D_C_X, D_HEIGHT - 1, D_C_X, 0)
         time.sleep(1)
         t = t + 1
         if t > 10:
             print "No such an option..."
             break
     d(text='About phone').click.wait()
     for i in range(10):
         d(text='Build number').click()
     d.press('back')
     d(text='Developer options').click.wait()
     d(text='Stay awake').right(
         resourceId='android:id/switchWidget').click.wait()
     self.backToDesktop()
예제 #38
0
def watch_video():
    time.sleep(2)
    #切换到电视台页面
    driver(resourceId="cn.xuexi.android:id/home_bottom_tab_button_contact"
           ).click()
    driver(text="联播频道").click()
    autoJob("观看视频", 15)
    driver(text="联播频道").click()

    news = None
    for v in driver(className='android.widget.TextView'):
        if "新闻联播" in v.text:
            news = v.text
            break
    driver(text=news).click()

    #存储已看视频和文章
    text_list = np.array(all_of_list)
    np.save('db.npy', text_list)

    print("正在观看新闻联播...")
    time.sleep(1100)
    driver.press('back')
    print("观看视频结束.")
예제 #39
0
def press_recent():
	d.press("recent")
	if d(description="Clear all").wait.exists(timeout=2000):
		d(description="Clear all").click.wait()
	if d(textContains="Your recent").wait.exists(timeout=2000):
		d.press("back")
	else:
		save_fail_img()
		d.press("home")
	return True
예제 #40
0
def press_recent():
    d.press("recent")
    if d(description="Clear all").wait.exists(timeout=2000):
        d(description="Clear all").click.wait()
    if d(textContains="Your recent").wait.exists(timeout=2000):
        d.press("back")
    else:
        save_fail_img()
        d.press("home")
    return True
예제 #41
0
 def testLaunchAndCloseIreaderByBackKey(self):
     '''
     Summary: Test launch and close ireader by back key
     Steps:  1. Launch ireader 
             2. Chech enter ireader successfully
             3. Exit ireader by back key
             4. Repeat steps 1-3 500 times
     '''
     for i in range(1,2):
         #Step 1
         d(text='掌阅iReader',className='android.widget.TextView').click.wait()
         time.sleep(3)
         #Step 2
         assert d(text='书城',className='android.widget.TextView')
         #Step 3
         d.press('back')
         d.press('back') 
         d.press('back')   
예제 #42
0
def alipay():
    activity_name = 'com.eg.android.AlipayGphone/.AlipayLogin'
    launch_app(activity_name)
    time.sleep(10)

    #领取搜索红包
    track_list0 = [(226, 163), (188, 582), (455, 577)]

    for step in track_list0:
        d.click(step[0], step[1])
        print('click')
        time.sleep(5)

    # 点击3次返回到主页
    d.press('back')
    time.sleep(3)
    d.press('back')
    time.sleep(3)
    d.press('back')
    time.sleep(3)

    track_list1 = [
        (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_list1:
        d.click(step[0], step[1])
        print('click')
        time.sleep(5)
예제 #43
0
 def tearDown(self):
     d.press('back')
     d.press('back')
     d.press('back')
     d.press('home')
     super(SoundrecordTest, self).tearDown()
예제 #44
0
def change():
    d.press().menu()# 点击菜单切换键
    time.sleep(1)
    d.click(500.1000)#点击切换到另一个页面
    time.sleep(2)
예제 #45
0
from uiautomator import device as d

d.press.home()
d(description="Apps list").click()
d(text=u"Chromium").click(timeout=10)
d(description=u"New tab").click(timeout=10)
d(resourceId="org.chromium.chrome:id/search_box_text").click()
d(text=u"Search or type web address", className="android.widget.EditText").set_text("www.msn.com")
d.press("enter")
예제 #46
0
파일: Message.py 프로젝트: zuodapeng/falcon
 def setUp(self):
     super(MessageTest, self).setUp()
     self.runComponent = PACKAGE_NAME + '/' + ACTIVITY_NAME
     d.wakeup()
     d.press('home')
예제 #47
0
def watchVideo():
    driver(text="百灵").click()
    time.sleep(5)
    driver.click(0.465 * Width, 0.285 * Height)
    time.sleep(4000)
    driver.press("back")
예제 #48
0
파일: Message.py 프로젝트: zuodapeng/falcon
 def tearDown(self):
     super(MessageTest, self).tearDown()
     d.press('back')
     d.press('back')
     d.press('home')
예제 #49
0
파일: browser.py 프로젝트: zuodapeng/falcon
 def tearDown(self):
     d.press('back')
     d.press('back')
     d.press('home')
     super(BrowserTest, self).tearDown()
예제 #50
0
from uiautomator import device as dev
import xml.dom.minidom
import time
import os

print dev.info
dev.screen.on()
os.system('rm -r -f data')
os.system('mkdir data')


CMD_MAP = {
    'CLICK': lambda dev, arg: dev(**arg).click(),
    'TOUCH': lambda dev, arg: dev.click(**arg),
    'DRAG': lambda dev, arg: dev.drag(**arg),
    'PRESS': lambda dev, arg: dev.press(**arg),
    'WAIT': lambda dev, arg: dev.wait.update() # wait until window update event occurs
    }

import Queue
import subprocess
import threading
import re # reg exp

class AsynchronousFileReader(threading.Thread):
    '''
    Helper class to implement asynchronous reading of a file
    in a separate thread. Pushes read lines on a queue to
    be consumed in another thread.
    '''
예제 #51
0
 def tearDown(self):
     super(Browser, self).tearDown()
     d.press('back')
     d.press('back')
     d.press('back')
     d.press('home')
예제 #52
0
    UISelectorList = d(packageName=packageName, clickable=True)
    for component in UISelectorList:
        componentList[component] = 'clickable'
    for component in componentList.keys():
        if componentList[component] == 'clickable' and component.exists:
            print(component.info)
            component.click()
            new = d.dump('temp.xml', compressed=False)
            print(current == new)
            if (current != new):
                print('here')
                traverse(pageNum + 1, resultFolder)
    d.press.back()


# In[79]:

traverse(1, '/Users/xikaioliver/Desktop/Result')

# In[65]:

packageName = 'com.fsck.k9'

# In[47]:

d(packageName=packageName, clickable=True)

# In[42]:

d.press('home')
예제 #53
0
text1 = os.system("adb install -r ./apks/Antutu.apk")
text2 = commands.getoutput("adb shell getprop ro.product.device")
text3 = commands.getoutput("git config --global --list")
text4 = commands.getoutput("adb shell getprop ro.build.type")
#获取版本信息
text5 = commands.getoutput("adb shell getprop ro.build.description")
text6 = commands.getoutput(" date \"+%Y-%m-%d %H-%M-%S\"")
#a = time.mktime(time.strptime(text6,"%Y-%m-%d"))

print text2, text3, text6

time.sleep(10)

#print text,text1

d.press("home")
time.sleep(1)
d(description="Apps").click()
time.sleep(1)
test1 = d(index=1, className="android.widget.TextView").info['text']
print test1
range1 = [
    1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
]
for i in range1:
    test = d(index=i, className="android.widget.TextView").info['text']
    print test
    if (test == "AnTuTu Benchmark"):
        d(index=i, className="android.widget.TextView").click()
        break
예제 #54
0
 def tearDown(self):
     super(Browser, self).tearDown()
     d.press('back')
     d.press('back')
     d.press('back')
     d.press('home')
예제 #55
0
파일: xx.py 프로젝트: xiaobingth/py
 def test_opencamera(self):
     if (d.screen == "off"):
         d.wakeup()
     d(text="Camera").click()
     d.press("back")
예제 #56
0
파일: camera.py 프로젝트: zuodapeng/falcon
 def tearDown(self):
     d.press('back')
     d.press('back')
     d.press('back')
     d.press('home')
     super(CameraTest, self).tearDown()