Beispiel #1
0
 def test_sign_in_link(self, browser_fixture):
     sign_up_page = SignUpSearchHelper(browser_fixture)
     sign_in_page = SignInSearchHelper(browser_fixture)
     sign_up_page.go_to_sign_up_page()
     sign_up_page.click_on_sign_in_link()
     time.sleep(2)
     assert sign_in_page.sign_in_page_header() == "Sign in"
Beispiel #2
0
 def test_sign_out(self, browser_fixture, data_fixture_js):
     session_email = data_fixture_js["session_email"]
     session_password = data_fixture_js["session_password"]
     sign_in_page = SignInSearchHelper(browser_fixture)
     common = CommonSearchHelper(browser_fixture)
     sign_in_page.go_to_sign_in_page()
     sign_in_page.type_sign_in_email(session_email)
     sign_in_page.type_sign_in_password(session_password)
     sign_in_page.click_sign_in_btn()
     common.click_sign_out()
     assert session_email not in common.navbar_items()
    def test_edit_address_negative(self, browser_fixture, data_fixture_js,
                                   test_input, expected):
        if not TestEditAddressNegative.before_all:
            before_all = TestHelper()
            before_all.add_address(browser_fixture, data_fixture_js)
            TestEditAddressNegative.before_all = True

        session_email = data_fixture_js["session_email2"]
        session_password = data_fixture_js["session_password2"]

        page = SignInSearchHelper(browser_fixture)
        common = CommonSearchHelper(browser_fixture)
        addresses_list_page = AddressesListPage(browser_fixture)
        edit_address_page = EditAddressPage(browser_fixture)
        show_address_page = ShowAddressPage(browser_fixture)

        page.go_to_sign_in_page()
        page.type_sign_in_email(session_email)
        page.type_sign_in_password(session_password)
        page.click_sign_in_btn()
        common.click_addresses()
        addresses_list_page.click_edit_link()

        edit_address_page.clean_field(EAL.locator_first_name_field)
        edit_address_page.clean_field(EAL.locator_last_name_field)
        edit_address_page.clean_field(EAL.locator_address1_field)
        edit_address_page.clean_field(EAL.locator_city)
        edit_address_page.clean_field(EAL.locator_zip_code)

        edit_address_page.set_data_to_field(EAL.locator_first_name_field,
                                            test_input["first_name"])

        edit_address_page.set_data_to_field(EAL.locator_last_name_field,
                                            test_input["last_name"])

        edit_address_page.set_data_to_field(EAL.locator_address1_field,
                                            test_input["address1"])

        edit_address_page.set_data_to_field(EAL.locator_city,
                                            test_input["city"])

        edit_address_page.set_data_to_field(EAL.locator_zip_code,
                                            test_input["zip_code"])

        edit_address_page.click_update_address_btn()

        error_message = common.get_text_from_element(
            EAL.locator_required_fields_error)

        assert error_message == expected

        common.click_sign_out()
Beispiel #4
0
 def setup_class(cls):
     cur_path = pathlib.Path(__file__).parent
     cls.file = open(f"{cur_path}\\..\\..\\test_input_data\\qa.json")
     cls.data_gen = [json.load(cls.file)]
     chrome_driver = ChromeDriverDownloader()
     driver_path = chrome_driver.download_and_install()
     cls.driver = webdriver.Chrome(executable_path=driver_path[0])
     session_email = cls.data_gen[0]["session_email"]
     session_password = cls.data_gen[0]["session_password"]
     page = SignInSearchHelper(cls.driver)
     common = CommonSearchHelper(cls.driver)
     page.go_to_sign_in_page()
     page.type_sign_in_email(session_email)
     page.type_sign_in_password(session_password)
     page.click_sign_in_btn()
     common.click_addresses()
     return cls.driver, cls.data_gen
    def test_error_required_fields_blank(self, browser_fixture,
                                         data_fixture_js, test_input,
                                         expected):
        session_email = data_fixture_js["session_email"]
        session_password = data_fixture_js["session_password"]
        page = SignInSearchHelper(browser_fixture)
        common = CommonSearchHelper(browser_fixture)
        addresses_list_page = AddressesListPage(browser_fixture)
        new_address_page = NewAddressPage(browser_fixture)
        page.go_to_sign_in_page()
        page.type_sign_in_email(session_email)
        page.type_sign_in_password(session_password)
        page.click_sign_in_btn()
        common.click_addresses()

        addresses_list_page.click_new_address_link()

        new_address_page.set_data_to_field(NAL.locator_first_name_field,
                                           test_input["first_name"])

        new_address_page.set_data_to_field(NAL.locator_last_name_field,
                                           test_input["last_name"])

        new_address_page.set_data_to_field(NAL.locator_address1_field,
                                           test_input["address1"])

        new_address_page.set_data_to_field(NAL.locator_city,
                                           test_input["city"])

        new_address_page.set_data_to_field(NAL.locator_zip_code,
                                           test_input["zip_code"])

        new_address_page.click_create_address_btn()

        error_message = common.get_text_from_element(
            NAL.locator_required_fields_error)
        assert error_message == expected

        common.click_sign_out()
Beispiel #6
0
 def test_sign_in_invalid_email_password(self, browser_fixture,
                                         data_fixture_js, test_input,
                                         expected):
     if not TestSignInNegative.user_created:
         create_user = TestHelper()
         create_user.create_user(browser_fixture)
         TestSignInNegative.user_created = True
     session_email = test_input["email"]
     session_password = test_input["password"]
     sign_in_page = SignInSearchHelper(browser_fixture)
     common = CommonSearchHelper(browser_fixture)
     sign_in_page.go_to_sign_in_page()
     sign_in_page.type_sign_in_email(session_email)
     sign_in_page.type_sign_in_password(session_password)
     sign_in_page.click_sign_in_btn()
     error_message = sign_in_page.error_message()
     assert error_message == expected
     assert session_email not in common.navbar_items()
Beispiel #7
0
 def test_sign_in_bad_email_format(self, browser_fixture, test_input,
                                   expected):
     session_email = test_input["email"]
     session_password = test_input["password"]
     sign_in_page = SignInSearchHelper(browser_fixture)
     common = CommonSearchHelper(browser_fixture)
     sign_in_page.go_to_sign_in_page()
     sign_in_page.type_sign_in_email(session_email)
     sign_in_page.type_sign_in_password(session_password)
     sign_in_page.click_sign_in_btn()
     email_field = sign_in_page.driver.switch_to_active_element()
     header = sign_in_page.sign_in_page_header()
     placeholder = email_field.get_attribute("placeholder")
     assert session_email not in common.navbar_items()
     assert header == "Sign in"
     assert placeholder == "Email"
Beispiel #8
0
        def add_address(self, browser_fixture, data_fixture_js,
                        delete_address):
            session_email = data_fixture_js["session_email2"]
            session_password = data_fixture_js["session_password2"]

            page = SignInSearchHelper(browser_fixture)
            common = CommonSearchHelper(browser_fixture)
            addresses_list_page = AddressesListPage(browser_fixture)
            new_address_page = NewAddressPage(browser_fixture)
            show_address_page = ShowAddressPage(browser_fixture)
            converter = Converters()

            url = f"{page.base_url}session"
            headers_log_in = requests.post(url,
                                           data={
                                               "session[email]":
                                               f"{session_email}",
                                               "session[password]":
                                               f"{session_password}"
                                           })

            build_headers = {
                "Cookie": f"{headers_log_in.headers['Set-Cookie']}"
            }

            delete_address['headers'] = build_headers

            page.go_to_sign_in_page()
            page.type_sign_in_email(session_email)
            page.type_sign_in_password(session_password)
            page.click_sign_in_btn()
            common.click_addresses()

            addresses_list_page.click_new_address_link()

            new_address_page.set_data_to_field(
                NAL.locator_first_name_field,
                data_fixture_js["dict_add_address"]["First name:"])

            new_address_page.set_data_to_field(
                NAL.locator_last_name_field,
                data_fixture_js["dict_add_address"]["Last name:"])

            new_address_page.set_data_to_field(
                NAL.locator_address1_field,
                data_fixture_js["dict_add_address"]["Street Address:"])

            new_address_page.set_data_to_field(
                NAL.locator_address2_field,
                data_fixture_js["dict_add_address"]["Secondary Address:"])

            new_address_page.set_data_to_field(
                NAL.locator_city, data_fixture_js["dict_add_address"]["City:"])

            new_address_page.select_dropdown_option(
                NAL.locator_state,
                data_fixture_js["dict_add_address"]["State:"])

            new_address_page.set_data_to_field(
                NAL.locator_zip_code,
                data_fixture_js["dict_add_address"]["Zip code:"])

            new_address_page.select_state(
                data_fixture_js["dict_add_address"]["Country:"])

            if platform.system() == "Linux":
                new_address_page.set_data_to_field(
                    NAL.locator_birthday,
                    data_fixture_js["dict_add_address"]["Birthday:"])
            else:
                new_address_page.set_data_to_field(
                    NAL.locator_birthday,
                    converter.date_converter(
                        data_fixture_js["dict_add_address"]["Birthday:"]))

            new_address_page.set_data_to_field(
                NAL.locator_color,
                converter.rgb_to_hex(
                    data_fixture_js["dict_add_address"]["Color:"]))

            new_address_page.set_data_to_field(
                NAL.locator_age, data_fixture_js["dict_add_address"]["Age:"])

            new_address_page.set_data_to_field(
                NAL.locator_website,
                data_fixture_js["dict_add_address"]["Website:"])

            # new_address_page.find_element(NAL.locator_picture)\
            #     .send_keys("C:\\123.png")

            new_address_page.set_data_to_field(
                NAL.locator_phone,
                data_fixture_js["dict_add_address"]["Phone:"])

            new_address_page.click_on_element_if_yes(
                NAL.locator_climbing,
                data_fixture_js["dict_add_address"]["Climbing?"])

            new_address_page.click_on_element_if_yes(
                NAL.locator_dancing,
                data_fixture_js["dict_add_address"]["Dancing?"])

            new_address_page.click_on_element_if_yes(
                NAL.locator_reading,
                data_fixture_js["dict_add_address"]["Reading?"])

            new_address_page.set_data_to_field(
                NAL.locator_note, data_fixture_js["dict_add_address"]["Note:"])

            new_address_page.click_create_address_btn()

            show_address_url = show_address_page.driver.current_url
            delete_address['address'].append(show_address_url)

            return show_address_url.split(addresses_list_page.base_url)[1]
    def test_destroy_address(self, browser_fixture, data_fixture_js):
        session_email = data_fixture_js["session_email2"]
        session_password = data_fixture_js["session_password2"]

        page = SignInSearchHelper(browser_fixture)
        common = CommonSearchHelper(browser_fixture)
        addresses_list_page = AddressesListPage(browser_fixture)
        new_address_page = NewAddressPage(browser_fixture)
        show_address_page = ShowAddressPage(browser_fixture)
        converter = Converters()

        page.go_to_sign_in_page()
        page.type_sign_in_email(session_email)
        page.type_sign_in_password(session_password)
        page.click_sign_in_btn()
        common.click_addresses()

        addresses_list_page.click_new_address_link()

        new_address_page.set_data_to_field(
            NAL.locator_first_name_field,
            data_fixture_js["dict_add_address"]["First name:"])

        new_address_page.set_data_to_field(
            NAL.locator_last_name_field,
            data_fixture_js["dict_add_address"]["Last name:"])

        new_address_page.set_data_to_field(
            NAL.locator_address1_field,
            data_fixture_js["dict_add_address"]["Street Address:"])

        new_address_page.set_data_to_field(
            NAL.locator_address2_field,
            data_fixture_js["dict_add_address"]["Secondary Address:"])

        new_address_page.set_data_to_field(
            NAL.locator_city, data_fixture_js["dict_add_address"]["City:"])

        new_address_page.select_dropdown_option(
            NAL.locator_state, data_fixture_js["dict_add_address"]["State:"])

        new_address_page.set_data_to_field(
            NAL.locator_zip_code,
            data_fixture_js["dict_add_address"]["Zip code:"])

        new_address_page.select_state(
            data_fixture_js["dict_add_address"]["Country:"])

        new_address_page.set_data_to_field(
            NAL.locator_birthday,
            converter.date_converter(
                data_fixture_js["dict_add_address"]["Birthday:"]))

        new_address_page.set_data_to_field(
            NAL.locator_color,
            converter.rgb_to_hex(
                data_fixture_js["dict_add_address"]["Color:"]))

        new_address_page.set_data_to_field(
            NAL.locator_age, data_fixture_js["dict_add_address"]["Age:"])

        new_address_page.set_data_to_field(
            NAL.locator_website,
            data_fixture_js["dict_add_address"]["Website:"])

        new_address_page.find_element(NAL.locator_picture) \
            .send_keys("C:\\123.png")

        new_address_page.set_data_to_field(
            NAL.locator_phone, data_fixture_js["dict_add_address"]["Phone:"])

        new_address_page.click_on_element_if_yes(
            NAL.locator_climbing,
            data_fixture_js["dict_add_address"]["Climbing?"])

        new_address_page.click_on_element_if_yes(
            NAL.locator_dancing,
            data_fixture_js["dict_add_address"]["Dancing?"])

        new_address_page.click_on_element_if_yes(
            NAL.locator_reading,
            data_fixture_js["dict_add_address"]["Reading?"])

        new_address_page.set_data_to_field(
            NAL.locator_note, data_fixture_js["dict_add_address"]["Note:"])

        new_address_page.click_create_address_btn()

        show_address_page.click_list_link()

        addresses_list_page.click_destroy_link()

        addresses_list_page.click_ok_on_alert()

        assert addresses_list_page.find_element(
            ALL.locator_destroyed_message
        ).text == "Address was successfully destroyed."

        common.click_sign_out()
Beispiel #10
0
 def test_sign_in_page_header(self, browser_fixture):
     address_main_page = CommonSearchHelper(browser_fixture)
     sign_in_page = SignInSearchHelper(browser_fixture)
     address_main_page.go_to_home_page()
     address_main_page.click_sign_in()
     assert sign_in_page.sign_in_page_header() == "Sign in"