def test_spec_no(self):
     page = HomePage(self.driver, self.domain)
     page = page.search("")
     course_names_list = ["rbq", "论持久战", "第三次世界大战", "如何进牢子"]
     rs()
     for course_name in course_names_list:
         self.checkCourseExist(page, course_name)
Exemple #2
0
 def getForm(self):
     rs()
     res = {}
     text = self.waitAppear_ID(self.name_text_id)
     res["name"] = text.text
     res["role"] = self.getRoleValue()
     res["gender"] = self.getGenderValue()
     text = self.waitAppear_ID(self.intro_text_id)
     res["intro"] = text.get_attribute("value")
     return res
Exemple #3
0
 def logIn(self, name, password):
     rs()
     name_text = self.waitAppear_ID(self.name_text_id)
     name_text.send_keys(name)
     password_text = self.waitAppear_ID(self.password_text_id)
     password_text.send_keys(password)
     btn = self.waitAppear_ID(self.login_btn_id)
     btn.click()
     self.alertAccept()
     return HomePage(self.driver)
 def test_regist_exist_user(self):
     page = HomePage(self.driver, self.domain)
     page = page.goRegistPage()
     page.fillForm(
         name="rbq",
         email="*****@*****.**",
         password="******",
         repassword="******",
     )
     page.submit()  # Should still be RegistPage
     rs(min=3)
     page.checkIsSelf()
Exemple #5
0
    def uploadPage_wholeProcess(self, image_path):
        btn = self.waitAppear_ID(self.photo_open_dialog_btn_id)
        btn.click()

        file_ctl = self.waitAppear_ID(self.photo_open_file_input_id)
        file_ctl.send_keys(image_path)

        rs()

        btn = self.waitAppear_xpath(self.photo_submit_btn_xpath)
        btn.click()
        self.alertAccept()
    def test_modify_photo(self):
        page = HomePage(self.driver, self.domain)
        with LogStatus(page, "rbq", "rbq") as page:
            page = page.goPersonPage()

            rs()
            old_url = page.getImageURL()
            test_path = "D:/code_concerned/ruangong/rateMyCourse_back/test/front/test_image.png"  # TODO Move out

            page.uploadPage_wholeProcess(test_path)
            rs()
            new_url = page.getImageURL()

            self.assertIsNotNone(old_url)
            self.assertIsNotNone(new_url)
            self.assertNotEquals(old_url, new_url)
Exemple #7
0
        def wrap_func(self, *args, **kwargs):
            self.block_cache = None

            res = f(self, *args, *kwargs)

            def func_comp(a, b):
                return a.__name__ == b.__name__

            if func_comp(f, SplitBasePage.prevSplit):
                self.now_index -= 1
            elif func_comp(f, SplitBasePage.nextSplit):
                self.now_index += 1
            elif func_comp(f, SplitBasePage.jumpSplit):
                self.now_index = args[0]

            rs()
            return res
    def test_rate_comment(self):
        '''This testcase takes very long time, at least 20s'''
        page = HomePage(self.driver, self.domain)
        with LogStatus(page, "rbq", "rbq") as page:
            page = self.goDetailPage(page)
            tci = 0  # target comment index

            with self.subTest(case_name="init"):
                self.checkRateState(page, tci, False, False, 0)

            with self.subTest(case_name="agree_no2agree"):
                page.clickThumbUp(tci)
                rs()
                self.checkRateState(page, tci, True, False, 1)

            with self.subTest(case_name="agree_agree2no"):
                page.clickThumbUp(tci)
                rs()
                self.checkRateState(page, tci, False, False, 0)

            with self.subTest(case_name="disagree_no2disagree"):
                page.clickThumbDown(tci)
                rs()
                self.checkRateState(page, tci, False, True, -1)

            with self.subTest(case_name="disagree_disagree2no"):
                page.clickThumbDown(tci)
                rs()
                self.checkRateState(page, tci, False, False, 0)

            with self.subTest(case_name="agree_again_no2agree"):
                page.clickThumbUp(tci)
                rs()
                self.checkRateState(page, tci, True, False, 1)

            with self.subTest(case_name="disagree_agree2disagree"):
                page.clickThumbDown(tci)
                rs()
                self.checkRateState(page, tci, False, True, -1)

            with self.subTest(case_name="agree_disagree2agree"):
                page.clickThumbUp(tci)
                rs()
                self.checkRateState(page, tci, True, False, 1)

            with self.subTest(case_name="agree_reset_agree2no"):
                page.clickThumbUp(tci)
                rs()
                self.checkRateState(page, tci, False, False, 0)
    def generalTest(self, num_per_page: int, page: SplitBasePage):
        block_forms_list = {}

        rs()
        with self.subTest(case_name="init"):
            self.assertEquals(page.getBlockNum(), num_per_page)
            block_forms_list[1] = self.getBlockForms(page)

            page.checkBtnShow()

        with self.subTest(case_name="next_page"):
            # Operation
            page.nextSplit()

            # Content Check
            self.assertEquals(page.getBlockNum(), num_per_page)
            block_forms_list[2] = self.getBlockForms(page)
            self.assertNotEquals(block_forms_list[1], block_forms_list[2])

            # Split btn show check
            page.checkBtnShow()

        with self.subTest(case_name="prev_page"):
            page.prevSplit()

            block_forms = self.getBlockForms(page)
            self.assertEquals(block_forms_list[1], block_forms)

            page.checkBtnShow()

        # with self.subTest(case_name="jump_page"):
        # page.jumpSplit(3)
        # block_forms_3 = self.getBlockForms(page)
        # self.assertNotEquals(block_forms_1, block_forms_3)
        # self.assertNotEquals(block_forms_2, block_forms_3)

        with self.subTest(case_name="first2last_page"):
            page.jumpSplit(page.getMaxIndex())

            block_forms_list[page.getMaxIndex()] = self.getBlockForms(page)
            self.assertNotEquals(block_forms_list[page.getMaxIndex()],
                                 block_forms_list[1])

            page.checkBtnShow()

        with self.subTest(case_name="last2first_page"):
            page.jumpSplit(1)

            block_forms = self.getBlockForms(page)
            self.assertEquals(block_forms, block_forms_list[1])

            page.checkBtnShow()

        with self.subTest(case_name="middle_page"):
            page.jumpSplit(5)

            block_forms_list[5] = self.getBlockForms(page)
            for index, forms in block_forms_list.items():
                if index == 5:
                    continue
                self.assertNotEquals(forms, block_forms_list[5])

            page.checkBtnShow()

        with self.subTest(case_name="middle2first_page"):
            page.jumpSplit(1)

            block_forms = self.getBlockForms(page)
            self.assertEquals(block_forms, block_forms_list[1])

            page.checkBtnShow()

        with self.subTest(case_name="middle2last_page"):
            page.jumpSplit(5)
            page.jumpSplit(page.getMaxIndex())

            block_forms_list[page.getMaxIndex()] = self.getBlockForms(page)
            self.assertNotEquals(block_forms_list[page.getMaxIndex()],
                                 block_forms_list[1])

            page.checkBtnShow()
Exemple #10
0
 def clickChildCommentBtn(self, parent_index: int):
     block = self.getBlock(parent_index)
     btn = block.find_element(*self.comment_child_comment_btn_loc)
     btn.click()
     rs()