def create_user(self, browser_fixture):
     sign_up_page = SignUpSearchHelper(browser_fixture)
     common = CommonSearchHelper(browser_fixture)
     sign_up_page.go_to_sign_up_page()
     sign_up_page.type_sign_up_email("*****@*****.**")
     sign_up_page.type_sign_up_password("123456")
     sign_up_page.click_sign_up_btn()
     try:
         common.click_sign_out()
     except TimeoutException:
         pass
 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_sign_up(self, browser_fixture):
     sign_up_email = "".join(random.choices(string.ascii_lowercase, k=6))\
                     + "@i.ua"
     sign_up_password = "".join(random.choices(string.ascii_lowercase, k=6))
     sign_up_page = SignUpSearchHelper(browser_fixture)
     common = CommonSearchHelper(browser_fixture)
     sign_up_page.go_to_sign_up_page()
     sign_up_page.type_sign_up_email(sign_up_email)
     sign_up_page.type_sign_up_password(sign_up_password)
     sign_up_page.click_sign_up_btn()
     assert sign_up_email in common.navbar_items()
     common.click_sign_out()
    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()
    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()
    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()