def Application_Guide(driver): try: time.sleep(5) with allure.step('点击合格投资者认证申请须知'): Page.wait_elem(driver, "com.chtwm.mall:id/tv_tip", 27, 3).click() time.sleep(5) with allure.step('下滑查看合格投资者须知内容'): huadong.shanghua(driver, 1000) time.sleep(3) with allure.step("合格投资者认证须知页面截图"): allure.attach(driver.get_screenshot_as_png(), "合格投资者认证须知截图", attachment_type=allure.attachment_type.PNG) time.sleep(3) with allure.step("返回合格投资者认证页面"): Page.wait_elem(driver, "com.chtwm.mall:id/iv_back", 18, 3).click() pytest_TestResult = True except Exception as e: print("合格投资者认证申请须知页面报错:", e) pytest_TestResult = False finally: return pytest_TestResult
def XiaLaPage(driver): """ 下滑页面以显示推荐楼盘 :return: None """ time.sleep(2) huadong.shanghua(driver, 300)
def AllFund(driver): try: with allure.step("通过基金名称查看基金"): time.sleep(5) print("开始进入基金内部") pr_names = driver.find_elements_by_id( "com.chtwm.mall:id/pr_name") #层级往下定位 for i in pr_names: i.click() time.sleep(3) driver.back() time.sleep(2) for i in range(0, 2): with allure.step('下滑查看下页三条数据'): time.sleep(3) huadong.shanghua(driver, 1000) #下滑页面 pr_names = driver.find_elements_by_id( "com.chtwm.mall:id/pr_name") #层级往下定位 for i in pr_names: i.click() time.sleep(3) huadong.shanghua(driver, 300) time.sleep(2) driver.back() time.sleep(2) except Exception as e: print("查看全部基金报错:", e)
def GMGroup(driver): try: with allure.step('公募组合→查看组合投资方案'): time.sleep(3) Listelements = driver.find_elements_by_xpath("//*") #层级往下定位 for i in Listelements: i.click() time.sleep(3) huadong.shanghua(driver, 500) time.sleep(2) huadong.shanghua(driver, 500) time.sleep(2) driver.back() driver.back() #回到首页 pytest_TestResult = True except Exception as e: print("进入查看组合投资方案报错:", e) pytest_TestResult = False driver.back() finally: return pytest_TestResult
def ZQCategory(driver, Category): try: with allure.step('点击分类列表'): time.sleep(2) Page.find_elem_id(driver, "com.chtwm.mall:id/right_images").click() with allure.step("%s" % Category): time.sleep(3) names = driver.find_elements_by_id("com.chtwm.mall:id/text_aa") for i in names: if i.text == "%s" % Category: i.click() Page.wait_elem(driver, "com.chtwm.mall:id/filter_true", 10).click() #点击确定 with allure.step("滑动查看详情"): time.sleep(3) huadong.shanghua(driver, 1000) time.sleep(8) huadong.shanghua(driver, 1000) time.sleep(8) except Exception as e: print("债权条件筛选报错:", e) #pytest_TestResult = False #driver.back() finally: pass
def XiaLaPage(driver, num): """ 下滑页面以显示推荐楼盘 :return: None """ time.sleep(2) huadong.shanghua(driver, num) # 数字越大滑动距离越小
def Tuijian_Loupan(driver): """ 实地派页面中的文字推荐楼盘 :return: None """ tuijianbuild = [ "广州常春藤", "无锡玫瑰庄园", "武汉君兰汀岸", "广州蔷薇国际", "天津海棠雅著", "惠州常春藤" ] try: time.sleep(2) huadong.shanghua(driver, 1000) for case in tuijianbuild: lpan = driver.find_elements_by_id( "com.pujitech.pujiejia:id/tv_community_name") for target in lpan: if target.text == case: target.click() ShiDiPai.tuijianloupan(driver, case) break # 点完了就跳出循环,否则会再次找寻case内容导致报错 except Exception as e: print("点击文字推荐楼盘报错信息为:", e) pass
def grid_item(driver, title): try: with allure.step('查看%s'%title): time.sleep(3) elems = driver.find_elements_by_id("com.chtwm.mall:id/grid_item_title") for i in elems: if i.text == title: i.click() time.sleep(3) huadong.shanghua(driver, 600) time.sleep(3) with allure.step('%s界面截图'%title): allure.attach(driver.get_screenshot_as_png(),'%s界面截图'%title,attachment_type=allure.attachment_type.PNG) pytest_TestResult = True break time.sleep(3) driver.back() except Exception as e: print("活动资讯报错:", e) pytest_TestResult = False finally: return pytest_TestResult
def GongMuAssetProve(driver): try: with allure.step('点击申请公募资产证明'): time.sleep(3) Page.wait_elem(driver, "com.chtwm.mall:id/gm_apply", 8).click() with allure.step('选择起始时间'): time.sleep(2) Page.find_elem_id( driver, "com.chtwm.mall:id/start_data_select").click() time.sleep(2) Page.find_elem_id(driver, "com.chtwm.mall:id/btnSubmit").click() with allure.step('选择结束时间'): time.sleep(2) Page.find_elem_id( driver, "com.chtwm.mall:id/finish_data_select").click() time.sleep(2) Page.find_elem_id(driver, "com.chtwm.mall:id/btnSubmit").click() with allure.step('点击提交申请'): time.sleep(2) Page.find_elem_id(driver, "com.chtwm.mall:id/submit_apply").click() with allure.step('点击下载,下载资产证明到手机'): time.sleep(15) Page.find_elem_id(driver, "com.chtwm.mall:id/right_text").click() try: with allure.step('资产证明发送到默认邮箱,点击确定'): time.sleep(2) Page.find_elem_id( driver, "com.chtwm.mall:id/tv_confirm").click() time.sleep(3) except: pass with allure.step("公募资产证明页面截图"): time.sleep(2) allure.attach(driver.get_screenshot_as_png(), '%s' % PrtScPath, attachment_type=allure.attachment_type.PNG) with allure.step("上滑查看公募资产证明下一页"): huadong.shanghua(driver, 500) with allure.step("返回上一页面"): driver.back() pytest_TestResult = True except Exception as e: print("查看%s报错:" % "公募" + title, e) pytest_TestResult = False finally: return pytest_TestResult
def LookGoods(driver): try: driver.implicitly_wait(10) #print ("开始执行用例8....商品详情页面,滑动查看商品内容") time.sleep(3) #c = (driver.page_source).encode("gbk", 'ignore').decode("gbk", "ignore") #print(c) contexts = driver.contexts #print("contexts全部上下文", contexts) # try: driver.switch_to.context('NATIVE_APP') except: pass print("当前上下文current_context", driver.current_context) print("contexts全部上下文", contexts) for i in range(1, 14): #print ("第",i,"次滑动") time.sleep(1) huadong.shanghua(driver, 500) for i in range(1, 8): time.sleep(1) huadong.xiahua(driver, 250) unittest_TestResult = True except Exception as e: print("Case008查看商品详情报错信息为:", e) unittest_TestResult = False finally: return unittest_TestResult
def ApplyProInvestors(driver): try: with allure.step('上滑屏幕显示出申请转为专业投资者按钮'): time.sleep(5) huadong.shanghua(driver, 1000) with allure.step('点击申请转为专业投资者'): Page.wait_elem(driver, "com.chtwm.mall:id/zt_tv", 10).click() with allure.step('%s检查点截图' % title): time.sleep(2) allure.attach(driver.get_screenshot_as_png(), '%s' % PrtScPath, attachment_type=allure.attachment_type.PNG) #添加检查点截图,PrtScPath为图片位置 with allure.step('确认普转专申请书'): Page.wait_elem(driver, "com.chtwm.mall:id/tv_confirm", 5).click() except Exception as e: print("%s报错:" % title, e) allure.attach("检查点%s报错:" % title, str(e), str(type(e))) with allure.step('用例失败%s检查点截图' % title): time.sleep(2) allure.attach(driver.get_screenshot_as_png(), '%s' % PrtScPath, attachment_type=allure.attachment_type.PNG)
def FuWuXieYi_CheckPoint(driver): time.sleep(8) with allure.step('上滑查看服务协议内容'): huadong.shanghua(driver, 800) time.sleep(1) with allure.step('左滑查看页面是否偏移'): huadong.zuohua(driver, 1000) with allure.step('添加检查点截图'): allure.attach(driver.get_screenshot_as_png(), '%s' % PrtScPath, attachment_type=allure.attachment_type.PNG) pytest_TestResult = True return pytest_TestResult
def Prod_HP_JingXuanGM(driver): try: with allure.step('首页→上滑,显示公募推荐'): time.sleep(8) huadong.shanghua(driver, 5300) time.sleep(3) with allure.step('查看公募推荐'): try: GM = driver.find_elements_by_id( "com.chtwm.mall:id/item_title_tv") #获取所有公募元素 #查看公募推荐1 time.sleep(3) GM[0].click() time.sleep(8) with allure.step('公募推荐1界面截图'): allure.attach( driver.get_screenshot_as_png(), '公募推荐1界面截图', attachment_type=allure.attachment_type.PNG) #添加检查点截图,PrtScPath为图片位置 driver.back() #查看公募推荐2 time.sleep(3) GM2 = driver.find_elements_by_id( "com.chtwm.mall:id/item_title_tv") #获取所有公募元素 GM2[1].click() time.sleep(8) with allure.step('公募推荐2界面截图'): allure.attach( driver.get_screenshot_as_png(), '公募推荐2界面截图', attachment_type=allure.attachment_type.PNG) #添加检查点截图,PrtScPath为图片位置 driver.back() except: pass pytest_TestResult = True except Exception as e: print("进入公募推荐报错:", e) pytest_TestResult = False finally: return pytest_TestResult
def More_Building(driver): """ 点击更多楼盘,进入精品楼盘页面查看 原来是原生的精品楼盘页面变为H5...无法进行定位 :return: None """ time.sleep(3) huadong.shanghua(driver, 800) lpmoredict = { "广州常春藤": "广州常春藤 23000元/m² 广东广州黄埔区禾丰路与永和大道交汇处 智慧社区 优质学府 全能配套 百万大城", "无锡玫瑰庄园": "无锡玫瑰庄园 8000元/m² 江苏无锡惠山区中惠大道与曙光南路交汇处 地铁口 价格洼地 高铁旁", "武汉君兰汀岸": "武汉君兰汀岸 17000元/m² 湖北武汉汉阳区经济技术开发区小军山大道19号", "广州蔷薇国际": "广州蔷薇国际 20000元/m² 广东广州增城区荔城街实地蔷薇国际 智能社区 叠水园林 品质大盘 地铁沿线", "惠州常春藤": "惠州常春藤 价格待定 广东惠州惠阳区惠南大道旁 轻轨学府", "天津海棠雅著": "天津海棠雅著 9300元/m² 天津天津宝坻区津蓟高速温泉城出口西侧500米 品质大盘 全龄配套 智能大盘 低密度" } try: # driver.find_elements_by_id("com.pujitech.pujiejia:id/ll_more_community").click() print("测试点击更多楼盘11111111111111111") driver.find_element_by_android_uiautomator( 'new UiSelector().text("更多楼盘")').click() driver.wait_activity( ".modules.h5.views.activitys.CommonH5Activity", 30) time.sleep(3) ''' for (name, element) in lpmoredict.items(): try: driver.find_element_by_accessibility_id("%s" % element).click() ShiDiPai.tuijianloupan(driver, name) except Exception as e: print("精品楼盘点击楼盘详情报错:", e) print("测试进入%s楼盘用例失败............Failed" % name) time.sleep(3) ''' title = driver.find_element_by_id( "com.pujitech.pujiejia:id/tv_title") if title.text == "精品楼盘": driver.back() else: print("检测到该页面标题与测试点不符......请查看当前为%s的测试点标题......" % title.text) driver.back() print("首页测试结束...") except Exception as e: print("进入精品楼盘报错为:", e) pass
def Qitainvest(driver): try: with allure.step('切换到其他投资列表'): time.sleep(3) #input("开始切换到证券投资") tv_tab_title = driver.find_elements_by_id( "com.chtwm.mall:id/tv_tab_title") for i in tv_tab_title: if i.text == "其他": i.click() break with allure.step('点击其他进入产品详情'): time.sleep(2) pr_names = driver.find_elements_by_id( "com.chtwm.mall:id/pr_name") #层级往下定位 for i in pr_names: i.click() time.sleep(3) driver.back() time.sleep(2) for i in range(0, 3): with allure.step('下滑查看下页三条数据'): time.sleep(3) huadong.shanghua(driver, 500) #下滑页面 pr_names = driver.find_elements_by_id( "com.chtwm.mall:id/pr_name") #层级往下定位 for i in pr_names: i.click() time.sleep(3) huadong.shanghua(driver, 300) time.sleep(2) driver.back() time.sleep(2) pytest_TestResult = True except Exception as e: print("其他投资报错:", e) pytest_TestResult = False driver.back() finally: return pytest_TestResult
def Into_SMTuiJian(driver): try: with allure.step('首页→上滑,显示私募推荐'): time.sleep(10) huadong.shanghua(driver, 2850) time.sleep(3) with allure.step('进入私募推荐内容'): elems = driver.find_elements_by_id("com.chtwm.mall:id/item_title_name") try: time.sleep(3) elems[0].click() time.sleep(3) huadong.shanghua(driver,500) time.sleep(3) driver.back() time.sleep(3) except Exception as e: print ("elems[0]报错:",e) elems = driver.find_elements_by_id("com.chtwm.mall:id/item_title_name") try: time.sleep(3) elems[1].click() time.sleep(3) huadong.shanghua(driver,500) time.sleep(3) driver.back() time.sleep(3) except Exception as e: print ("elems[1]报错:",e) elems = driver.find_elements_by_id("com.chtwm.mall:id/item_title_name") try: time.sleep(3) elems[2].click() time.sleep(3) huadong.shanghua(driver,500) time.sleep(3) driver.back() time.sleep(3) except Exception as e: print ("elems[2]报错:",e) pytest_TestResult = True except Exception as e: print("进入私募推荐报错:", e) pytest_TestResult = False finally: return pytest_TestResult
def Into_GMTuiJian(driver): try: with allure.step('首页→上滑,显示公募推荐'): time.sleep(8) huadong.shanghua(driver, 5300) time.sleep(3) with allure.step('查看公募推荐'): Page.find_elem_id(driver, "com.chtwm.mall:id/item_tv").click() time.sleep(3) driver.back() pytest_TestResult = True except Exception as e: print("进入公募推荐报错:", e) pytest_TestResult = False finally: return pytest_TestResult
def Basic_Information_CheckPoint(driver): time.sleep(2) with allure.step('验证标题是否为%s' % title): check = Page.find_elem_id(driver, "com.chtwm.mall:id/tv_title") with allure.step('添加基本信息检查点截图_第一页'): allure.attach(driver.get_screenshot_as_png(), '%s_1' % PrtScPath, attachment_type=allure.attachment_type.PNG) #添加检查点截图,PrtScPath为图片位置 huadong.shanghua(driver, 500) with allure.step('添加基本信息检查点截图_第二页'): allure.attach(driver.get_screenshot_as_png(), '%s_2' % PrtScPath, attachment_type=allure.attachment_type.PNG) #添加检查点截图,PrtScPath为图片位置 if check.text == title: pytest_TestResult = True else: pytest_TestResult = False return pytest_TestResult
def MarketImg(driver): try: with allure.step('首页→上滑,显示活动资讯'): time.sleep(3) huadong.shanghua(driver, 10000) time.sleep(3) with allure.step('查看活动资讯'): Page.find_elem_id(driver,"com.chtwm.mall:id/item_market_img").click() time.sleep(3) driver.back() pytest_TestResult = True except Exception as e: print("活动资讯报错:", e) pytest_TestResult = False finally: return pytest_TestResult
def bottom(driver): try: with allure.step('首页→上滑,显示底部'): time.sleep(10) huadong.shanghua(driver, 600) time.sleep(2) huadong.shanghua(driver, 600) time.sleep(2) huadong.shanghua(driver, 600) time.sleep(2) huadong.shanghua(driver, 600) except Exception as e: print("显示底部报错:", e)
def Community_Image(driver): """ 点击主要推荐的大图片楼盘iv_community_image :return: None """ time.sleep(2) case = "图片广告广州常春藤楼盘" try: driver.find_element_by_id( "com.pujitech.pujiejia:id/iv_community_image").click() # 滑动查看常春藤 time.sleep(2) huadong.shanghua(driver, 300) time.sleep(2) huadong.shanghua(driver, 300) driver.back() print("测试点击%s用例Passed............成功" % case) except: print("测试点击%s用例失败............Failed" % case) time.sleep(2)
def Zhaiquaninvest(driver): try: with allure.step('点击债权名称进入产品详情'): time.sleep(3) pr_names = driver.find_elements_by_id( "com.chtwm.mall:id/pr_name") #层级往下定位 for i in pr_names: i.click() time.sleep(3) driver.back() time.sleep(2) for i in range(0, 5): with allure.step('下滑查看下页三条数据'): time.sleep(3) huadong.shanghua(driver, 500) #下滑页面 pr_names = driver.find_elements_by_id( "com.chtwm.mall:id/pr_name") #层级往下定位 for i in pr_names: i.click() time.sleep(3) huadong.shanghua(driver, 300) time.sleep(2) driver.back() time.sleep(2) pytest_TestResult = True except Exception as e: print("债权投资报错:", e) pytest_TestResult = False driver.back() finally: return pytest_TestResult
def IntoPurse(driver): """ 先决条件:进入我家页面 :return: None """ # 测试点击我的钱包进入我的钱包页面 Public_Page.NomalTest(driver, title="我的钱包", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id="com.pujitech.pujiejia:id/tv_user_wallet", Wait_Element=".modules.wallet.views.activitys.MyWalletActivity", check_element_id="com.pujitech.pujiejia:id/tv_title") # 测试点击我的钱包额度进入我的钱包页面 Public_Page.NomalTest(driver, title="我的钱包", MainWait_Element=".modules.main.views.activities.MainActivity", find_element_id="com.pujitech.pujiejia:id/tv_wallet", Wait_Element=".modules.wallet.views.activitys.MyWalletActivity", check_element_id="com.pujitech.pujiejia:id/tv_title", YESBack=False) # 点击余额说明 Public_Page.NomalTest(driver, title="余额说明", MainWait_Element=".modules.wallet.views.activitys.MyWalletActivity", find_element_id="com.pujitech.pujiejia:id/my_wallet_yue_shuoming_tv", Wait_Element=".modules.help.view.activities.HelpActivity", check_element_id="com.pujitech.pujiejia:id/tv_title") # 点击去充值 Public_Page.NomalTest(driver, title="余额充值", MainWait_Element=".modules.wallet.views.activitys.MyWalletActivity", find_element_id="com.pujitech.pujiejia:id/my_wallet_qu_chongzhi_btn", Wait_Element=".modules.wallet.views.activitys.MyWalletYuEChongzhiActivity", check_element_id="com.pujitech.pujiejia:id/tv_title") # 下滑查看余额明细 driver.wait_activity(".modules.wallet.views.activitys.MyWalletActivity", 30) time.sleep(2) driver.swipe(500, 1700, 500, 1000) time.sleep(2) driver.swipe(500, 1700, 500, 1000) # 点击更多明细(并下滑查看数据) Public_Page.NomalTest(driver, title="更多明细", MainWait_Element=".modules.wallet.views.activitys.MyWalletActivity", find_element_id="com.pujitech.pujiejia:id/my_wallet_more_mingxi_tv", Wait_Element=".modules.wallet.views.activitys.MyWalletMoreMingxiActivity", check_element_id="com.pujitech.pujiejia:id/tv_title", YESBack=False) huadong.shanghua(driver, 1000) time.sleep(3) huadong.shanghua(driver, 1000) time.sleep(3) huadong.shanghua(driver, 1000) time.sleep(3) driver.find_element_by_id("com.pujitech.pujiejia:id/iv_back").click() # 退回到我的钱包页面 time.sleep(2) driver.find_element_by_id("com.pujitech.pujiejia:id/iv_back").click()
def LC_GMTuiJian(driver): try: with allure.step('理财→上滑,显示公募推荐'): time.sleep(8) huadong.shanghua(driver, 300) time.sleep(3) with allure.step('查看智慧盈公募'): Page.wait_elem(driver, "com.chtwm.mall:id/type_three_ll", 18, 3).click() time.sleep(8) huadong.shanghua(driver, 300) time.sleep(3) huadong.shanghua(driver, 300) time.sleep(3) driver.back() with allure.step("查看稳鑫盈公募"): time.sleep(8) elms2 = driver.find_elements_by_id( "com.chtwm.mall:id/item_ha_than_tv") for i in elms2: if i.text == "稳鑫盈": i.click() time.sleep(8) huadong.shanghua(driver, 300) time.sleep(3) huadong.shanghua(driver, 300) time.sleep(3) driver.back() pytest_TestResult = True except Exception as e: print("查看公募推荐模块报错:", e) pytest_TestResult = False finally: return pytest_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 tuijianloupan(driver, case): # 点击每个推荐楼盘 time.sleep(3) try: # 向上滑动查看页面 driver.wait_activity( ".modules.h5.views.activitys.CommonH5Activity", 30) time.sleep(2) huadong.shanghua(driver, 500) time.sleep(2) huadong.shanghua(driver, 500) time.sleep(2) huadong.xiahua(driver, 500) time.sleep(2) huadong.xiahua(driver, 500) driver.find_element_by_id( "com.pujitech.pujiejia:id/iv_back").click() print("测试进入%s楼盘用例Passed............成功" % case) except Exception as e: print("测试进入%s楼盘用例失败............Failed" % case) print("报错信息为:", e) time.sleep(2) pass
def IntoShiDiDaZaoShi(driver): # 从微信进入到实地打造师小程序中 try: driver.wait_activity(".ui.LauncherUI", 30) dibu = driver.find_elements_by_id("com.tencent.mm:id/dkb") for i in dibu: # print ("i的text为",i.text) if i.text == "发现": i.click() break # time.sleep(2) driver.wait_activity(".ui.LauncherUI", 30) xcx = driver.find_elements_by_id("android:id/title") for i in xcx: if i.text == "小程序": i.click() break time.sleep(2) # print(driver.context) # ac = driver.current_activity # print (ac) driver.wait_activity(".plugin.appbrand.ui.AppBrandLauncherUI", 30) time.sleep(2) shidi = driver.find_elements_by_id("com.tencent.mm:id/cg") for i in shidi: if i.text == "实地打造师": i.click() break # com.tencent.mm:id/cg # ac = driver.current_activity # print("实地打造师",ac) driver.wait_activity(".plugin.appbrand.ui.AppBrandUI", 30) # ac = driver.current_activity # print("实地打造师",ac) # contexts = driver.contexts # print("contexts全部上下文",contexts) # print ("############################################") # print("进入小程序后查看上下文",driver.context) # print("切换以后查看", driver.context) # time.sleep(5) # print(driver.page_source) #滑动查看商品列表是否正常显示,以后如果报错拆分成两个脚本 for i in range(1,14): #print ("第",i,"次滑动") time.sleep(1) huadong.shanghua(driver,500) for i in range(1,8): time.sleep(1) huadong.xiahua(driver,250) # driver.switch_to.context('WEBVIEW_com.tencent.mm:appbrand2') # driver.switch_to.context('WEBVIEW_com.tencent.mm') # driver.switch_to.context('WEBVIEW_com.tencent.mm:appbrand0') #这里切换上下文 time.sleep(3) try: driver.switch_to.context('WEBVIEW_com.tencent.mm:appbrand0') except: time.sleep(3) driver.switch_to.context('WEBVIEW_com.tencent.mm:appbrand0') pass # print('切换成功') # print("当前上下文current_context", driver.current_context) # print("*****************************************") #print ("selenium获取全部handles和needhandle") time.sleep(5) all_handles = driver.window_handles # print("all_handles所有句柄为:", all_handles) # time.sleep(2) needhandle = driver.current_window_handle # print("needhandle,", needhandle) time.sleep(3) #debug:这块偶尔会报错,以后优化一下 for i in all_handles: if i != needhandle: #driver.switch_to_window(i) driver.switch_to.window(i) # print(i) break # print("切换以后查看", driver.context) # print(driver.page_source) # print("测试点击网页") time.sleep(3) driver.find_element_by_xpath("//*[@id=\"63\"]/wx-text/span[2]").click() #点击家私然后再点击家电验证是否进入了页面 time.sleep(3) driver.find_element_by_xpath("//*[@id=\"62\"]/wx-text/span[2]").click() unittest_TestResult = True except Exception as e: print("进入实地打造师报错信息==========:", e) unittest_TestResult = False finally: return unittest_TestResult
def P03_qiehuanloupan(driver): #尝试关闭版本更新 try: time.sleep(2) driver.find_element_by_id( "com.pujitech.pujiejia:id/tv_cancel").click() except Exception as e: print("不需要取消更新") pass try: time.sleep(5) huadong.shanghua(driver, 1000) #下滑页面 time.sleep(1) #点击实地派 driver.find_element_by_android_uiautomator( 'new UiSelector().className("android.widget.TextView").text("实地派")' ).click() time.sleep(1) driver.find_element_by_id( "com.pujitech.pujiejia:id/rl_building_name_container").click() #com.pujitech.pujiejia:id/rl_building_name_container #com.pujitech.pujiejia:id/tv_building_name #com.pujitech.pujiejia:id/bg_building #进入选择楼盘 ###ct = driver.contexts ###print (ct) #查看上下文 ###driver.switch_to.context('WEBVIEW_com.pujitech.pujiejia') #driver.switch_to.context('WEBVIEW_com.pujitech.pujiejia:pushcore') ''' ###下看在哪个activity current = driver.current_activity print(current) ###下获取当前页面代码 page = driver.page_source print (page) ''' #点击其他楼盘名称 time.sleep(3) #case1__android_uiautomator:遵义·遵义蔷薇国际 #driver.find_element_by_android_uiautomator('new UiSelector().className("android.widget.TextView").text("遵义·遵义蔷薇国际")').click() #case2__textContains("View") #driver.find_element_by_android_uiautomator('new UiSelector().textContains("中山璟湖城")').click() #case3__xpath #driver.find_element_by_xpath("//android.widget.TextView[contains(@text='中山璟湖城')]").click() #case4__text(\"中山璟湖城\") #driver.find_element_by_android_uiautomator('new UiSelector().text(\"中山璟湖城\")').click() #case5__index #driver.find_element_by_android_uiautomator('new UiSelector().index(\"4\")').click() #case6__.clickable(true).index("4") #driver.find_element_by_android_uiautomator('new UiSelector().clickable(true).index("4")').click() #case7__elements _accessibility_id #dondake = driver.find_elements_by_accessibility_id("com.pujitech.pujiejia:id/tv_city") #case8__elements _classname #dondake = driver.find_elements_by_class_name("android.widget.RelativeLayout") #print (dondake) #dondake.pop(0).click() #case9__elements _classname__ #dondake = driver.find_elements_by_class_name("android.widget.TextView") #print (dondake) #dondake.pop(0).click() #case10__直接tap 这个可以点,输入要点击小区的坐标 #driver.tap([(0,729), (1080,856)], 500) #中山 driver.tap([(0, 221), (1080, 348)], 500) #测试 except Exception as e: print(e) pass
def UploadZiChanProve(driver): try: with allure.step('切换到上传资产证明页面'): time.sleep(5) Page.wait_elem(driver, "com.chtwm.mall:id/tv_tab_02", 10, 2).click() with allure.step('上滑显示页面'): time.sleep(3) huadong.shanghua(driver, 1800) with allure.step('尝试删除之前上传过的照片记录'): time.sleep(3) try: for i in range(4): #尝试删除4次之前上传的图片 Page.wait_elem(driver, "com.chtwm.mall:id/iv_del", 5).click() print("删除之前上传过的照片成功") allure.attach("删除之前上传过的照片成功") except: print("删除之前上传过的照片失败") allure.attach("删除之前上传过的照片失败") pass with allure.step('点击+,上传图片'): try: time.sleep(2) Page.wait_elem(driver, "com.chtwm.mall:id/rl_upload_img", 6).click() #点击大图上传图片 except: Page.wait_elem(driver, "com.chtwm.mall:id/iv_add_img", 10).click() ##点击小加号上传图片 ''' with allure.step('点击相机,上传拍摄的照片'): time.sleep(2) Page.wait_elem(driver,"com.chtwm.mall:id/camera_tv", 5).click() with allure.step('点击相册,上传相册中的照片'): time.sleep(2) Page.wait_elem(driver,"com.chtwm.mall:id/photo_tv", 5).click() with allure.step('点击相册,上传相册中的照片'): time.sleep(2) Page.wait_elem(driver,"com.chtwm.mall:id/photo_tv", 5).click() ''' with allure.step('选择一张照片'): time.sleep(5) photos = driver.find_elements_by_id( "com.chtwm.mall:id/v_selected")[0] #取第一张照片 photos.click() with allure.step('点击右上方,完成按钮'): time.sleep(3) Page.wait_elem(driver, "com.chtwm.mall:id/done", 5).click() #立即申请后会弹出短信验证框 with allure.step('点击下方立即申请按钮'): time.sleep(3) Page.wait_elem(driver, "com.chtwm.mall:id/bt_suction_bottom", 5).click() time.sleep(5) with allure.step('输入短信验证码,点击确认'): time.sleep(3) Page.wait_elem(driver, "com.chtwm.mall:id/et_input_code", 5).send_keys("753698") time.sleep(3) #Page.find_elem_id(driver,"com.chtwm.mall:id/tv_confirm").click() #暂不提交TANUKIdondake time.sleep(3) pytest_TestResult = True except Exception as e: #print("%s报错:"%title, e) allure.attach("%s报错:%s%s" % (title, str(e), str(type(e)))) pytest_TestResult = False finally: return pytest_TestResult
def ShowPage2(driver): time.sleep(2) with allure.step('我的页面上滑,显示交易明细等其他'): huadong.shanghua(driver,500)