コード例 #1
0
    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()
コード例 #2
0
ファイル: test_helper.py プロジェクト: amarmulyak/AddressBook
        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]
コード例 #3
0
    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()