def login(self, mode, login_state): """ 账号登录 :param login_state: 登录状态 2 的时候表示已经登录 :param self: :param driver: :param mode:1:账号密码登录 2:微信登录 """ test_name = "登录" if login_state == 2: pass else: if mode == 1: # 账号密码登录 self.driver.implicitly_wait(5) mainChat_element(self) test_name = "mobile账号密码登录" mylogger.debug(test_name) # 返回测试用例名称 mylogger.info("进入登录页面成功") self.driver.implicitly_wait(5) mobile_title_element(self) mylogger.info("切换成账号密码登录") time.sleep(4) # driver.implicitly_wait(10) mobile_user_element(self) mylogger.info("输入账号成功") self.driver.implicitly_wait(10) mobile_password_element(self) mylogger.info("输如密码成功") self.driver.implicitly_wait(5) mobile_login_element(self) mylogger.info("触发登录") self.assertEqual(True, check_mobile_login(self, test_name)) mylogger.info("mobile 登录成功") elif mode == 2: # 微信登录 self.driver.implicitly_wait(5) userAvatar_element(self) mylogger.info("进入我的页面") self.driver.implicitly_wait(5) dL_element(self) mylogger.info('点击注册/登录 进入登录页面') self.driver.implicitly_wait(10) wX_element(self) time.sleep(2) mylogger.info('点击微信图标进行登录') self.driver.implicitly_wait(4) self.assertEqual(True, check_wx_login(self=self, test_name=test_name))
def check_mobile_login(self, test_name): try: self.driver.implicitly_wait(5) self.driver.find_element_by_id('chat_img').click() mylogger.info("进入消息界面成功") return True except Exception as e: mylogger.debug(e) screenShot(self, test_name) return False
def check_wx_login(self, test_name): try: self.driver.implicitly_wait(5) download_map(self) # driver.find_element_by_android_uiautomator('new UiSelector().text("离线地图")').click() mylogger.info("True") return True except Exception as e: mylogger.debug(e) screenShot(self, test_name) return False
def test6_1(self): """message send voice """ test_name = "发送语音时长为10s" mylogger.debug("%s start" % test_name) mainChat_element(self) first_chat_element(self) mylogger.info("进入与第一个联系人交互界面") chat_voice_element(self).click() self.driver.implicitly_wait(5) chat_send_voice_element(self=self, t=10000) # time.sleep(5) return_home(self, test_name)
def test3_5_Service(self): """进入 place service 并分享周边兴趣列表位置""" test_name = "%s:服务下分享" % self._testMethodName mylogger.debug("%s start" % test_name) mainChat_element(self) first_chat_element(self) mylogger.info("进入与第一个联系人交互界面") chat_img_more_element(self) time.sleep(2) chat_place_service(self.driver) chat_place_surrounding_share(self.driver, n=1) mylogger.info("分享位置触发") time.sleep(2) screenShot(self=self, test_name=test_name) return_home(self, test_name)
def test3_2_Food(self): """进入 place food 并分享周边兴趣列表位置""" test_name = "%s:美食下分享" % self._testMethodName mylogger.debug("%s start" % test_name) mainChat_element(self) first_chat_element(self) mylogger.info("进入与第一个联系人交互界面") chat_img_more_element(self) time.sleep(2) chat_place_eat(self) chat_place_surrounding_share(self=self, n=1) mylogger.info("分享位置触发") time.sleep(2) screenShot(self=self, test_name=test_name) self.driver.implicitly_wait(5) return_home(self, test_name)
def check_wx_logout(self, test_name): try: mylogger.info("进入退出验证") self.driver.implicitly_wait(5) # count_visitor = driver.find_element_by_xpath("//android.support.v7.widget.RecyclerView[2]" # "/android.widget.LinearLayout[5]/android.widget.TextView[1]").text count_visitor = self.driver.find_element_by_id( "com.erlinyou.worldlist:id/user_name_tv").text # mylogger.info("定位成功") print(count_visitor) # count_visitor = int(count_visitor) # mylogger.info('获取访客数成功%s' % count_visitor) if count_visitor == "注册/登录": mylogger.info("True") return True else: mylogger.info("退出登录失败") return False except Exception as e: mylogger.debug(e) screenShot(self, test_name) return False