Exemplo n.º 1
0
Arquivo: weibo.py Projeto: jimlin95/hm
    def weibo(self, wifi):
        u.openWifi(d, wifi)
        
        #Open sina weibo and check if successful
        d.start_activity(component='com.sina.weibo/.SplashActivity')
        assert d(className='android.widget.TextView', description="MainEdit").wait.exists(timeout=10000), 'weibo cient unable to open in 10 secs'

        #Clear the 'sent fail' prompt
        if d.exists(text='Sent failed. It has been saved in the draft.'):
            d(text='Sent failed. It has been saved in the draft.').click.wait()
            d.press('back')
        
        #Swipe to fetch new messages 3 times
        for i in range(3):
            #d.swipe(340, 340, 340, 1000, steps=5)
            d(description='首页列表').click.wait()
            d(className='android.widget.LinearLayout', index=0).click.wait()
            u.sleep(5)
        
        #Compose new message
        #Switch to message editor
        d(className='android.widget.TextView', description="MainEdit").click.wait()
        assert d(className='android.widget.TextView', text="New Weibo").wait.exists(timeout=3000), 'unable to compose message'
        
        #Fetch and input random TEXT, and send the message
        d(className='android.widget.EditText').set_text(u.fetchText())
        d(text='Send', description='Send').click.wait()
        assert not d(text='Sent failed. It has been saved in the draft.').wait.exists(timeout=10000), 'msg send failed'
        assert d(className='android.widget.TextView', description="MainEdit").wait.exists(timeout=10000), 'unable to back to home screen in 10 secs'
Exemplo n.º 2
0
Arquivo: baidu.py Projeto: jimlin95/hm
    def testBaidumaps(self):
        #Check and set wifi
        u.openWifi(d, True)

        #Launch Baidu map app
        d.start_activity(component='com.baidu.BaiduMap/com.baidu.baidumaps.WelcomeScreen')

        if d(text='不要福利').wait.exists(timeout=5000):
            d(text='不要福利').click.wait()
        if d(text='以后再说').wait.exists(timeout=5000):
            d(text='以后再说').click.wait()
        if d(text='以后再说').wait.exists(timeout=2000):
            d(text='以后再说').click.wait()

        #Check if baidu map can be launched successfully
        assert d(text='附近').wait.exists(timeout=10000), 'No enter main map activity'
        assert d(text='路线').wait.exists(timeout=2000), 'No enter main map activity'

        #Swipe on the map
        d.swipe(340, 340, 340, 900, steps=5)

        #Locate to current location
        d.expect('location.png')
        d.click('location.png')

        #Located successful
        assert d(text='我的位置').wait.exists(timeout=3000), 'can not locate'
Exemplo n.º 3
0
    def openBrowser(self, wifi):
        u.openWifi(d, wifi)
        
        #Launch browser and check if launch sucessful
        d.start_activity(component='com.android.browser/.BrowserActivity')
        assert d(className='android.widget.ImageButton', index=3).wait.exists(timeout=5000), 'Launch browser failed in 5s'

        #Open a new page
        #and go to www.qq.com
        d(className='android.widget.ImageButton', index=3).click.wait()
        assert d(text="Bookmarks").wait.exists(timeout=3000), 'Open new page failed in 3s'
        d(className='android.widget.EditText').set_text('wap.qq.com')
        d.press('enter')

        #Sleep 15s to wait loading web page
        u.sleep(15)
        flag = True
        i = 0
        while(flag and i < 9):
            i = i + 1
            d.swipe(400, 1000, 400, 500, steps=6)
            u.sleep(5)
            if not d.find('browser_blank.png'):
                flag = False
        if flag:
            assert False, 'Open the web page failed in 60s.'
        else:
            assert True
Exemplo n.º 4
0
    def openBrowser(self, wifi):
        u.openWifi(d, wifi)
        #Launch browser
        d.start_activity(component='com.android.browser/.BrowserActivity')
        assert d(description='Page manager').wait.exists(timeout=5000), 'Launch browser failed in 5s'

        d(className='android.widget.EditText').set_text('wap.qq.com')
        d.press('enter')

        #Sleep 15s to wait loading web page
        d.sleep(15)
        if d.find('browser_blank.png'):
            assert False, 'Open the web page failed.'
        else:
            assert True
Exemplo n.º 5
0
    def weChat(self, wifi):
        u.openWifi(d, wifi)

        #Start WeChat and check if successful
        d.start_activity(component='com.tencent.mm/.ui.LauncherUI')
        assert d(text="Me").wait.exists(timeout=20000), 'wechat unable to open in 20 secs'
        assert d(text="Discover").wait.exists(timeout=20000), 'wechat unable to open in 20 secs'

        #Switch to groups, moments, and settings
        d(className='android.widget.RadioButton', text='Contacts').click.wait()
        d(text='Groups').wait.exists(timeout=3000), 'Switch to Contacts failed'
        d(className='android.widget.RadioButton', text='Discover').click.wait()
        d(text='Moments').wait.exists(timeout=3000), 'Switch to Discover failed'
        d(className='android.widget.RadioButton', text='Me').click.wait()
        d(text='Settings').wait.exists(timeout=3000), 'Switch to Me failed'
        d(className='android.widget.RadioButton', text='Chats').click.wait()

        #Enter WeChat Team
        d.expect('conversation.png')
        d.click('conversation.png')

        assert d(text='常见问题').wait.exists(timeout=3000), 'Switch to chat failed.'

        #Clear chat history
        d.press('menu')
        d(text='Clear Chat History').click.wait()
        d(text='OK').click.wait()

        #Compose and send out a void message
        d.expect('compose.png', timeout=10)
        d.click('compose.png')
        if d.find('voice.png'):
            d.click('voice.png')

        assert d(className='android.widget.Button', text='Hold to Talk').wait.exists(timeout=3000), 'Can not swith to voice message'
        d(className='android.widget.Button', text='Hold to Talk').swipe.up(steps=100)

        #Check if can get feedback in 60s
        d.expect('chat.png', timeout=60)
Exemplo n.º 6
0
    def weibo(self, wifi):
        u.openWifi(d, wifi)
        #assert d.exists(text='Weibo') , 'wechat app not appear on the home screen'
        #assert d.exists(text='Apps')  , 'not appear on the home screen'
        #d(text='Weibo').click.wait()
        d.start_activity(component='com.sina.weibo/.SplashActivity')
        assert d(className='android.widget.TextView', description="MainEdit").wait.exists(timeout=10000), 'weibo cient unable to open in 10 secs'

        if d.exists(text='Sent failed. It has been saved in the draft.'):
            d(text='Sent failed. It has been saved in the draft.').click.wait()
            d.press('back')
        d.swipe(350, 420, 350, 820)
        d.sleep(5)
        
        d(className='android.widget.TextView', description="MainEdit").click.wait()
        assert d(className='android.widget.TextView', text="New Weibo").wait.exists(timeout=3000), 'unable to compose message'
        
        n=random.randint(15, 30)
        
        d(className='android.widget.EditText').set_text(''.join(self.content(n)))
        d(text='Send', description='Send').click.wait()
        assert not d(text='Sent failed. It has been saved in the draft.').wait.exists(timeout=10000), 'msg send failed'
        assert d(className='android.widget.TextView', description="MainEdit").wait.exists(timeout=10000), 'unable to back to home screen in 10 secs'