def testOpenBrowser(self): assert d.exists(text='Internet') , 'not appear on the home screen' assert d.exists(text='Apps') , 'not appear on the home screen' d(text='Internet').click.wait() assert d(description="Bookmarks").wait.exists(timeout=10000), 'browser unable to open in 10 secs' d(className='android.widget.EditText').set_text('www.baidu.com') d.click('go.png', threshold=0.01) d.expect('baidu_logo.png', timeout=20)
def testSendMessage2(self): assert d.exists(text='Messaging') d(text='Messaging').click() assert d.exists(text='No conversations') d.click('create_btn.png') if d.find('input_label.png'): d.click('input_label.png')\ .click('content_label.png') assert d.exists(text='New message')
def testSendMessage1(self): assert d.exists(text='Messaging') , 'message app not appear on the home screen' assert d.exists(text='Apps') , 'apps not appear on the home screen' d(text='Messaging').click.wait() if d(text="No messages").wait.exists(timeout=10000): d(description='Compose').click.wait() d(text='Enter recipient').set_text('13581739891') assert d(text="13581739891").wait.exists(timeout=10000), 'receiver number input error' d(text='Enter message').set_text('testingongoing') assert d(text="Testingongoing").wait.exists(timeout=10000), 'content input error' d(description='Send').click.wait() else: assert 0, 'no handle error'
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'
def testCall(self): assert d.exists(text='Phone') assert d.exists(text='Apps') d(text='Phone').click.wait() d(description='One').click() d(description='Zero').click() d(description='Zero').click() d(description='Eight').click() d(description='Six').click() assert d.exists(text="10086") d(description='Dial').click.wait() assert d(text="Hold").wait.exists(timeout=10000), 'not connected in 10 secs' #assert d.exists(text='Hold'), 'not connected in 8 secs' assert d(text="00:10").wait.exists(timeout=20000), 'call duration should be 10 secs' assert d.exists(text='End call'), 'no End call button' d(text='End call').click.wait() assert d(text="Hold").wait.gone(timeout=10000), 'not connected in 10 secs'
def testWeibo(self): 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() 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(3) #d(description="首页列表").click.wait() 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' d(className='android.widget.EditText').set_text('funny funny bear') 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'
def testCall(self): import time #d.sleep(9) assert 0, 'phone failure' #assert d.exists(text='Phone') , 'Phone app not appear on home screen' d(text='Phone').click.wait() d(description='one').click() d(description='zero').click() d(description='zero').click() d(description='eight').click() d(description='six').click() assert d.exists(text="10086") if d.exists(description='dial'): d(description='dial').click.wait() assert d(text="Dialing").wait.exists(timeout=5000), 'call not connected in 10 secs' assert d(text="0:10").wait.exists(timeout=20000), 'call duration should be 10 secs' d(className='android.widget.Button', index=1).click.wait() assert d(description='dial').wait.exists(timeout=3000)
def testTakePicture(self): assert d.exists(text='Camera') , 'camera app not appear on home screen' #assert d.exists(text='Apps') d(text='Camera').click.wait() d.click(1765,555) d.click(116,966) d.press('menu') assert d(text="Delete").wait.exists(timeout=5000), 'unable to take picture!' d(text='Delete').click.wait() d(text="OK").click.wait()
def testWechat(self): assert d.exists(text='WeChat') , 'wechat app not appear on the home screen' #assert d.exists(text='Apps') , 'not appear on the home screen' d(text='WeChat').click.wait() assert d(text="Me").wait.exists(timeout=5000), 'wechat unable to open in 10 secs' assert d(text="Discover").wait.exists(timeout=1000), 'wechat unable to open in 10 secs' d(className='android.widget.ImageView', index=0).click.wait() d(className='android.widget.CheckBox').click.wait() d(text='OK(1)').click.wait() #d.click('go.png', threshold=0.01) d.click('compose.png') #d(className='android.widget.EditText').set_text('how are u') #d(className='android.widget.Button', text='Send').click.wait() #assert d(text="Thanks for your feedback.").wait.exists(timeout=10000) or d(text="Got it - thanks!").wait.exists(timeout=10000), 'msg unable to send in 20 secs' if d.exists(className='android.widget.Button', text='Hold to Talk'): pass else: d.click('composeaudio.png') d(className='android.widget.Button', text='Hold to Talk').swipe.up(steps=200) assert d(className='android.widget.Button', text='Release to send').wait.gone(timeout=10000), 'unable to send msg'
def testSendMessage1(self): assert d.exists(text="Messaging"), "message app not appear on the home screen" # assert d.exists(text='Apps') , 'apps not appear on the home screen' assert 0, "manunal failure" d(text="Messaging").click.wait() if not d(text="No conversations.").wait.exists(timeout=3000): d(className="android.view.View").long_click() if d(text="Check All").wait.exists(timeout=3000): d(text="Check All").click.wait() d(text="Delete").click.wait() d(text="Delete").click.wait() assert d(text="No conversations.").wait.exists(timeout=10000) d(text="New message").click.wait() d(className="android.widget.EditText", index=0).set_text("13581739891") assert d(text="13581739891").wait.exists(timeout=10000), "receiver number input error" d(className="android.widget.EditText", index=1).set_text("Testingongoing") assert d(text="Testingongoing").wait.exists(timeout=10000), "content input error" d(description="Send message").click.wait() assert d(text="Received").wait.exists(timeout=20000), "message unable to send in 20 seconds"
def testMoMMS(self): #Set receiver and msg content str_receiver = '13501278511' str_content = 'Message Test Content' #Start Messaging and check if sucessful assert d.exists(text='Messaging') , 'message app not appear on the home screen' d(text='Messaging').click.wait() #Delete messages if there is any message. if not d(text="No conversations.").wait.exists(timeout=1000): d(className='android.view.View').long_click() if d(text="Check All").wait.exists(timeout=3000): d(text="Check All").click.wait() d(text="Delete").click.wait() d(text="Delete").click.wait() #Compose message d(text='New message').click.wait() d(className='android.widget.EditText', index=0).set_text(str_receiver) assert d(text=str_receiver).wait.exists(timeout=10000), 'receiver number input error' d(className='android.widget.EditText', index=1).set_text(str_content) assert d(text=str_content).wait.exists(timeout=10000), 'content input error' #Add attachment from camera d(descriptionContains='dd attachment').click.wait() assert d(text='Capture picture').wait.exists(timeout=3000), 'no adding attachment panel' d(text='Capture picture').click.wait() assert d(description='Shutter button').wait.exists(timeout=3000), 'no camera' d(description='Shutter button').click.wait() assert d(className='android.widget.ImageView', index=1, description='Shutter button').wait.gone(timeout=10000), 'Take picture failed' assert d(className='android.widget.ImageView', index=1).wait.exists(timeout=5000), 'No confirm for picture' d(className='android.widget.ImageView', index=1).click.wait() assert d(text='MMS').wait.exists(timeout=5000), 'add attachment failed' #Send MMS d(descriptionContains='end message').click.wait() assert d(text='Sending').wait.exists(timeout=5000), 'No sending status' u.sleep(20) assert d(text='Sending').wait.gone(timeout=40000), 'MMS sending failed in 60s'
def testSendMessage1(self): assert d.exists(text='Messaging') , 'message app not appear on the home screen' #assert d.exists(text='Apps') , 'apps not appear on the home screen' d(text='Messaging').click.wait() if not d(text="No messages").wait.exists(timeout=3000): d.press('menu') d(text="Delete threads").click.wait() d(text="Select all").click.wait() d(text="Delete").click.wait() d(text="OK").click.wait() assert d(text="No messages").wait.exists(timeout=10000) d(description='Compose').click.wait() d(text='Enter recipient').set_text('13581739891') assert d(text="13581739891").wait.exists(timeout=10000), 'receiver number input error' d(text='Enter message').set_text('testingongoing') assert d(text="Testingongoing").wait.exists(timeout=10000), 'content input error' d(description='Send').click.wait() assert d(className='android.widget.ProgressBar').wait.gone(timeout=10000), 'message unable to send in 30 seconds' assert d(description='Sending failed').wait.exists(timeout=10000), 'message send failed' assert d(text='Failed').wait.exists(timeout=10000), 'message send failed'
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'
def testMoCall(self): #Start dialer and confirm if dialer is launched d.start_activity(component='com.android.contacts/.activities.TwelveKeyDialer') assert d(text='Keypad').wait.exists(timeout=5000), 'Launch dialer failed' #MO call to 10086(cmcc) or 10010(unicom) d(description='one').click() d(description='zero').click() d(description='zero').click() d(description='one').click() d(description='zero').click() assert d.exists(text="10010") , 'Input number error!' #Press the call button d(text='Keypad').click.wait() #Wait 'Dialing' to see if begin to dial, and wait 'Dialing' disappear to see if connected. #Wait '0:10' to see if duration is over 10s. assert d(text="Dialing").wait.exists(timeout=10000), 'Should begin to dialing in 10 secs' assert d(text="Dialing").wait.gone(timeout=10000), 'Should connect in 10 secs' assert d(textStartsWith="0:1").wait.exists(timeout=15000), 'Call duration should be 10 secs' d(className='android.widget.Button', index=1).click.wait() assert d(text='Keypad').wait.exists(timeout=10000), 'Should Hangup in 10s.'