def test_ChapterEdit(storyName): """编写小说""" myChapterEdit = ChapterEdit() actualValue = myChapterEdit.process_creationStoryFlow(storyName) assert_equal(actualValue, True, "创作小说{0}".format(myChapterEdit.ChapterEdit_info)) sleep(5)
def test_discoverPopup(): """大厅弹框""" myDiscover = Discover() actualValue = myDiscover.discoverPopup() assert_equal(True, actualValue, "大厅弹框列表{0}".format(myDiscover.discoverPopup_info)) sleep(3)
def test_nameedit(name): """编辑名字""" myProfilemodule = Profilemodule() actualValue = myProfilemodule.nameedit(name=name) assert_equal( actualValue, True, "编辑名字{0}".format( (myProfilemodule.Profilemodule_info["name"])))
def test_showAchievement(): """成就展示""" myProfilemodule = Profilemodule() actualValue = myProfilemodule.Change_showAchievement() assert_equal( actualValue, True, "成就展示变更的名字{0}".format(myProfilemodule.Profilemodule_info["name"]))
def test_operationAchievement(): """对成就进行操作""" myAchievementmodule = Achievementmodule() actualValue = myAchievementmodule.operationAchievememt() assert_equal( True, True, "进行操作的成就名字{0}".format( myAchievementmodule.Achievementmodule_info["name"]))
def test_ChangeUseremoticons(expression): """更换背景角色表情""" myProfilemodule = Profilemodule() actualValue = myProfilemodule.ChangeUseremoticons(expression) assert_equal( actualValue, True, "更换角色的表情{0}".format( (myProfilemodule.Profilemodule_info["emoticons"])))
def test_ReadUGCBook(time=2): """短信小说阅读""" myReadUGCBook = ReadUGCBook() myReadUGCBook.click_Read() actualValue = myReadUGCBook.bookRead(time) assert_equal(actualValue, True, "短信小说阅读{0}".format(myReadUGCBook.ReadUGCBook_info))
def test_bookload(BookID=None): """书籍加载""" myBookLoad = BookLoad() actualValue = myBookLoad.bookLoad(BookID) assert_equal(actualValue, True, "书籍loading{0}".format(myBookLoad.BookLoad_info)) sleep(3)
def setting_page_instance(self): """ 链式调用 :return:page实例,可以重复操作实例方法 """ assert_equal("setting_page_instance", "setting_page_instance", "断言setting_page_instance") return self
def test_bookchoose(bookShelf, index): """找书""" bookdetail = BookNewDetail() bookdetail.bookChoose(bookShelf=bookShelf, index=index) # actualValue = bookdetail.getBookNewDetail_info() assert_equal(True, True, "视觉小说书籍选择{0}".format(bookdetail.BookNewDetail_info))
def test_signin(login="******", email="15019423971", password="******"): """用户绑定""" SignIn1 = SignIn() actualValuSignIne = SignIn1.process_profilelogin() SignIn1.issign() # 判断用户登陆情况 assert_equal(True, actualValuSignIne, "用户绑定{0}".format(SignIn1.SignIn_info)) sleep(3)
def test_Creation(): """创建书籍""" Community1 = Community() actualValueinto_workshop = Community1.into_workshop() assert_equal(actualValueinto_workshop, True, "进入工作室{0}") Creation1 = Creation() isCreation = Creation1.process_createNewBook() assert_equal(isCreation, True, "创建书籍")
def assert_equal(self, first, second, msg=""): ''' 断言相等 :param first:第一个 :param last:第二个 :param msg:信息 :return: ''' assert_equal(first, second, msg)
def assert_equal(self, first, second, msg=""): """ 断言相等 :param first: anything :param second: anything :param msg:断言的描述 :return: """ assert_equal(first, second, msg)
def test_bookread(BookID=None): """读书""" # if BookID == None: # BookID == MyData.UserData_dir["bookDetailInfo"]["BookID"] # else: # MyData.UserData_dir["bookDetailInfo"]["BookID"] = BookID # print(MyData.UserData_dir["bookDetailInfo"]) # print(MyData.UserData_dir["bookDetailInfo"]["BookID"]) myVisual = BookRead() actualValue = myVisual.bookRead(BookID) assert_equal(actualValue, True, "阅读详情{0}".format(myVisual.ReadBook_info)) sleep(5)
def go_single_live(self): """ 开启普通直播 :return: """ # 去准备直播页面并设置标题 self.go_pre_live_page_and_set_title() # 点击开播按钮开启普通直播 self.pre_live_page.click_go_live().snap("已经进入直播间") # 判断是否开播成功 assert_equal(self.live_page.in_current_page(), True, "开播失败") # 关闭直播 self.live_page.close_live_anchor return self
def test_startgame(login): """启动游戏""" myGameStart = GameStart() myGameStart.stopGame() sleep(1) myGameStart.starGame() # assert_equal(myGameStart.isStarGame, True, "启动游戏{0}".format(myGameStart.GameStart_info)) myGameLoaded = GameLoaded() actualValue = myGameLoaded.mainprocess(login=login) if float(myGameLoaded.GameLoaded_info["loadtime"]) > 50: log(Exception("load游戏时间大于30s!加载时间为:{0}".format( myGameLoaded.GameLoaded_info["loadtime"])), snapshot=True) assert_equal(actualValue, True, "启动游戏{0}".format(myGameLoaded.GameLoaded_info)) sleep(3)
def goods_add_shopping_cart(poco): poco("com.caibaopay.cashier:id/fl_right").wait_for_appearance(10) poco(text="海天 蒸鱼鼓油 450ml").click() poco(text="红玫瑰苹果").click() poco("com.caibaopay.cashier:id/rl_product").swipe([0.0337, -0.5722]) poco("com.caibaopay.cashier:id/rl_product").swipe([0.0202, -0.4884]) poco(text="烟台苹果 箱").click() poco(text="秋香苹果").click() assert_equal(poco("com.caibaopay.cashier:id/fl_left").child("android.widget.FrameLayout").offspring( "com.caibaopay.cashier:id/rv_product").child("com.caibaopay.cashier:id/ll_container")[0].offspring( "com.caibaopay.cashier:id/tv_order_number").get_text(), "4", "购物车加购成功")
def go_pre_live_page_and_set_title(self): """ 去准备直播页面名并设置直播标题 :return: """ # 判断首页开播按钮是否存在 assert_equal(self.home_page.up_live_icon_is_exists(), True, "home页开播按钮不存在") # 点击直播按钮进入准备直播页面 self.home_page.goto_prepare_live_page().snap("进入准备直播页面") sleep(2) # 判断开播按钮是否存在 assert_equal(self.pre_live_page.in_current_page(), True, "准备直播页面开播按钮不存在") # 设置开播标题 self.pre_live_page.click_live_title().set_live_title() return self
def goto_network_ping(self): """ ping网络检测 -> Network Diagnosis :return: """ self.poco(text=self.page_ele_loc("TEXT_NETWORK_DIAGNOSIS")).click() try: assert_equal(self.poco(text="Upload diagnosis report").exists(), True, msg='Upload diagnosis report 按钮出现') log('网络检测页面截图', timestamp=time.time(), desc='网络检测页面截图', snapshot=True) except AssertionError as e: log(e, timestamp=time.time(), desc='Upload diagnosis report 按钮没有出现', snapshot=True) return self
def bookChoose(self, bookShelf, index=0): """Discover Banner,Weekly,Mybook,Search,testSearh""" index = int(index) if bookShelf == "Banner": # print("数据库中大厅banner书籍以及阅读进度", self.Bookshelf__dir["readprogressList"]) self.find_object("ScrollHot", description="大厅banner的书籍滑动控件" ) # 获取第一个大厅banner的书籍滑动控件type : ScrollRect banner_list = self.poco("ScrollHot").child("Viewport").child( "Content").children() for i in banner_list: print("banner滑动图", i.get_name()) print("banner滑动图的长度:", len(banner_list)) if len(banner_list) != 4: assert_equal(False, True, "banner滑动图数量异常!") return else: self.findClick_childobject(banner_list[1], description="点击第二个滑动banner滑动图", sleeptime=3) self.bookNewDetailPOP() BookID = MyData.Bookshelf__dir["banner_data"][index] print("BookID:", BookID) UIbookName = self.poco("TitleScr").offspring("BookTitle").wait( 2).get_TMPtext() Bookname = self.getBookNewDetail_info(BookID, UIbookName) print("Bookname:", Bookname) print("UIbookName:", UIbookName) return True, Bookname, self.BookNewDetail_info if bookShelf == "Weekly": # "获取书籍的名称" Myboopoco = self.poco("WeekView") self.find_object("WeekView", description="周排行书架") self.findSwipe_object("WeekView", 0.5, POCOobject=Myboopoco, swipeTye="y") time.sleep(3) while (True): try: thebook = \ self.poco("WeekView").child("WeekScr").child("Viewport").child("Content").child("0(Clone)")[ index].wait(5) UIbookName = thebook.child("TextName").wait( 2).get_TMPtext() print("页面显示的书籍名称:", UIbookName) POCOclik = thebook.child("Image") print("POCOclik:", POCOclik.get_position()) BookID = MyData.Bookshelf__dir["Weekly Update"][index] print("BookID:", BookID) Bookname = self.getBookNewDetail_info(BookID, UIbookName) self.findClick_childobject(POCOclik, description="点击书籍封面", waitTime=5, sleeptime=1) self.bookNewDetailPOP() return True, Bookname, self.BookNewDetail_info # 接口书籍名称,当前详情页书籍信息 except: print("未能点击对应的书籍") if index <= 5: index = index + 1 else: return False, None if bookShelf == "Mybook": print("选择Mybook书架") Myboopoco = self.poco("MybookView") self.find_object("MybookView", description="Mybook书架") # self.findSwipe_object("MybookView", 0.5, POCOobject=Myboopoco, swipeTye="y") while (True): try: thebook = \ self.poco("MybookView").child("MybookScr").child("Viewport").child("Content").child("0(Clone)")[ index].wait(3) bookName = thebook.child("TextName").wait(2).get_TMPtext() print("发现对应的书籍", bookName) POCO = thebook.child("Reading").click() self.findClick_childobject(POCO, description="点击书籍", waitTime=1, sleeptime=3) bookName = bookShelf + ":" + bookName return True, bookName except: print("未能点击对应的书籍,退出") if index <= 5: index = index + 1 else: return False
def test_bookPlay(): """Play书籍""" bookdetail = BookNewDetail() actualValue = bookdetail.book_Play() assert_equal(True, actualValue, "点击书籍Play按钮")
def test_ChangeUseravatar(): """更换个人信息背景角色""" myProfilemodule = Profilemodule() actualValue = myProfilemodule.ChangeUseravatar() assert_equal(actualValue, True, "更换背景角色情况{0}".format(myProfilemodule.Profilemodule_info))
def test_newUserGuide(): """新手引导""" myNewUserGuide = NewUserGuide() actualValue = myNewUserGuide.newUserPopUp() assert_equal(actualValue, True, "新手引导{0}".format(myNewUserGuide.NewUserGuide_info))
def test_shop_buy_member(): """订阅会员""" myShopmodule = Shopmodule() actualValue = myShopmodule.shop_buy_member() assert_equal(actualValue, True, "用户的会员状态信息{0}".format(myShopmodule.Shopmodule_info))
def test_shop_buy_ticket(num): """购买票卷""" myShopmodule = Shopmodule() actualValue = myShopmodule.shop_buy_ticket(num) assert_equal(actualValue, True, "购买非双倍奖励的5票{0}".format(myShopmodule.Shopmodule_info))
def test_shop_buy_diamond(num): """购买钻石""" myShopmodule = Shopmodule() actualValue = myShopmodule.shop_buy_diamond(num) assert_equal(actualValue, True, "购买非双倍奖励的20钻石{0}".format(myShopmodule.Shopmodule_info))
def test_installGame(): """安装卸载游戏""" myGameStart = GameStart() myGameStart._instance = myGameStart actualValue = myGameStart.installGame() assert_equal(actualValue, True, "安装游戏")