def MyTorrent(driver): """ 先决条件:进入我家页面 :return: None """ try: # 点击我的种子进入我的种子页面 Public_Page.debug_NomalTest( driver, title="我的种子", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id="com.pujitech.pujiejia:id/tv_user_wallet", Wait_Element= ".modules.bounspoint.activites.BonusPointsDetailActivity", check_element_id="com.pujitech.pujiejia:id/tv_title") # 点击大框进入我的种子页面 Public_Page.debug_NomalTest( driver, title="我的种子", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id= "com.pujitech.pujiejia:id/rl_user_wallet_container", Wait_Element= ".modules.bounspoint.activites.BonusPointsDetailActivity", check_element_id="com.pujitech.pujiejia:id/tv_title") unittest_TestResult = True except: unittest_TestResult = False finally: return unittest_TestResult
def AllOrder(driver): """ 先决条件: 进入我家页面 :return: None """ try: time.sleep(2) # 点击全部订单进入我的订单页面 Public_Page.debug_NomalTest( driver, title="全部订单", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id= "com.pujitech.pujiejia:id/ll_all_order_container", Wait_Element= ".modules.usercenter.order.views.activities.OrderListActivity", check_element_id="com.pujitech.pujiejia:id/tv_title", YESBack=False) unittest_TestResult = True except: unittest_TestResult = False finally: return unittest_TestResult
def SmartBandInstruction(driver): """ 点击智能手环的使用说明 先决条件:进入我家页面 :return: None """ try: time.sleep(2) huadong.shanghua(driver, 300) time.sleep(1) Public_Page.debug_NomalTest( driver, title="使用说明", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id= "com.pujitech.pujiejia:id/btn_brand_instruction", Wait_Element=".modules.help.view.activities.HelpActivity", check_element_id="com.pujitech.pujiejia:id/tv_title") unittest_TestResult = True except: unittest_TestResult = False finally: return unittest_TestResult
def IntoCoupon(driver): """ 先决条件:进入我家页面 :return: None """ try: time.sleep(1) #测试点击我的优惠券进入我的优惠券页面 Public_Page.debug_NomalTest( driver, title="我的优惠券", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id= "com.pujitech.pujiejia:id/rl_user_coupon_container", Wait_Element= ".modules.usercenter.coupon.view.activities.AvailableCouponActivity", check_element_id="com.pujitech.pujiejia:id/tv_title", YESBack=False) #点击优惠券使用说明 Public_Page.debug_NomalTest( driver, title="使用说明", MainWait_Element= ".modules.usercenter.coupon.view.activities.AvailableCouponActivity", find_element_id="com.pujitech.pujiejia:id/tv_coupon_top", Wait_Element=".modules.help.view.activities.HelpActivity", check_element_id="com.pujitech.pujiejia:id/tv_title", ) #查看无效优惠券 Public_Page.debug_NomalTest( driver, title="无效优惠券", MainWait_Element= ".modules.usercenter.coupon.view.activities.AvailableCouponActivity", find_element_id="com.pujitech.pujiejia:id/tv_bottom_coupon", Wait_Element= ".modules.usercenter.coupon.view.activities.UnAvailableCouponActivity", check_element_id="com.pujitech.pujiejia:id/tv_title", ) time.sleep(3) driver.find_element_by_id( "com.pujitech.pujiejia:id/iv_back").click() #退回到我家页面 unittest_TestResult = True except: time.sleep(1) driver.find_element_by_id( "com.pujitech.pujiejia:id/iv_back").click() unittest_TestResult = False finally: return unittest_TestResult
def SheQuFuWu(driver): """ 首页实地派下社区服务模块, 包括物业缴费,限时促销,精品团购 :return: None """ time.sleep(2) try: Public_Page.debug_NomalTest( driver, title="物业缴费", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id="com.pujitech.pujiejia:id/tv_modules_name", Wait_Element= ".modules.usercenter.community.views.activities.PropertyPaymentHomeActivity", check_element_id="com.pujitech.pujiejia:id/tv_title", TestCase="物业缴费") time.sleep(2) Public_Page.debug_NomalTest( driver, title="限时促销", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id="com.pujitech.pujiejia:id/tv_modules_name", Wait_Element=".modules.h5.views.activitys.CommonH5Activity", check_element_id="com.pujitech.pujiejia:id/tv_title", TestCase="限时促销") time.sleep(2) Public_Page.debug_NomalTest( driver, title="精品团购", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id="com.pujitech.pujiejia:id/tv_modules_name", Wait_Element=".modules.h5.views.activitys.CommonH5Activity", check_element_id="com.pujitech.pujiejia:id/tv_title", TestCase="精品团购") except Exception as e: print("报错为", e) pass
def MyHome_MsgSetting(driver): try: # 测试我的消息页面是否正常显示 driver.wait_activity(".modules.main.views.activities.MainActivity", 30) # 等待切换到我家页面30s driver.find_element_by_id( "com.pujitech.pujiejia:id/iv_message").click() time.sleep(20) driver.wait_activity( ".modules.h5.views.activitys.CommonH5Activity", 30) # 我的消息内容加载时间较长,目前开发尚未解决问题,先这么写,以后优化 driver.back() ''' Public_Page.debug_NomalTest(driver, title="我的消息", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id="com.pujitech.pujiejia:id/iv_message", Wait_Element = None, check_element_id="com.pujitech.pujiejia:id/tv_title" ) ''' # 测试设置页面是否正确显示 Public_Page.debug_NomalTest( driver, title="设置", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id="com.pujitech.pujiejia:id/iv_setting", Wait_Element= ".modules.usercenter.setting.views.activities.SettingActivity", check_element_id="com.pujitech.pujiejia:id/tv_title") ''' driver.wait_activity(".modules.main.views.activities.MainActivity", 30) driver.find_element_by_id("com.pujitech.pujiejia:id/iv_setting").click() time.sleep(2) driver.wait_activity(".modules.usercenter.setting.views.activities.SettingActivity", 30) checkpoint = driver.find_element_by_id("com.pujitech.pujiejia:id/tv_title") if checkpoint.text == "设置": driver.find_element_by_id("com.pujitech.pujiejia:id/iv_back").click() print("我家→设置模块可以正常访问....................PASS") else: print("我家→设置模块出现BUG....................用例失败") ''' # 点击头像图片进入个人资料页面 Public_Page.debug_NomalTest( driver, title="个人资料", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id="com.pujitech.pujiejia:id/iv_avatar", Wait_Element= ".modules.usercenter.selfinfo.views.activities.SelfInfoActivity", check_element_id="com.pujitech.pujiejia:id/tv_title") print("点击头像图片进入个人资料页面测试完成") # 点击用户名称进入个人资料页面 Public_Page.debug_NomalTest( driver, title="个人资料", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id="com.pujitech.pujiejia:id/tv_user_center_name", Wait_Element= ".modules.usercenter.selfinfo.views.activities.SelfInfoActivity", check_element_id="com.pujitech.pujiejia:id/tv_title") print("点击用户名称进入个人资料页面测试完成") # 点击用户手机号进入个人资料页面 Public_Page.debug_NomalTest( driver, title="个人资料", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id="com.pujitech.pujiejia:id/tv_user_center_phone", Wait_Element= ".modules.usercenter.selfinfo.views.activities.SelfInfoActivity", check_element_id="com.pujitech.pujiejia:id/tv_title") print("点击用户手机号进入个人资料页面") # 点击用户手机号进入个人资料页面,并修改个人资料数据 unittest_TestResult = True except: unittest_TestResult = False finally: return unittest_TestResult
def ShengHuoPeiTao(driver): """ 首页实地派下生活配套模块, :return: None """ time.sleep(2) try: Public_Page.debug_NomalTest( driver, title="贝瑞母婴", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id="com.pujitech.pujiejia:id/tv_topic_row11", # Wait_Element = ".modules.usercenter.community.views.activities.PropertyPaymentHomeActivity", check_element_id="com.pujitech.pujiejia:id/tv_title", # TestCase = "物业缴费" ) time.sleep(2) Public_Page.debug_NomalTest( driver, title="海绵兴趣", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id="com.pujitech.pujiejia:id/tv_topic_row12", # Wait_Element = ".modules.h5.views.activitys.CommonH5Activity", check_element_id="com.pujitech.pujiejia:id/tv_title", # TestCase = "限时促销" ) time.sleep(2) Public_Page.debug_NomalTest( driver, title="家有健康", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id="com.pujitech.pujiejia:id/tv_topic_row13", # Wait_Element = ".modules.h5.views.activitys.CommonH5Activity", check_element_id="com.pujitech.pujiejia:id/tv_title", # TestCase = "精品团购" ) time.sleep(2) Public_Page.debug_NomalTest( driver, title="新用户专场", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id="com.pujitech.pujiejia:id/tv_topic_row21", # Wait_Element = ".modules.h5.views.activitys.CommonH5Activity", check_element_id="com.pujitech.pujiejia:id/tv_title", # TestCase = "精品团购" ) time.sleep(2) Public_Page.debug_NomalTest( driver, title="哈奇水果生鲜", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id="com.pujitech.pujiejia:id/tv_topic_row22", # Wait_Element = ".modules.h5.views.activitys.CommonH5Activity", check_element_id="com.pujitech.pujiejia:id/tv_title", # TestCase = "精品团购" ) time.sleep(2) Public_Page.debug_NomalTest( driver, title="哈奇家里购", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id="com.pujitech.pujiejia:id/tv_topic_row23", # Wait_Element = ".modules.h5.views.activitys.CommonH5Activity", check_element_id="com.pujitech.pujiejia:id/tv_title", # TestCase = "精品团购" ) except Exception as e: print("报错为", e) pass
def ClickMyOrder(driver): """ 进入我的订单页面,脚本执行完成后返回我家页面 :return: None """ try: """ 订单状态:配送中 待自提 已完成 已退款 已取消 待支付 待受理 已受理 """ orderstatus = [ '已退款', '已取消', '已完成', '配送中', '待自提', '待支付', '待受理', '已受理' ] for status in orderstatus: time.sleep(2) order = driver.find_elements_by_id( "com.pujitech.pujiejia:id/order_state") # 取所有订单状态 for i in order: if i.text == status: Public_Page.debug_NomalTest( driver, title="订单详情", MainWait_Element= ".modules.usercenter.order.views.activities.OrderListActivity", find_element_id=i, Wait_Element= ".modules.usercenter.order.views.activities.OrderDetailsActivity", check_element_id= "com.pujitech.pujiejia:id/tv_title", YESBack=False) Public_Page.debug_NomalTest( driver, title="订单状态跟踪", MainWait_Element= ".modules.usercenter.order.views.activities.OrderDetailsActivity", find_element_id= "com.pujitech.pujiejia:id/tv_more_status", Wait_Element= ".modules.usercenter.order.views.activities.OrderStatusActivity", check_element_id= "com.pujitech.pujiejia:id/tv_title", TestCase=status + "订单") time.sleep(1) driver.find_element_by_id( "com.pujitech.pujiejia:id/iv_back").click() break else: continue driver.find_element_by_id( "com.pujitech.pujiejia:id/iv_back").click() # 返回我家页面 unittest_TestResult = True except: driver.find_element_by_id( "com.pujitech.pujiejia:id/iv_back").click() # 返回我家页面 unittest_TestResult = False finally: return unittest_TestResult '''
def MyApplication(driver, AppName, wojia=False): """ 先决条件:进入我家页面 从我家页面进入需要带参数 wojia = True 这样取的activity就是我家页面的activity :return: None """ try: time.sleep(3) if wojia == True: MainActivity = ".modules.main.views.activities.MainActivity" driver.wait_activity("%s" % MainActivity, 30) time.sleep(1) else: MainActivity = ".modules.usercenter.allapp.views.activitys.AllApplicationActivity" driver.wait_activity("%s" % MainActivity, 30) time.sleep(1) Allname = driver.find_elements_by_id("com.pujitech.pujiejia:id/tv_app_name") noin = ["访客邀请"] for i in Allname: if i.text == AppName: if i.text in noin: i.click() try: Public_Page.NoHomeInThisBuilding(driver) # 在该小区没有认证房间 except: Public_Page.ExitBack(driver) break elif i.text == "智能家居": Public_Page.debug_NomalTest(driver, title="智能家居", # MainWait_Element = "%s"%MainActivity, MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id=i, Wait_Element="com.pujitech.atsmarthome.SipActivity", check_element_id="com.pujitech.pujiejia:id/tv_base_title", TestCase=i.text ) break elif i.text == "我的购物车": Public_Page.debug_NomalTest(driver, title=i.text, MainWait_Element="%s" % MainActivity, find_element_id=i, Wait_Element=".modules.shoppingcar.views.activities.MyShoppingCarActivity", check_element_id="com.pujitech.pujiejia:id/tv_title" ) break elif i.text == "我的报修": Public_Page.debug_NomalTest(driver, title=i.text, MainWait_Element="%s" % MainActivity, find_element_id=i, Wait_Element=".modules.complaint.views.activities.MyRoomRepairListActivity", check_element_id="com.pujitech.pujiejia:id/tv_title" ) break elif i.text == "房间绑定": Public_Page.debug_NomalTest(driver, title=i.text, MainWait_Element="%s" % MainActivity, find_element_id=i, Wait_Element=".modules.roombind.views.activitys.RoomBindActivity", check_element_id="com.pujitech.pujiejia:id/tv_title" ) break elif i.text == "社区服务": Public_Page.debug_NomalTest(driver, title=i.text, MainWait_Element="%s" % MainActivity, find_element_id=i, Wait_Element=".modules.usercenter.community.views.activities.CommunityHomeActivity", check_element_id="com.pujitech.pujiejia:id/tv_title" ) break elif i.text == "人脸识别": Public_Page.debug_NomalTest(driver, title=i.text, MainWait_Element="%s" % MainActivity, find_element_id=i, Wait_Element=".modules.facerecognition.views.activities.FaceRecognitionActivity", # Wait_Element = ".modules.facerecognition.views.activities.RecognitionProtocolActivity", check_element_id="com.pujitech.pujiejia:id/tv_title" ) break elif i.text == "商家收藏": Public_Page.debug_NomalTest(driver, title=i.text, MainWait_Element="%s" % MainActivity, find_element_id=i, Wait_Element=".modules.usercenter.collection.views.activities.CollectionActivity", check_element_id="com.pujitech.pujiejia:id/tv_title" ) break elif i.text == "约车记录": Public_Page.debug_NomalTest(driver, title=i.text, MainWait_Element="%s" % MainActivity, find_element_id=i, Wait_Element=".modules.community_bus.views.CarOrderRecordListActivity", check_element_id="com.pujitech.pujiejia:id/tv_title" ) break elif i.text == "我的家书" or i.text == "我的关注" or i.text == "我的活动" or i.text == "我的评价" or i.text == "我的帖子": Public_Page.debug_NomalTest(driver, title=i.text, MainWait_Element="%s" % MainActivity, find_element_id=i, Wait_Element=".modules.h5.views.activitys.CommonH5Activity", # Wait_Element= None, check_element_id="com.pujitech.pujiejia:id/tv_title" ) break unittest_TestResult = True except: unittest_TestResult = False finally: return unittest_TestResult