class HomePageTest(BaseTest):
    def test_launch(self):
        """Test Case untuk launch URL"""

        # Membuat objek kelas HomePage
        self.homePage = HomePage(self.driver)

        # Mengambil page title dari HomePage
        title = self.homePage.get_title()

        # Verifikasi title page
        assert TestData.WEB_TITLE in title

    def test_login(self):
        """Test Case untuk login"""

        # Membuuat objek kelas HomePage
        self.homePage = HomePage(self.driver)

        # Mengeklik tombol Sign In
        self.homePage.signin()

        # Membuat objek kelas AuthenticationPage
        self.authenticationPage = AuthenticationPage(self.homePage.driver)

        # Mengisi email, password, dan mngeklik tombol Sign In
        self.authenticationPage.signin_registered()

        # Mengambil teks dari elemen header page My Account
        element = self.authenticationPage.get_text(
            Locators.MY_ACCOUNT_PAGE_HEADER)

        # Verifikasi teks header
        assert TestData.MY_ACCOUNT_PAGE_HEADER == element
Exemple #2
0
class LoginTest(BaseTest):
    def test_login_success(self):
        # Membuat objek Home Page
        self.homepage = HomePage(self.driver)

        # Klik tombol sign in
        self.homepage.signin()

        # Membuat objek Authentiaction Page
        self.authenticationpage = AuthenticationPage(self.homepage.driver)

        # Isi email dan password dan klik tombol Sign In
        self.authenticationpage.signin_success()

        # Assertion
        header = self.authenticationpage.get_text(
            Locators.MY_ACCOUNT_PAGE_HEADER)
        self.assertEqual("MY ACCOUNT", header)

    def test_login_failed(self):
        # Membuat objek homepage
        self.homepage = HomePage(self.driver)

        # Klik tombol sign in
        self.homepage.signin()

        # Membuat objek authentication page
        self.authenticationpage = AuthenticationPage(self.homepage.driver)

        # Panggil fungsi signin dengan email invalid
        self.authenticationpage.signin_email_invalid()

        # Assertion
        failed_email_result = self.homepage.get_text(
            Locators.INVALID_EMAIL_ALERT)

        self.assertEqual(failed_email_result, TestData.ALERT_EMAIL_INVALID)

    def test_login_password_invalid(self):
        # Membuat objek homepage
        self.homepage = HomePage(self.driver)

        # Klik tombol sign in
        self.homepage.signin()

        # Membuat objek authentication page
        self.authenticationpage = AuthenticationPage(self.homepage.driver)

        # Panggil fungsi signin dengan password invalid
        self.authenticationpage.signin_password_invalid()

        # Assertion
        failed_password_result = self.homepage.get_text(
            Locators.INVALID_PASSWORD_ALERT)

        self.assertEqual(failed_password_result,
                         TestData.ALERT_PASSWORD_INVALID)

    def test_both_field_empty(self):
        # Membuat objek homepage
        self.homepage = HomePage(self.driver)

        # Klik tombol sign in
        self.homepage.signin()

        # Membuat objek authentication page
        self.authenticationpage = AuthenticationPage(self.homepage.driver)

        self.homepage.click(Locators.SIGN_IN_SUBMIT)

        # Assertion
        empty_field_result = self.homepage.get_text(
            Locators.EMAIL_REQUIRED_ALERT)
        self.assertEqual(empty_field_result, TestData.ALERT_EMAIL_REQUIRED)