class RegisterCoursesCSVDataTests(unittest.TestCase):
    """
    

    To run html reports verify pytest-html is installed. If is not installed, from the terminal type : pip3 install pytest-html

    """
    @pytest.fixture(autouse=True)
    def objectSetup(self, oneTimeSetUp):
        self.courses = RegisterCoursesPage(self.driver, self.cfg)
        self.ts = TstStatus(self.driver)
        self.nav = NavigationPage(self.driver, self.cfg)

    def setUp(self):
        self.nav.navigateToAllCourses()

    @pytest.mark.run(order=1)
    @data(*getCSVData("testdata.csv"))
    @unpack
    def test_invalidEnrollment(self, courseName, ccNum, ccExp, ccCVV, ccZip):
        self.courses.enterCourseName(courseName)
        time.sleep(1)
        self.courses.selectCourseToEnroll(courseName)
        time.sleep(1)
        self.courses.enrollCourse(num=ccNum, exp=ccExp, cvv=ccCVV, zip=ccZip)
        time.sleep(1)
        result = self.courses.verifyEnrollFailed()
        self.driver.back()
        self.ts.markFinal("test_invalidEnrollment", result,
                          "Enrollment Failed Verification")
class RegisterCoursesTests(unittest.TestCase):
    """
    py.test -v -s tests/courses/register_courses_tests.py --browser firefox
    py.test -v -s tests/courses/register_courses_tests.py --html=htmlreport.html

    Verify pytest is installed installed
    pip3 install pytest

    Make sure Install pytest-ordering and pytest in system terminal using the pip3 command.
    pip3 install pytest-ordering

    If pytest-html is not installed, from the terminal type : pip3 install pytest-html

    """
    @pytest.fixture(autouse=True)
    def objectSetup(self, oneTimeSetUp):
        self.courses = RegisterCoursesPage(self.driver, self.cfg,
                                           self.bitConfig)
        self.ts = TstStatus(self.driver)

    @pytest.mark.run(order=1)
    def test_invalidEnrollment(self):
        self.courses.enterCourseName("JavaScript")
        self.courses.selectCourseToEnroll("JavaScript for beginners")
        self.courses.enrollCourse(num="1234 5678 9012 3456",
                                  exp="1220",
                                  cvv="444",
                                  zip="12345")
        result = self.courses.verifyEnrollFailed()
        self.ts.markFinal("test_invalidEnrollment", result,
                          "Enrollment Failed Verification")
class RegisterMultipleCoursesTests(unittest.TestCase):

    @pytest.fixture(autouse=True)
    def objectSetup(self, oneTimeSetUp):
        self.courses = RegisterCoursesPage(self.driver)
        self.ts = TstStatus(self.driver)

    @pytest.mark.run(order=1)
    @data(("JavaScript for beginners", "10", "1220", "10"), ("Learn Python 3 from scratch", "20", "1220", "20"))
    @unpack
    def test_invalidEnrollment(self, courseName, ccNum, ccExp, ccCVV):
        self.courses.enterCourseName(courseName)
        self.courses.selectCourseToEnroll(courseName)
        self.courses.enrollCourse(num=ccNum, exp=ccExp, cvv=ccCVV)
        result = self.courses.verifyEnrollFailed()
        self.ts.markFinal("test_invalidEnrollment", result,
                          "Enrollment Failed Verification")
        self.driver.find_element_by_link_text("All Courses").click()
 def objectSetup(self, oneTimeSetUp):
     self.courses = RegisterCoursesPage(self.driver, self.cfg,
                                        self.bitConfig)
     self.ts = TstStatus(self.driver)
Пример #5
0
class LoginTests(unittest.TestCase):
    """

    Make sure Install pytest-ordering and pytest in system terminal using the pip command.
    pip install requests
    py.test -v -s tests/home/login_tests.py --browser firefox
    py.test -v -s tests/home/login_tests.py --browser chrome

    """
    @pytest.fixture(autouse=True)
    def objectSetup(self, oneTimeSetUp):
        self.lp = LoginPage(self.driver)
        self.ts = TstStatus(self.driver)

    @pytest.mark.run(order=2)
    def test_validLogin(self):
        try:
            self.lp.login()
            result1 = self.lp.verifyLoginTitle()
            self.ts.mark(result1, "Title Verification")
            result2 = self.lp.verifyLoginSuccessful()
            self.ts.markFinal("test_validLogin", result2, "Login Verification")
            print("Taking snapshot")
            snapshot_hash1 = self.api_session.post(
                'https://crossbrowsertesting.com/api/v3/selenium/' +
                self.driver.session_id + '/snapshots').json()['hash']

            # if we are still in the try block after all of our assertions that
            # means our test has had no failures, so we set the status to "pass"
            self.test_result = 'pass'

        except AssertionError as e:
            # log the error message, and set the score to "during tearDown()".
            self.api_session.put(
                'https://crossbrowsertesting.com/api/v3/selenium/' +
                self.driver.session_id + '/snapshots/' + snapshot_hash1,
                data={'description': "AssertionError: " + str(e)})
            self.test_result = 'fail'
            raise

    @pytest.mark.run(order=1)
    def test_invalidLogin(self):
        try:
            self.lp.logout()
            self.lp.login("*****@*****.**", "abcabcabc")
            result = self.lp.verifyLoginFailed()
            assert result == True
            print("Taking snapshot")
            snapshot_hash = self.api_session.post(
                'https://crossbrowsertesting.com/api/v3/selenium/' +
                self.driver.session_id + '/snapshots').json()['hash']

            # if we are still in the try block after all of our assertions that
            # means our test has had no failures, so we set the status to "pass"
            self.test_result = 'pass'

        except AssertionError as e:
            # log the error message, and set the score to "during tearDown()".
            self.api_session.put(
                'https://crossbrowsertesting.com/api/v3/selenium/' +
                self.driver.session_id + '/snapshots/' + snapshot_hash,
                data={'description': "AssertionError: " + str(e)})
            self.test_result = 'fail'
            raise
Пример #6
0
 def objectSetup(self, oneTimeSetUp):
     self.lp = LoginPage(self.driver)
     self.ts = TstStatus(self.driver)
 def objectSetup(self, oneTimeSetUp):
     self.courses = RegisterCoursesPage(self.driver, self.cfg)
     self.ts = TstStatus(self.driver)
     self.nav = NavigationPage(self.driver, self.cfg)