def test_send_txt(self): '''查找联系人,发送文本消息''' #查找联系人 time.sleep(5) swip.swipLeft(self, 500) #左划 time.sleep(2) swip.swipLeft(self, 500) #左划 self.driver.find_element_by_id("group_name").click() wq = self.driver.find_element_by_id("chatting_attach_btn") assert_not_none(wq, u"未定位到加号按钮") wq.click() time.sleep(2) photograph_x = self.driver.find_element_by_name(u"拍照").location.get( 'x') photograph_y = self.driver.find_element_by_name(u"拍照").location.get( 'y') print photograph_x, photograph_y photograph_x = int(photograph_x) photograph_y = int(photograph_y) - 100 print photograph_x, photograph_y self.driver.tap([(photograph_x, photograph_y)], ) #点击 self.driver.find_element_by_name(u"录制小视频").click() self.driver.find_element_by_id("switch_btn").click() time.sleep(2) self.driver.find_element_by_id("start").click() time.sleep(10) #录制10秒小视频 self.driver.find_element_by_id("stop").click() time.sleep(2) self.driver.find_element_by_id("text_right").click()
def test_send_txt(self): '''发送链接消息''' time.sleep(5) #发送文本链接消息 swip.swipLeft(self, 500) #左划 time.sleep(2) self.driver.find_element_by_id( "com.yuntongxun.ecdemo:id/card_item_tv").click() self.driver.find_element_by_id("content").click() self.driver.find_element_by_id("content").send_keys("13311267857") self.driver.find_element_by_id("text_right").click() self.driver.find_element_by_id("chatting_content_et").send_keys( "https://www.baidu.com") time.sleep(2) self.driver.find_element_by_id("chatting_send_btn").click() el = self.driver.find_element_by_id("chatting_content_itv") action1 = TouchAction(self.driver) action1.long_press(el, duration=5000).perform() self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click() self.driver.find_element_by_name("https://www.baidu.com").click() el = self.driver.contexts #获取H5页面 print el el = self.driver.find_element_by_id("btn_middle").get_attribute("text") assert_equal(el, u"下载", msg=u"访问链接失败") print u"访问链接成功" self.driver.press_keycode('4') #点击返回键 el = self.driver.find_element_by_id("chatting_content_itv") action1.long_press(el, duration=5000).perform() self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click()
def test_send_txt(self): '''查找联系人,发送文本消息''' #查找联系人 time.sleep(5) swip.swipLeft(self, 500) #左划 time.sleep(2) swip.swipLeft(self, 500) #左划 self.driver.find_element_by_id("group_name").click() wq = self.driver.find_element_by_id("chatting_attach_btn") assert_not_none(wq, u"未定位到加号按钮") wq.click() time.sleep(2) #发送语音 self.driver.find_element_by_id("chatting_mode_btn").click() #左下角语音按钮 action1 = TouchAction(self.driver) el = self.driver.find_element_by_id("voice_record_imgbtn") action1.long_press(el, duration=5000).perform() #点击发送出去的语音 self.driver.find_element_by_id( "chatting_voice_play_anim_tv").click() #点击发送的语音 time.sleep(5) self.driver.find_element_by_id("btn_left").click() #点击右上角返回按钮 logout.test_logout(self) #退出登录 login.test_login(self, el="13366778604") #使用账号13366778606登录 self.driver.find_element_by_name("13311267857").click() self.driver.find_element_by_id("chatting_voice_play_anim_tv").click() time.sleep(5) self.driver.press_keycode('4') #点击返回键 el = self.driver.find_element_by_id("avatar_iv") action1.long_press(el, duration=5000).perform() self.driver.find_element_by_name(u"删除该聊天").click() logout.test_logout(self) #退出登录 time.sleep(5)
def test_send_readrurn(self): '''发送阅后即焚''' login.test_login(self, phoneid="13311267857") time.sleep(5) swip.swipLeft(self, 500) #左划 time.sleep(2) self.driver.find_element_by_id( "com.yuntongxun.ecdemo:id/card_item_tv").click() self.driver.find_element_by_id("content").click() self.driver.find_element_by_id("content").send_keys("13366778604") self.driver.find_element_by_id("text_right").click() #发送阅后即焚图片 self.driver.find_element_by_id("chatting_attach_btn").click() self.driver.find_element_by_name(u"阅后即焚").click() self.driver.find_element_by_name(u"拍照").click() time.sleep(2) self.driver.find_element_by_id( "com.lenovo.scg:id/shutter_button").click() time.sleep(2) self.driver.find_element_by_id("com.lenovo.scg:id/btn_done").click() time.sleep(2) self.driver.find_element_by_id("text_right").click() self.driver.press_keycode('4') #点击返回键 #self.driver.find_element_by_id("chatting_content_itv").click() time.sleep(2) logout.test_logout(self) #退出登录 login.test_login(self, phoneid="13366778604") #使用账号receive登录 time.sleep(2) self.driver.find_element_by_name("13311267857").click() self.driver.find_element_by_id("chatting_content_iv").click() time.sleep(2) self.driver.press_keycode('4') #点击返回键 #获取点击后的图片 self.test_get_screen_by_element() #对比焚毁的图片 self.test_same_as() time.sleep(2) print u"接收图片成功" #发送阅后即焚图片 x1 = self.driver.find_element_by_id( "chatting_content_iv").location.get('x') y1 = self.driver.find_element_by_id( "chatting_content_iv").location.get('y') print x1, y1 x1 = int(x1) + 400 y1 = int(y1) + 100 print x1, y1 self.driver.tap([(x1, y1)], 5000) self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click() #确认删除 self.driver.press_keycode('4') #点击返回键 logout.test_logout(self) #退出登录
def test_send_expression(self): '''查找联系人,发送表情''' #login.test_login(self,el="13311267857") time.sleep(5) swip.swipLeft(self,500)#左划 time.sleep(2) self.driver.find_element_by_id("com.yuntongxun.ecdemo:id/card_item_tv").click() self.driver.find_element_by_id("content").click() self.driver.find_element_by_id("content").send_keys("13311267857") self.driver.find_element_by_id("text_right").click() time.sleep(3) #all=self.driver.page_source action1 = TouchAction(self.driver) try: wq=str(self.driver.find_element_by_id("com.yuntongxun.ecdemo:id/chatting_avatar_iv"))#头像 #itv=str(self.driver.find_element_by_id("com.yuntongxun.ecdemo:id/chatting_content_itv"))#文字表情图片等 #filesize=str(self.driver.find_element_by_id("com.yuntongxun.ecdemo:id/tv_filesize"))#视频大小等 while wq: el=self.driver.find_element_by_id("com.yuntongxun.ecdemo:id/chatting_content_itv")#文字 action1.long_press(el,duration=5000).perform() self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click() except: self.driver.press_keycode('4')#点击返回键 time.sleep(2) self.driver.find_element_by_id("com.yuntongxun.ecdemo:id/card_item_tv").click() self.driver.find_element_by_id("content").click() self.driver.find_element_by_id("content").send_keys("13311267857") self.driver.find_element_by_id("text_right").click() print u"已经无历史数据" #发送表情 self.driver.find_element_by_id("chatting_content_et").click() el=self.driver.find_element_by_id("chatting_smiley_btn") self.assertIsNotNone(el,msg=u"定位表情切换图标失败") el.click()#点击切换到表情输入 time.sleep(2) self.driver.find_element_by_name("😄").click()#点击表情 self.driver.find_element_by_id("chatting_send_btn").click() el = self.driver.find_element_by_id("chatting_content_itv") action1 = TouchAction(self.driver) action1.long_press(el,duration=5000).perform() self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click() el=self.driver.find_element_by_id("chatting_content_itv").get_attribute("text") assert_equal(el, "😄", msg=u"接收表情失败") print u"接收表情成功" + el el = self.driver.find_element_by_id("chatting_content_itv") action1 = TouchAction(self.driver) action1.long_press(el,duration=5000).perform() self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click() self.driver.press_keycode('4')#点击返回键
def test_send_video(self): '''发送小视频''' time.sleep(5) swip.swipLeft(self,500)#左划 time.sleep(2) self.driver.find_element_by_id("com.yuntongxun.ecdemo:id/card_item_tv").click() self.driver.find_element_by_id("content").click() self.driver.find_element_by_id("content").send_keys("13311267857") self.driver.find_element_by_id("text_right").click() #发送小视频 time.sleep(5) self.driver.find_element_by_id("chatting_attach_btn").click() time.sleep(2) photograph_x=self.driver.find_element_by_name(u"拍照").location.get('x') photograph_y=self.driver.find_element_by_name(u"拍照").location.get('y') print photograph_x,photograph_y photograph_x=int(photograph_x) photograph_y=int(photograph_y)-100 print photograph_x,photograph_y self.driver.tap([(photograph_x,photograph_y)], )#点击 self.driver.find_element_by_name(u"录制小视频").click() self.driver.find_element_by_id("switch_btn").click() time.sleep(2) self.driver.find_element_by_id("start").click() time.sleep(10)#录制10秒小视频 self.driver.find_element_by_id("stop").click() time.sleep(2) self.driver.find_element_by_id("text_right").click() el=self.driver.find_element_by_id("tv_read_unread").get_attribute("text") assert_equal(el, u"已读", msg=u"状态验证失败") print el+u" 阅读状态验证成功" el = self.driver.find_element_by_id("tv_read_unread")#状态 action1 = TouchAction(self.driver) action1.long_press(el,duration=5000).perform() self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click()#确认删除 time.sleep(2) self.driver.find_element_by_id("iv_file_mp4").click() time.sleep(3) self.driver.find_element_by_id("iv_file_mp4").click() time.sleep(5) self.driver.press_keycode('4')#点击返回键 #获取点击后的图片 time.sleep(2) print u"接收小视频成功" #删除小视频 el = self.driver.find_element_by_id("tv_filesize") action1.long_press(el,duration=5000).perform() self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click()
def test_send_photograph(self): '''发送拍摄照片''' time.sleep(5) swip.swipLeft(self,500)#左划 time.sleep(2) self.driver.find_element_by_id("com.yuntongxun.ecdemo:id/card_item_tv").click() self.driver.find_element_by_id("content").click() self.driver.find_element_by_id("content").send_keys("13311267857") self.driver.find_element_by_id("text_right").click() #发送照片 time.sleep(5) self.driver.find_element_by_id("chatting_attach_btn").click() time.sleep(2) photograph_x=self.driver.find_element_by_name(u"拍照").location.get('x') photograph_y=self.driver.find_element_by_name(u"拍照").location.get('y') print photograph_x,photograph_y photograph_x=int(photograph_x) photograph_y=int(photograph_y)-100 print photograph_x,photograph_y self.driver.tap([(photograph_x,photograph_y)], )#点击 self.driver.find_element_by_name(u"拍照").click() #self.driver.find_element_by_id("cameraswitchtofront").click()#切换摄像头 time.sleep(2) self.driver.context#可以定位到悬浮窗口 self.driver.find_element_by_id("com.lenovo.scg:id/shutter_button").click()#快门 time.sleep(2) self.driver.context#可以定位到悬浮窗口 self.driver.find_element_by_id("com.lenovo.scg:id/btn_done").click()#保存 time.sleep(2) self.driver.find_element_by_id("text_right").click() print u"拍照成功" el=self.driver.find_element_by_id("tv_read_unread").get_attribute("text") assert_equal(el, u"已读", msg=u"状态验证失败") print el+u" 阅读状态验证成功" el = self.driver.find_element_by_id("tv_read_unread")#状态 action1 = TouchAction(self.driver) action1.long_press(el,duration=5000).perform() self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click()#确认删除 #删除接收到的图片 x1=self.driver.find_element_by_id("chatting_content_iv").location.get('x') y1=self.driver.find_element_by_id("chatting_content_iv").location.get('y') print x1,y1 x1=int(x1)+400 y1=int(y1)+100 print x1,y1 self.driver.tap([(x1,y1)],5000) self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click()#确认删除
def test_send_picture(self): '''发送图片''' time.sleep(5) swip.swipLeft(self, 500) #左划 time.sleep(2) self.driver.find_element_by_id( "com.yuntongxun.ecdemo:id/card_item_tv").click() self.driver.find_element_by_id("content").click() self.driver.find_element_by_id("content").send_keys("13311267857") self.driver.find_element_by_id("text_right").click() #发送图片 self.driver.find_element_by_id("chatting_attach_btn").click() self.driver.find_element_by_id("app_grid_item_icon_mask").click() self.driver.find_element_by_id("imageview_photo").click() self.driver.find_element_by_id("text_right").click() time.sleep(2) self.test_get_screen_by_element() #获取图片保存到本地 #删除发送的图片 el = self.driver.find_element_by_id("tv_read_unread") #状态 action1 = TouchAction(self.driver) action1.long_press(el, duration=5000).perform() self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click() #确认删除 time.sleep(2) self.test_same_as() #接收到的图片对比发送的图片 #self.test_get_screen_by_element()#获取接收到的图片保存到本地 print u"接收图片成功" x1 = self.driver.find_element_by_id( "chatting_content_iv").location.get('x') y1 = self.driver.find_element_by_id( "chatting_content_iv").location.get('y') print x1, y1 x1 = int(x1) + 400 y1 = int(y1) + 100 print x1, y1 self.driver.tap([(x1, y1)], 5000) self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click() #确认删除
def test_send_txt(self): '''查找联系人,发送文本消息''' #查找联系人 time.sleep(5) swip.swipLeft(self,500)#左划 time.sleep(2) swip.swipLeft(self,500)#左划 self.driver.find_element_by_id("group_name").click() self.driver.find_element_by_id("chatting_content_et").send_keys("hello tester") self.driver.find_element_by_id("chatting_send_btn").click() time.sleep(2) #发送文本消息 sendoutcontent = self.driver.find_element_by_id("chatting_content_itv").get_attribute("text") print sendoutcontent receivecontent = self.driver.find_element_by_id("tv_read_unread").get_attribute("text") #验证发送消息 assert_equal(sendoutcontent,"hello tester",msg=u'发送的消息验证失败') assert_equal(receivecontent,u"未读",msg=u'消息状态验证失败')
def test_send_voicemessage(self): '''发送萝莉变声语音消息''' time.sleep(5) swip.swipLeft(self, 500) #左划 time.sleep(2) self.driver.find_element_by_id( "com.yuntongxun.ecdemo:id/card_item_tv").click() self.driver.find_element_by_id("content").click() self.driver.find_element_by_id("content").send_keys("13311267857") self.driver.find_element_by_id("text_right").click() #发送变声语音 self.driver.find_element_by_id("chatting_mode_btn").click() #左下角语音按钮 time.sleep(2) self.driver.swipe(810, 1600, 54, 1600, 500) action1 = TouchAction(self.driver) el = self.driver.find_element_by_id("voice_record_imgbtn_biansheng") action1.long_press(el, duration=10000).perform() self.driver.find_element_by_name(u"萝莉").click() self.driver.find_element_by_id("layout_send_changevoice").click() #删除 el = self.driver.find_element_by_id("tv_read_unread").get_attribute( "text") assert_equal(el, u"已读", msg=u"状态验证失败") print el + u" 阅读状态验证成功" el = self.driver.find_element_by_id("tv_read_unread") #状态 action1 = TouchAction(self.driver) action1.long_press(el, duration=5000).perform() self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click() #确认删除 self.driver.find_element_by_id("chatting_voice_play_anim_tv").click() time.sleep(5) #删除接收语音 el = self.driver.find_element_by_id("chatting_content_itv") #时间 action1 = TouchAction(self.driver) action1.long_press(el, duration=5000).perform() self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click() #确认删除
def test_send_voicemessage(self): '''发送语音消息60秒''' time.sleep(5) swip.swipLeft(self,500)#左划 time.sleep(2) self.driver.find_element_by_id("com.yuntongxun.ecdemo:id/card_item_tv").click() self.driver.find_element_by_id("content").click() self.driver.find_element_by_id("content").send_keys("13311267857") self.driver.find_element_by_id("text_right").click() #发送语音 self.driver.find_element_by_id("chatting_mode_btn").click()#左下角语音按钮 action1 = TouchAction(self.driver) el = self.driver.find_element_by_id("voice_record_imgbtn") action1.long_press(el,duration=59000).perform() el=self.driver.find_element_by_id("tv_read_unread").get_attribute("text") assert_equal(el, u"已读", msg=u"状态验证失败") print el+u" 阅读状态验证成功" el = self.driver.find_element_by_id("tv_read_unread")#状态 action1 = TouchAction(self.driver) action1.long_press(el,duration=5000).perform() self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click()#确认删除 el=[] el=self.driver.find_element_by_id("chatting_content_itv").get_attribute("text") a=str(el[0])+str(el[1]) print a assert_equal(int(a), 58, msg=u"时间验证失败") print el+u" 语音时间显示验证成功" el = self.driver.find_element_by_id("chatting_content_itv")#时间 action1 = TouchAction(self.driver) action1.long_press(el,duration=5000).perform() self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click()#确认删除 self.driver.press_keycode('4')#点击返回键 logout.test_logout(self)#退出登录
def test_videocall(self): '''视频通话''' driver = self.driver #查找联系人 login.test_login(self, phoneid="13311267857") #使用账号13366778606登录 #点击聊天 self.driver.find_element_by_id( "com.yuntongxun.eckuailiao:id/btn_address_list").click() time.sleep(2) self.driver.find_element_by_id( "com.yuntongxun.eckuailiao:id/search").send_keys("13366778604") self.driver.find_element_by_id( "com.yuntongxun.eckuailiao:id/name_tv").click() self.driver.find_element_by_id( "com.yuntongxun.eckuailiao:id/phone_chat").click() self.driver.find_element_by_id("chatting_a ttach_btn").click() time.sleep(5) swip.swipLeft(self, 500) #左划 self.driver.find_element_by_name("17710556903").click() self.driver.find_element_by_id("entrance_chat").click() #self.driver.find_element_by_name("a1").click() time.sleep(5) wq = driver.find_element_by_id("chatting_attach_btn") assert_not_none(wq, u"未定位到加号按钮") wq.click() time.sleep(2) driver.tap([(400, 1660)], ) #点击 print "Start : %s" % time.ctime() time.sleep(6) print "End : %s" % time.ctime() #图片对比 self.test_get_screen_by_element() self.test_same_as() time.sleep(2) driver.find_element_by_id("video_botton_cancle").click() time.sleep(5) self.driver.press_keycode('4') #点击返回键
def test_send_voicemessage(self): '''发送语音消息''' time.sleep(5) swip.swipLeft(self,500)#左划 time.sleep(2) self.driver.find_element_by_id("com.yuntongxun.ecdemo:id/card_item_tv").click() self.driver.find_element_by_id("content").click() self.driver.find_element_by_id("content").send_keys("13311267857") self.driver.find_element_by_id("text_right").click() #发送语音 self.driver.find_element_by_id("chatting_mode_btn").click()#左下角语音按钮 action1 = TouchAction(self.driver) el = self.driver.find_element_by_id("voice_record_imgbtn") action1.long_press(el,duration=5000).perform() el=self.driver.find_element_by_id("tv_read_unread").get_attribute("text") assert_equal(el, u"已读", msg=u"状态验证失败") print el+u" 阅读状态验证成功" el = self.driver.find_element_by_id("tv_read_unread")#状态 action1 = TouchAction(self.driver) action1.long_press(el,duration=5000).perform() self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click()#确认删除 self.driver.find_element_by_id("chatting_voice_play_anim_tv").click() time.sleep(5) x1=self.driver.find_element_by_id("chatting_voice_play_anim_tv").location.get('x') y1=self.driver.find_element_by_id("chatting_voice_play_anim_tv").location.get('y') print x1,y1 x1=int(x1)+400 y1=int(y1)+100 print x1,y1 self.driver.tap([(x1,y1)],5000) self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click()#确认删除
def test_send_expression(self): '''查找联系人,发送表情''' #login.test_login(self,el="13311267857") time.sleep(5) swip.swipLeft(self,500)#左划 time.sleep(2) self.driver.find_element_by_id("com.yuntongxun.ecdemo:id/card_item_tv").click() self.driver.find_element_by_id("content").click() self.driver.find_element_by_id("content").send_keys("13311267857") self.driver.find_element_by_id("text_right").click() time.sleep(3) #all=self.driver.page_source action1 = TouchAction(self.driver) try: #wq=str(self.driver.find_element_by_id("com.yuntongxun.ecdemo:id/chatting_avatar_iv"))#头像 itv=str(self.driver.find_element_by_id("com.yuntongxun.ecdemo:id/chatting_content_itv"))#文字表情图片等 #filesize=str(self.driver.find_element_by_id("com.yuntongxun.ecdemo:id/tv_filesize"))#视频大小等 while itv: el=self.driver.find_element_by_id("com.yuntongxun.ecdemo:id/chatting_content_itv")#文字 action1.long_press(el,duration=5000).perform() self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click() except: self.driver.press_keycode('4')#点击返回键 time.sleep(2) self.driver.find_element_by_id("com.yuntongxun.ecdemo:id/card_item_tv").click() self.driver.find_element_by_id("content").click() self.driver.find_element_by_id("content").send_keys("13311267857") self.driver.find_element_by_id("text_right").click() print u"已经无历史数据" elif filesize: while filesize: el=self.driver.find_element_by_id("com.yuntongxun.ecdemo:id/tv_filesize")#文字 action1.long_press(el,duration=5000).perform() self.driver.find_element_by_name(u"删除").click() self.driver.find_element_by_id("dilaog_button3").click()