Exemplo n.º 1
0
class LoginHrmTests(unittest.TestCase):

    # base_url = "http://localhost"
    # driver = webdriver.Chrome()
    # driver.maximize_window()
    # driver.implicitly_wait(3)
    # driver.get(base_url)

    # create class_level fixture to prepare to run all tests: here to make an instance of a class we are testing and
    # make it available to every method
    @pytest.fixture(autouse=True)
    def class_setup(
        self, module_set_up_level_to_test_a_class_orangehrm
    ):  # need to provide fixture to the class here because we need to get the "value" returned by request.cls.value
        self.login_page = LoginPage(self.driver)
        self.test_status = TCaseStatus(self.driver)

    @pytest.mark.run(order=4)
    def test_valid_login(self):
        #after 186 video we login via conftest setup class method as a precondition to write the rest of TCs
        #--> will deal with that later for login tests
        self.login_page.login_hrm("admin", "Bitnami.12345")
        result1 = self.login_page.verify_login_title_hrm()
        self.test_status.mark(result1, "Title Verification")
        time.sleep(2)
        result2 = self.login_page.verify_login_successfull_hrm()
        #call mark_final() at the last test in the Test Case with multiple assertions
        self.test_status.mark_final("Test Case Name: test_valid_login",
                                    result2, "Login Successful Verification")
        #self.driver.quit() - moved to conftest.py >> pytest fixture

    @pytest.mark.run(order=1)
    def test_invalid_login(self):
        self.login_page.logout_hrm()
        self.login_page.login_hrm("longinvalid", "abcabcbbb")
        result = self.login_page.verify_login_failed_hrm()
        assert result is True

    @pytest.mark.run(order=2)
    def test_empty_credentials_login(self):
        self.login_page.login_hrm()
        result = self.login_page.verify_empty_username_login_failed_hrm()
        assert result is True

    @pytest.mark.run(order=3)
    def test_empty_username_valid_password_login(self):
        self.login_page.login_hrm(password="******")
        result = self.login_page.verify_empty_username_login_failed_hrm()
        assert result is True
class RegisterCoursesCsvDataTests(unittest.TestCase):
    @pytest.fixture(autouse=True)
    def class_setup(self, module_set_up_level_to_test_a_class):
        self.register_courses = RegisterCoursesPage(self.driver)
        self.test_status = TCaseStatus(self.driver)
        self.navigation = NavigationPage(self.driver)

    def setUp(self):
        #this is setup: since all tests for register courses should start on that page
        self.navigation.navigate_to_letskodeit_icon()

    @pytest.mark.run(order=1)
    @data(*get_csv_data(
        "/Users/annaromanovskaia/PycharmProjects/orangehrm-automation/test_data_courses.csv"
    ))
    @unpack
    def test_redirected_to_course_detail_page_and_invalid_enrollment(
            self, course_name, cc_number, cc_exp_date, cc_cvc, cc_postal_code):
        self.register_courses.search_for_course(course_name)
        # start from there
        self.register_courses.select_course_to_enroll(course_name)
        #self.register_courses.select_mac_linux_course()
        #result = self.register_courses.verify_redirected_to_course_details_page()
        #self.test_status.mark(result, "Redirected to course details page Verification")
        time.sleep(2)

        #def test_verify_enroll_button_final_disabled_with_invalid_card(self):
        self.register_courses.enroll_in_course_from_course_details_page()
        result2 = self.register_courses.verify_redirected_to_checkout_page()
        self.test_status.mark(result2,
                              "Redirected to Checkout Page Verification")
        self.register_courses.enter_another_card_details_postal_code(
            cc_number=cc_number,
            exp_date=cc_exp_date,
            cvc=cc_cvc,
            postal_code=cc_postal_code)
        result3 = self.register_courses.verify_buy_now_button_disabled()
        print("Result3: {}".format(result3))
        time.sleep(1)

        self.test_status.mark_final(
            "Test Case Name: test_verify_enroll_button_final_disabled_with_invalid_card",
            result3, "Enroll Button Final Disabled Verification")
        time.sleep(2)
Exemplo n.º 3
0
class RegisterCoursesTests(unittest.TestCase):
    @pytest.fixture(autouse=True)
    def class_setup(self, module_set_up_level_to_test_a_class):
        self.register_courses = RegisterCoursesPage(self.driver)
        self.test_status = TCaseStatus(self.driver)

    @pytest.mark.run(order=1)
    @data(("Mac Linux Command Line Basics", "5555", "12/22", "123", "93405"),
          ("JavaScript Masterclass", "6666", "12/22", "456", "93405"),
          ("Learn Python 3 from scratch", "7777", "12/22", "124", "94087"))
    @unpack
    def test_redirected_to_course_detail_page_and_invalid_enrollment(
            self, course_name, cc_number, cc_exp_date, cc_cvc, cc_postal_code):
        self.register_courses.search_for_course(course_name)
        # start from there
        self.register_courses.select_course_to_enroll(course_name)
        #self.register_courses.select_mac_linux_course()
        #result = self.register_courses.verify_redirected_to_course_details_page()
        #self.test_status.mark(result, "Redirected to course details page Verification")
        time.sleep(2)

        #def test_verify_enroll_button_final_disabled_with_invalid_card(self):
        self.register_courses.enroll_in_course_from_course_details_page()
        result2 = self.register_courses.verify_redirected_to_checkout_page()
        self.test_status.mark(result2,
                              "Redirected to Checkout Page Verification")
        self.register_courses.enter_another_card_details_postal_code(
            cc_number=cc_number,
            exp_date=cc_exp_date,
            cvc=cc_cvc,
            postal_code=cc_postal_code)
        result3 = self.register_courses.verify_buy_now_button_disabled()
        print("Result3: {}".format(result3))
        time.sleep(1)

        self.test_status.mark_final(
            "Test Case Name: test_verify_enroll_button_final_disabled_with_invalid_card",
            result3, "Enroll Button Final Disabled Verification")
        self.driver.find_element_by_xpath(
            "//div/a[@class='navbar-brand header-logo']").click()
        time.sleep(2)
Exemplo n.º 4
0
class RegisterCoursesTests(unittest.TestCase):

    @pytest.fixture(autouse=True)
    def class_setup(self, module_set_up_level_to_test_a_class):
        self.register_courses = RegisterCoursesPage(self.driver)
        self.test_status = TCaseStatus(self.driver)

    @pytest.mark.run(order=1)
    def test_redirected_to_course_detail_page(self):
        self.register_courses.search_for_course("Mac Linux Command Line Basics")
        self.register_courses.select_mac_linux_course()
        result = self.register_courses.verify_redirected_to_course_details_page()
        self.test_status.mark_final("Test Case Name: test_redirected_to_course_detail_page", result,
                                    "Redirected to course details page Verification")
        time.sleep(4)

    @pytest.mark.run(order=2)
    def test_verify_buy_now_button_disabled_with_invalid_card(self):
        self.register_courses.enroll_in_course_from_course_details_page()
        result = self.register_courses.verify_redirected_to_checkout_page()
        self.test_status.mark(result, "Redirected to Checkout Page Verification")
        self.register_courses.enter_another_card_details_postal_code(cc_number="5555", exp_date="03/22",
                                                             cvc="123", postal_code="93405")
        result2 = self.register_courses.verify_buy_now_button_disabled()
        print("Result2: {}".format(result))
        time.sleep(3)

        self.test_status.mark_final("Test Case Name: test_verify_buy_now_button_disabled_with_invalid_card",
                              result2, "Buy Now Disabled Verification")
        time.sleep(3)
Exemplo n.º 5
0
 def class_setup(
     self, module_set_up_level_to_test_a_class_orangehrm
 ):  # need to provide fixture to the class here because we need to get the "value" returned by request.cls.value
     self.login_page = LoginPage(self.driver)
     self.test_status = TCaseStatus(self.driver)
 def class_setup(self, module_set_up_level_to_test_a_class):
     self.register_courses = RegisterCoursesPage(self.driver)
     self.test_status = TCaseStatus(self.driver)
     self.navigation = NavigationPage(self.driver)