class DecimalTest(BaseTest):
    def test_001_addition(self):
        # Membuat objek HomePage
        self.homepage = HomePage(self.driver)

        # Input angka ke kedua field lalu pilih operasi penjumlahan
        self.homepage.calculation(TestData.DECIMAL_1, TestData.DECIMAL_2, TestData.ADDITION_OP)

        # Ambil teks result
        result = self.homepage.get_text(Locators.RESULT)

        self.assertEqual("3", result)


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

        # Input angka ke kedua field lalu pilih operasi pengurangan
        self.homepage.calculation(TestData.DECIMAL_1, TestData.DECIMAL_2, TestData.SUBSTRACTION_OP)

        # Ambil teks result
        result = self.homepage.get_text(Locators.RESULT)

        self.assertEqual("1.8", result)

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

        # Input angka ke kedua field lalu pilih operasi perkalian
        self.homepage.calculation(TestData.DECIMAL_1, TestData.DECIMAL_2, TestData.MULTIPLICATION_OP)

        # Ambil teks result
        result = self.homepage.get_text(Locators.RESULT)

        self.assertEqual("1.44", result)

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

        # Input angka ke kedua field lalu pilih operasi pembagian
        self.homepage.calculation(TestData.DECIMAL_1, TestData.DECIMAL_2, TestData.DIVISION_OP)

        # Ambil teks result
        result = self.homepage.get_text(Locators.RESULT)

        self.assertEqual("4", result)
class AddToCartTest(BaseTest):
    def test_add_from_home(self):

        # Load Home Page
        self.homepage = HomePage(self.driver)

        # Add to Cart (From Home)
        self.homepage.add_from_home()

        # Assertion
        status = self.homepage.get_text(Locators.ADD_FROM_HOME_STATUS)
        self.assertEqual(status, TestData.ALERT_ADD_FROM_HOME)

    def test_add_from_category(self):

        # Load Home Page
        self.homepage = HomePage(self.driver)

        # Click Category
        self.homepage.category()

        # Add to Cart (From Category)
        self.homepage.add_from_category()

        # Assertion
        status = self.homepage.get_text(Locators.CATEGORY_ADD_TO_CART_STATUS)
        self.assertEqual(status, TestData.ALERT_ADD_FROM_CATEGORY)

    def test_add_from_details(self):
        # Load Home Page
        self.homepage = HomePage(self.driver)

        # Add from details
        self.homepage.add_from_details()

        # Assertion
        status = self.homepage.get_text(Locators.DETAIL_PRODUCT_STATUS)
        self.assertEqual(status, TestData.ALERT_ADD_FROM_DETAILS)

    def test_add_from_search(self):
        # Load Home Page
        self.homepage = HomePage(self.driver)

        # Add from Search
        self.homepage.add_from_search()

        # Assertion
        status = self.homepage.get_text(Locators.SEARCH_PRODUCT_STATUS)
        self.assertEqual(status, TestData.ALERT_ADD_FROM_SEARCH)
class CheckoutTest(BaseTest):
    def test_checkout_by_bankwire(self):
        # Load Homepage
        self.homepage = HomePage(self.driver)

        # Click Sign In Button
        self.homepage.signin()

        # Load Auth Page
        self.authpage = AuthPage(self.homepage.driver)

        # Sign in with Account
        self.authpage.sign_in_success()

        # Click Website Logo
        self.homepage.logo()

        # Checkout Success
        self.homepage.checkout_success_bankwire()

        # Assertion
        status = self.homepage.get_text(Locators.CHECKOUT_STATUS_BANKWIRE)
        self.assertEqual(TestData.ALERT_CHECKOUT_SUCCESS, status)

    def test_checkout_by_check(self):
        # Load Homepage
        self.homepage = HomePage(self.driver)

        # Click Sign In Button
        self.homepage.signin()

        # Load Auth Page
        self.authpage = AuthPage(self.homepage.driver)

        # Sign in with Account
        self.authpage.sign_in_success()

        # Click Website Logo
        self.homepage.logo()

        # Checkout Success
        self.homepage.checkout_success_check()

        # Assertion
        status = self.homepage.get_text(Locators.CHECKOUT_STATUS_BY_CHECK)
        self.assertEqual(TestData.ALERT_CHECKOUT_SUCCESS, status)
class ErrorTest(BaseTest):
    def test_001_input_empty(self):
        # Membuat objek HomePage
        self.homepage = HomePage(self.driver)

        # Select Operator *
        self.homepage.select_operator(TestData.ADDITION_OP)

        # Input 2nd number
        self.homepage.enter_text(Locators.INPUT_2, TestData.INTEGER_2)

        # CLick equal sign
        self.homepage.click(Locators.EQUAL_BUTTON)

        actual_text = self.homepage.get_text(Locators.RESULT)

        self.assertEqual("Error: Input value cannot be empty!", actual_text)
Beispiel #5
0
class NewsletterTest(BaseTest):
    def test_register_newsletter_valid(self):
        # Step 1 - Membuat objek Home Page
        self.homepage = HomePage(self.driver)

        # Step 2 - Masukkan email di Newletter
        self.homepage.enter_text(Locators.NEWSLETTER_INPUT,
                                 TestData.NEWSLETTER_EMAIL)
        print(TestData.NEWSLETTER_EMAIL)
        # Step 3 - Click Submit button
        self.homepage.click(Locators.SUBMIT_NEWSLETTER)

        # # Step 2 & 3 - Masukkan email dan Click Submit
        # self.homepage.register_newsletter_valid()

        # Assertion
        teks = self.homepage.get_text(Locators.NEWSLETTER_ALERT)
        self.assertEqual(TestData.NEWSLETTER_SUCCESS, teks)

    def test_register_newsletter_invalid(self):
        pass

    def test_register_newsletter_registered(self):
        pass
Beispiel #6
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)
class IntegerTest(BaseTest):
    def test_001_addition(self):
        # Membuat objek HomePage
        self.homepage = HomePage(self.driver)

        # Input 1st number
        self.homepage.enter_text(Locators.INPUT_1, TestData.INTEGER_1)

        # Select Operator +
        self.homepage.select_operator(TestData.ADDITION_OP)

        # Input 2nd number
        self.homepage.enter_text(Locators.INPUT_2, TestData.INTEGER_2)

        # CLick equal sign
        self.homepage.click(Locators.EQUAL_BUTTON)

        # Ambil teks result
        result = self.homepage.get_text(Locators.RESULT)

        self.assertEqual("7", result)

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

        # Input angka ke kedua field lalu pilih operasi penjumlahan
        hasil = self.homepage.calculation_dynamic_integer(TestData.ADDITION_OP)

        # Ambil teks result
        result = self.homepage.get_text(Locators.RESULT)

        self.assertEqual(str(hasil), result)

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

        # Input 1st number
        self.homepage.enter_text(Locators.INPUT_1, TestData.INTEGER_1)

        # Select Operator +
        self.homepage.select_operator(TestData.SUBSTRACTION_OP)

        # Input 2nd number
        self.homepage.enter_text(Locators.INPUT_2, TestData.INTEGER_2)

        # CLick equal sign
        self.homepage.click(Locators.EQUAL_BUTTON)

        # Ambil teks result
        result = self.homepage.get_text(Locators.RESULT)

        self.assertEqual("1", result)

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

        # Input angka ke kedua field lalu pilih operasi pengurangan
        hasil = self.homepage.calculation_dynamic_integer(TestData.SUBSTRACTION_OP)

        # Ambil teks result
        result = self.homepage.get_text(Locators.RESULT)

        self.assertEqual(str(hasil), result)

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

        # Input angka ke kedua field lalu pilih operasi perkalian
        self.homepage.calculation(TestData.INTEGER_1, TestData.INTEGER_2, TestData.MULTIPLICATION_OP)

        # Ambil teks result
        result = self.homepage.get_text(Locators.RESULT)

        self.assertEqual("12", result)

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

        # Input angka ke kedua field lalu pilih operasi perkalian
        hasil = self.homepage.calculation_dynamic_integer(TestData.MULTIPLICATION_OP)

        # Ambil teks result
        result = self.homepage.get_text(Locators.RESULT)

        self.assertEqual(str(hasil), result)

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

        # Input angka ke kedua field lalu pilih operasi pembagian
        self.homepage.calculation(TestData.INTEGER_1, TestData.INTEGER_2, TestData.DIVISION_OP)

        # Ambil teks result
        result = self.homepage.get_text(Locators.RESULT)

        self.assertEqual("1.3333333333333333", result)

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

        # Input angka ke kedua field lalu pilih operasi pembagian
        hasil = self.homepage.calculation_dynamic_integer(TestData.DIVISION_OP)

        # Ambil teks result
        result = self.homepage.get_text(Locators.RESULT)

        self.assertEqual(str(hasil), result)
class MyAccountTest(BaseTest):
    def test_reorder(self):
        # Load Homepage
        self.homepage = HomePage(self.driver)

        # Click Sign In Button
        self.homepage.signin()

        # Load Auth Page
        self.authpage = AuthPage(self.homepage.driver)

        # Sign in with Account
        self.authpage.sign_in_success()

        # Load MyAccount Page
        self.myaccount = MyAccountPage(self.homepage.driver)

        # Execute Reorder
        self.myaccount.reorder()

        # Assertion
        status = self.homepage.get_text(Locators.CHECKOUT_STATUS_BY_CHECK)
        self.assertEqual(TestData.ALERT_CHECKOUT_SUCCESS, status)

    def test_add_new_address(self):
        # Load Homepage
        self.homepage = HomePage(self.driver)

        # Click Sign In Button
        self.homepage.signin()

        # Load Auth Page
        self.authpage = AuthPage(self.homepage.driver)

        # Sign in with Account
        self.authpage.sign_in_success()

        # Load My Account Page
        self.myaccount = MyAccountPage(self.homepage.driver)

        # Execute Add New Address
        self.myaccount.add_new_address()

    def test_remove_address(self):
        # Load Homepage
        self.homepage = HomePage(self.driver)

        # Click Sign In Button
        self.homepage.signin()

        # Load Auth Page
        self.authpage = AuthPage(self.homepage.driver)

        # Sign in with Account
        self.authpage.sign_in_success()

        # Load My Account Page
        self.myaccount = MyAccountPage(self.homepage.driver)

        # Execute Remove Address
        self.myaccount.remove_address()

    def test_remove_wishlist(self):
        # Load Homepage
        self.homepage = HomePage(self.driver)

        # Click Sign In Button
        self.homepage.signin()

        # Load Auth Page
        self.authpage = AuthPage(self.homepage.driver)

        # Sign in with Account
        self.authpage.sign_in_success()

        # Click Website Logo
        self.homepage.logo()

        # Load My Account Page
        self.myaccount = MyAccountPage(self.homepage.driver)

        # Execute Remove Wishlist
        self.myaccount.remove_wishlist()

        time.sleep(5)