def setUp(self):
        browser = os.environ.get('BROWSER', os.environ['BROWSER'])

        self.driver = Remote(
            command_executor='http://127.0.0.1:4444/wd/hub',
            desired_capabilities=getattr(DesiredCapabilities, browser).copy()
        )
        self.driver.maximize_window()

        self.MESSAGE_TEXT = "testNumber1"
        self.BOT_1_LOGIN = "******"
        self.PASSWORD = os.environ['PASSWORD']
        self.CURRENT_DIALOG_URL = ""
        self.URL_OF_MESSAGES = "https://ok.ru/messages"
        self.ANOTHER_MESSAGE_TEXT = 'new pinned'
        self.NEW_ENG_TITLE = "Avengers: Infinity War"
        self.NEW_RUS_TITLE = u"Мстители: Война Бесконечности"
        self.NEW_CHINE_TITLE = u"复仇者:无穷的战争"
        self.NEW_TOO_LONG_TITLE = "Avengers: It is really " + "infinity " * 42 + "War"
        self.MAX_TITLE_LENGTH = 200

        self.dialog_page = DialogPage(self.driver)
        self.message_page = MessagePage(self.driver)
        self.auth_page = AuthPage(self.driver)
        self.auth_page.sign_in(self.BOT_1_LOGIN, self.PASSWORD)
        self.main_page = MainPage(self.driver)
        self.main_page.open_messages()
        self.create_dialog()
        self.dialog_page.add_user_to_chat()        
    def setUp(self):
        browser = os.environ.get('BROWSER', os.environ['BROWSER'])

        self.driver = Remote(command_executor='http://127.0.0.1:4444/wd/hub',
                             desired_capabilities=getattr(
                                 DesiredCapabilities, browser).copy())
        self.driver.maximize_window()

        self.BOT_1_LOGIN = "******"
        self.PASSWORD = os.environ['PASSWORD']
        self.CURRENT_DIALOG_URL = ""

        self.USUAL_MESSAGE_TEXT = 'USUAL TEXT'
        self.CHINESE_TEXT = u'測試漢字'
        self.EMPTY_MESSAGE_TEXT = ''
        self.LONG_VALID_MESSAGE = '_123' * 512
        self.LONG_INVALID_MESSAGE = '_123' * 1024
        self.MESSAGE_EDITED_TEXT = ' IS_EDITED'
        self.MESSAGE_ANSWERED_TEXT = ' IS_ANSWERED'
        self.APPLICATION_ID_1 = "1247868160"
        self.APPLICATION_ID_2 = "1249037824"
        self.APPLICATION_ID_3 = "1248235008"
        self.SEARCH_REQUEST = u"желаю"
        self.BAD_SEARCH_REQUEST = "definitely not exist"

        self.dialog_page = DialogPage(self.driver)
        self.message_page = MessagePage(self.driver)
        self.auth_page = AuthPage(self.driver)
        self.auth_page.sign_in(self.BOT_1_LOGIN, self.PASSWORD)
        self.main_page = MainPage(self.driver)
        self.main_page.open_messages()
        self.create_dialog()
        self.CURRENT_DIALOG_URL = self.driver.current_url
Example #3
0
    def setUp(self):
        browser = os.environ.get('BROWSER', os.environ['BROWSER'])

        self.driver = Remote(
            command_executor='http://127.0.0.1:4444/wd/hub',
            desired_capabilities=getattr(DesiredCapabilities, browser).copy()
        )
        self.driver.maximize_window()

        self.BOT_1_LOGIN = "******"
        self.PASSWORD = os.environ['PASSWORD']
        self.CURRENT_DIALOG_URL = ""

        self.dialog_page = DialogPage(self.driver)
        self.message_page = MessagePage(self.driver)
        self.auth_page = AuthPage(self.driver)
        self.auth_page.sign_in(self.BOT_1_LOGIN, self.PASSWORD)
        self.main_page = MainPage(self.driver)
        self.main_page.open_messages()

        self.MESSAGE_TEXT = "testNumber1"
        self.RED_POWER = u"☭☭☭☭☭☭"
        self.URL_OF_MESSAGES = "https://ok.ru/messages"

        self.create_dialog()
        self.CURRENT_DIALOG_URL = self.driver.current_url
    def setUp(self):
        browser = os.environ.get('BROWSER', os.environ['BROWSER'])

        self.driver = Remote(
            command_executor='http://127.0.0.1:4444/wd/hub',
            desired_capabilities=getattr(DesiredCapabilities, browser).copy()
        )
        self.driver.maximize_window()

        self.MESSAGE_TEXT = "testNumber1"
        self.LONG_MESSAGE_TEXT = "test" * 100
        self.RED_POWER = u"☭☭☭☭☭☭"  # special unicode
        self.RUSSIAN_ARMENIAN_MESSAGE = u"привет աշխարհ"
        self.NOT_VALID_MESSAGE = "?" * 4100
        self.EMPTY_MESSAGE = ""

        self.BOT_1_LOGIN = "******"
        self.BOT_2_LOGIN = "******"
        self.PASSWORD = os.environ['PASSWORD']
        self.CURRENT_DIALOG_URL = ""

        self.dialog_page = DialogPage(self.driver)
        self.message_page = MessagePage(self.driver)
        self.auth_page = AuthPage(self.driver)
        self.auth_page.sign_in(self.BOT_1_LOGIN, self.PASSWORD)
        self.main_page = MainPage(self.driver)
        self.main_page.open_messages()
        self.URL_OF_DIALOG_WITH_ME = "https://ok.ru/messages/575662066926"
        self.URL_OF_MESSAGES = "https://ok.ru/messages"

        self.NEED_TO_BLOCK_USER = False
        self.NEED_TO_CHANGE_ACC = False

        self.create_dialog()
        self.CURRENT_DIALOG_URL = self.driver.current_url
    def setUp(self):
        browser = os.environ.get('BROWSER', os.environ['BROWSER'])

        self.driver = Remote(
            command_executor='http://127.0.0.1:4444/wd/hub',
            desired_capabilities=getattr(DesiredCapabilities, browser).copy()
        )
        self.driver.maximize_window()

        self.BOT_1_LOGIN = "******"
        self.PASSWORD = os.environ['PASSWORD']
        self.CURRENT_DIALOG_URL = ""
        self.STICKERS_NEW_SET_ID = "2"
        self.STICKERS_OLD_SET_ID = "35"
        self.STICKERS_PAY_SET_ID = "42"

        self.dialog_page = DialogPage(self.driver)
        self.message_page = MessagePage(self.driver)
        self.auth_page = AuthPage(self.driver)
        self.auth_page.sign_in(self.BOT_1_LOGIN, self.PASSWORD)
        self.main_page = MainPage(self.driver)
        self.main_page.open_messages()

        self.create_dialog()
        self.CURRENT_DIALOG_URL = self.driver.current_url
Example #6
0
    def setUp(self):
        self.driver = Remote(
            command_executor='http://127.0.0.1:4444/wd/hub',
            desired_capabilities=getattr(DesiredCapabilities, self.BROWSER)
        )
        auth_page = AuthPage(self.driver)
        auth_page.sign_in(self.LOGIN, self.PASSWORD)

        main_page = MainPage(self.driver)
        self.assertTrue(main_page.is_authorized(), 'user authorized')
Example #7
0
    def sign_in(self, login, password):
        self.driver.get(self.url)

        login_form = LoginForm(self.driver)

        login_field = login_form.login_input().wait_for_clickable().get()
        login_field.click()
        login_field.clear()
        login_field.send_keys(login)

        password_field = login_form.password_input().wait_for_visible().get()
        password_field.click()
        password_field.clear()
        password_field.send_keys(password)

        login_form.sign_in_button().wait_for_visible().get().click()

        MainPage(self.driver).wait_username()
Example #8
0
class TestsStickers(unittest.TestCase):
    def setUp(self):
        browser = os.environ.get('BROWSER', os.environ['BROWSER'])

        self.driver = Remote(command_executor='http://127.0.0.1:4444/wd/hub',
                             desired_capabilities=getattr(
                                 DesiredCapabilities, browser).copy())
        self.driver.maximize_window()

        self.BOT_1_LOGIN = "******"
        self.PASSWORD = os.environ['PASSWORD']
        self.CURRENT_DIALOG_URL = ""
        self.STICKERS_NEW_SET_ID = "2"
        self.STICKERS_OLD_SET_ID = "35"
        self.STICKERS_PAY_SET_ID = "42"

        self.dialog_page = DialogPage(self.driver)
        self.message_page = MessagePage(self.driver)
        self.auth_page = AuthPage(self.driver)
        self.auth_page.sign_in(self.BOT_1_LOGIN, self.PASSWORD)
        self.main_page = MainPage(self.driver)
        self.main_page.open_messages()

        self.create_dialog()
        self.CURRENT_DIALOG_URL = self.driver.current_url

    def tearDown(self):
        self.driver.get(self.CURRENT_DIALOG_URL)
        self.delete_dialog()
        self.driver.quit()

    def create_dialog(self):
        self.message_page.create_dialog()
        self.message_page.choose_companion()
        self.dialog_page.wait_for_loader()

    def delete_dialog(self):
        self.dialog_page.open_menu()
        dilog_menu_page = DialogMenuPage(self.driver)
        dilog_menu_page.delete_dialog()
        confirm_page = ConfirmPage(self.driver)
        confirm_page.confirm()

    def test_send_usmile_sticker(self):
        self.dialog_page.send_sticker("USMILE_STICKER")
        self.assertTrue(self.dialog_page.message_with_sticker_exists(),
                        "test_send_usmile_sticker failed")

    def test_send_usmile_2_sticker(self):
        self.dialog_page.send_sticker("USMILE_STICKER_2")
        self.assertTrue(self.dialog_page.message_with_sticker_exists(),
                        "test_send_usmile_2_sticker failed")

    def test_send_dog_sticker(self):
        self.dialog_page.send_sticker("DOG_STICKER")
        self.assertTrue(self.dialog_page.message_with_sticker_exists(),
                        "test_send_dog_sticker failed")

    def test_send_fox_sticker(self):
        self.dialog_page.send_sticker("FOX_STICKER")
        self.assertTrue(self.dialog_page.message_with_sticker_exists(),
                        "test_send_fox_sticker failed")

    def test_send_heart_sticker(self):
        self.dialog_page.send_sticker("HEART_STICKER")
        self.assertTrue(self.dialog_page.message_with_sticker_exists(),
                        "test_send_heart_sticker failed")

    # You have my respect, Stark. When I'm done, half of
    # humanity will still be alive. I hope they remember you. (c) Thanos

    def test_add_stickers_set(self):
        set_id = self.STICKERS_NEW_SET_ID
        self.assertFalse(self.dialog_page.check_stickers_set(set_id),
                         "testing stickers set already exists")
        self.dialog_page.install_stickers_set(set_id)
        self.assertTrue(self.dialog_page.check_stickers_set(set_id),
                        "can't add new sticker set #" + set_id)
        self.dialog_page.uninstall_stickers_set(set_id)

    def test_delete_sticker_set(self):
        set_id = self.STICKERS_OLD_SET_ID
        self.assertTrue(self.dialog_page.check_stickers_set(set_id),
                        "default stickers set is not exist")
        self.dialog_page.uninstall_stickers_set(set_id)
        self.assertFalse(self.dialog_page.check_stickers_set(set_id),
                         "Can't delete sticker set #" + set_id)
        self.dialog_page.install_stickers_set(set_id)

    def test_add_paid_stickers_set(self):
        set_id = self.STICKERS_PAY_SET_ID
        self.assertFalse(self.dialog_page.check_stickers_set(set_id),
                         "pay stickers set already exists #" + set_id)
        self.dialog_page.install_stickers_set(set_id)
        self.assertTrue(self.dialog_page.check_stickers_set(set_id),
                        "can't add new pay sticker set #" + set_id)
        self.dialog_page.uninstall_stickers_set(set_id)

    def test_delete_sticker_pack(self):
        set_id = self.STICKERS_NEW_SET_ID
        self.dialog_page.install_stickers_set(set_id)
        self.dialog_page.uninstall_stickers_set(set_id)
        self.assertTrue(not self.dialog_page.check_stickers_set(set_id),
                        "test_delete_sticker_pack failed")

    def test_installx2_deletex2_sticker_pack(self):
        set_id1 = self.STICKERS_NEW_SET_ID
        set_id2 = self.STICKERS_OLD_SET_ID

        self.dialog_page.install_stickers_set(set_id1)
        self.dialog_page.install_stickers_set(set_id2)
        self.dialog_page.uninstall_stickers_set(set_id1)
        self.dialog_page.uninstall_stickers_set(set_id2)

        self.assertTrue(not self.dialog_page.check_stickers_set(set_id1),
                        "test_delete_sticker_pack failed")
        self.assertTrue(not self.dialog_page.check_stickers_set(set_id2),
                        "test_delete_sticker_pack failed")

    def test_install_delete_x2_sticker_pack(self):
        set_id1 = self.STICKERS_NEW_SET_ID
        set_id2 = self.STICKERS_OLD_SET_ID

        self.dialog_page.install_stickers_set(set_id1)
        self.dialog_page.uninstall_stickers_set(set_id1)
        self.assertTrue(not self.dialog_page.check_stickers_set(set_id1),
                        "test_delete_sticker_pack failed")

        self.dialog_page.install_stickers_set(set_id2)
        self.dialog_page.uninstall_stickers_set(set_id2)
        self.assertTrue(not self.dialog_page.check_stickers_set(set_id2),
                        "test_delete_sticker_pack failed")

    def test_sticker_bar(self):
        self.dialog_page.hide_sticker_bar()
        self.assertTrue(self.dialog_page.sticker_bar_exists(),
                        "test_sticker_bar failed")

    def test_hidex2_sticker_bar(self):
        self.dialog_page.hide_sticker_bar()
        self.dialog_page.open_sticker_bar()
        self.dialog_page.hide_sticker_bar()
        self.assertTrue(self.dialog_page.sticker_bar_exists(),
                        "test_sticker_bar failed")

    def test_send_animation_smile(self):
        self.dialog_page.send_animation_smile()
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_animation_smile failed")

    def test_send_OK_smile(self):
        self.dialog_page.send_OK_smile()
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_OK_smile failed")

    def test_send_people_smile(self):
        self.dialog_page.send_people_smile()
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_people_smile failed")

    def test_send_nature_smile(self):
        self.dialog_page.send_nature_smile()
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_nature_smile failed")

    def test_send_object_smile(self):
        self.dialog_page.send_object_smile()
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_object_smile failed")

    def test_send_places_smile(self):
        self.dialog_page.send_places_smile()
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_places_smile failed")

    def test_send_symbols_smile(self):
        self.dialog_page.send_symbols_smile()
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_symbols_smile failed")

    def test_send_sticker1_from_bar(self):
        self.dialog_page.send_sticker1_from_bar()
        self.assertTrue(self.dialog_page.message_with_sticker_exists(),
                        "test_send_sticker1_from_bar failed")

    def test_send_sticker2_from_bar(self):
        self.dialog_page.send_sticker2_from_bar()
        self.assertTrue(self.dialog_page.message_with_sticker_exists(),
                        "test_send_sticker2_from_bar failed")

    def test_send_sticker_from_hide_bar(self):
        self.dialog_page.hide_sticker_bar()
        self.assertTrue(self.dialog_page.sticker_bar_exists(),
                        "test_send_sticker_from_hide_bar failed")
        self.assertTrue(not self.dialog_page.sticker_in_bar_exists(),
                        "test_send_sticker_from_hide_bar failed")

    def test_send_sticker_x2_from_bar(self):
        self.dialog_page.send_sticker1_from_bar()
        self.assertTrue(self.dialog_page.message_with_sticker_exists(),
                        "test_send_sticker_x2_from_bar failed")
        self.dialog_page.send_sticker2_from_bar()
        self.assertTrue(self.dialog_page.message_with_sticker_exists(),
                        "test_send_sticker_x2_from_bar failed")
class TestsSendMessages(unittest.TestCase):
    def setUp(self):
        browser = os.environ.get('BROWSER', os.environ['BROWSER'])

        self.driver = Remote(command_executor='http://127.0.0.1:4444/wd/hub',
                             desired_capabilities=getattr(
                                 DesiredCapabilities, browser).copy())
        self.driver.maximize_window()

        self.BOT_1_LOGIN = "******"
        self.PASSWORD = os.environ['PASSWORD']
        self.CURRENT_DIALOG_URL = ""

        self.USUAL_MESSAGE_TEXT = 'USUAL TEXT'
        self.CHINESE_TEXT = u'測試漢字'
        self.EMPTY_MESSAGE_TEXT = ''
        self.LONG_VALID_MESSAGE = '_123' * 512
        self.LONG_INVALID_MESSAGE = '_123' * 1024
        self.MESSAGE_EDITED_TEXT = ' IS_EDITED'
        self.MESSAGE_ANSWERED_TEXT = ' IS_ANSWERED'
        self.APPLICATION_ID_1 = "1247868160"
        self.APPLICATION_ID_2 = "1249037824"
        self.APPLICATION_ID_3 = "1248235008"
        self.SEARCH_REQUEST = u"желаю"
        self.BAD_SEARCH_REQUEST = "definitely not exist"

        self.dialog_page = DialogPage(self.driver)
        self.message_page = MessagePage(self.driver)
        self.auth_page = AuthPage(self.driver)
        self.auth_page.sign_in(self.BOT_1_LOGIN, self.PASSWORD)
        self.main_page = MainPage(self.driver)
        self.main_page.open_messages()
        self.create_dialog()
        self.CURRENT_DIALOG_URL = self.driver.current_url

    def tearDown(self):
        self.driver.get(self.CURRENT_DIALOG_URL)
        self.delete_dialog()
        self.driver.quit()

    def create_dialog(self):
        self.message_page.create_dialog()
        self.message_page.choose_companion()
        self.dialog_page.wait_for_loader()

    def delete_dialog(self):
        self.dialog_page.open_menu()
        dilog_menu_page = DialogMenuPage(self.driver)
        dilog_menu_page.delete_dialog()
        confirm_page = ConfirmPage(self.driver)
        confirm_page.confirm()

    def test_send_usual_message(self):
        self.dialog_page.send_message(self.USUAL_MESSAGE_TEXT)
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test send usual message failed")

    def test_send_empty_message(self):
        self.dialog_page.send_message(self.EMPTY_MESSAGE_TEXT)
        self.assertFalse(self.dialog_page.sent_message_exists(),
                         "test send empty message failed")

    def test_send_unicode_message(self):
        self.dialog_page.send_message(self.CHINESE_TEXT)
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test send unicode message failed")

    def test_send_long_valid_message(self):
        self.dialog_page.send_message(self.LONG_VALID_MESSAGE)
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test send long valid message failed")

    def test_send_long_invalid_message(self):
        self.dialog_page.send_message(self.LONG_INVALID_MESSAGE)
        self.assertTrue(self.dialog_page.long_message_error_exists(),
                        "test send long invalid message failed")

    def test_usual_edit_usual_message(self):
        self.dialog_page.send_message(self.USUAL_MESSAGE_TEXT)
        self.dialog_page.edit_and_send_message(self.MESSAGE_EDITED_TEXT)
        self.driver.refresh()
        self.assertEquals(self.dialog_page.get_sent_message_text(),
                          self.USUAL_MESSAGE_TEXT + self.MESSAGE_EDITED_TEXT)

    def test_empty_edit_unicode_message(self):
        self.dialog_page.send_message(self.CHINESE_TEXT)
        self.dialog_page.edit_and_send_message(self.EMPTY_MESSAGE_TEXT)
        self.driver.refresh()
        self.assertEquals(self.dialog_page.get_sent_message_text(),
                          self.CHINESE_TEXT + self.EMPTY_MESSAGE_TEXT)

    def test_unicode_edit_unicode_message(self):
        self.dialog_page.send_message(self.CHINESE_TEXT)
        self.dialog_page.edit_and_send_message(self.CHINESE_TEXT)
        self.driver.refresh()
        self.assertEquals(self.dialog_page.get_sent_message_text(),
                          self.CHINESE_TEXT + self.CHINESE_TEXT)

    def test_usual_answer_unicode_message(self):
        self.dialog_page.send_message(self.CHINESE_TEXT)
        self.dialog_page.answer_message(self.MESSAGE_ANSWERED_TEXT)
        self.driver.refresh()
        self.assertTrue(self.dialog_page.get_exsistance_of_answered_message(),
                        "test_usual_answer_message failed")

    def test_unicode_answer_usual_message(self):
        self.dialog_page.send_message(self.USUAL_MESSAGE_TEXT)
        self.dialog_page.answer_message(self.CHINESE_TEXT)
        self.driver.refresh()
        self.assertTrue(self.dialog_page.get_exsistance_of_answered_message(),
                        "test_unicode_answer_message failed")

    def test_forward_usual_message(self):
        self.dialog_page.send_message(self.USUAL_MESSAGE_TEXT)
        self.dialog_page.forward_message()
        self.message_page.choose_companion_forward_message()
        self.driver.refresh()
        self.assertTrue(self.dialog_page.get_exsistance_of_forwarded_message(),
                        "test_forward_message failed")

    def test_forward_unicode_message(self):
        self.dialog_page.send_message(self.CHINESE_TEXT)
        self.dialog_page.forward_message()
        self.message_page.choose_companion_forward_message()
        self.driver.refresh()
        self.assertTrue(self.dialog_page.get_exsistance_of_forwarded_message(),
                        "test_forward_message failed")

    def test_delete_usual_message(self):
        self.dialog_page.send_message(self.USUAL_MESSAGE_TEXT)
        self.dialog_page.delete_message()
        self.driver.refresh()
        self.assertTrue(self.dialog_page.no_messages_text_exists(),
                        "test_delete_message failed")

    def test_send_chocolate_smile(self):
        self.dialog_page.send_chocolate_smile()
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_smile failed")

    def test_send_whale_smile(self):
        self.dialog_page.send_whale_smile()
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_whale_smile failed")

    def test_send_many_smiles(self):
        self.dialog_page.send_combo_wombo_smile()
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_many_smile failed")

    # I'm a f*****g game developer
    def test_appearance_of_game_invite(self):
        self.dialog_page.invite_game(self.APPLICATION_ID_1)
        self.assertTrue(self.dialog_page.existence_game_invite_in_dialog(),
                        "test_appearance_of_game_invite failed")
        self.dialog_page.close_game()
        self.dialog_page.reject_game_invite(self.APPLICATION_ID_1)

    def test_game_close(self):
        app_id = self.APPLICATION_ID_2
        self.dialog_page.invite_game(app_id)
        self.assertTrue(self.dialog_page.find_game_invite_by_id(app_id),
                        "Game has not opened")
        self.dialog_page.close_game()
        self.assertFalse(self.dialog_page.existence_game(app_id),
                         "Game has not closed")
        self.dialog_page.reject_game_invite(app_id)

    def test_game_invite_1(self):
        app_id = self.APPLICATION_ID_1
        self.dialog_page.invite_game(app_id)
        self.assertTrue(self.dialog_page.existence_game_invite_in_dialog(),
                        "Invite in game #" + app_id + " failed")
        self.assertTrue(self.dialog_page.existence_game(app_id),
                        "test_game_invite_1 failed")
        self.dialog_page.close_game()
        self.dialog_page.reject_game_invite(app_id)

    def test_game_invite_2(self):
        app_id = self.APPLICATION_ID_2
        self.dialog_page.invite_game(app_id)
        self.assertTrue(self.dialog_page.existence_game_invite_in_dialog(),
                        "Invite in game #" + app_id + " failed")
        self.assertTrue(self.dialog_page.existence_game(app_id),
                        "test_game_invite_2 failed")
        self.dialog_page.close_game()
        self.dialog_page.reject_game_invite(app_id)

    def test_game_invite_3(self):
        app_id = self.APPLICATION_ID_3
        self.dialog_page.invite_game(app_id)
        self.assertTrue(self.dialog_page.existence_game_invite_in_dialog(),
                        "Invite in game #" + app_id + " failed")
        self.assertTrue(self.dialog_page.existence_game(app_id),
                        "test_game_invite_2 failed")
        self.dialog_page.close_game()
        self.dialog_page.reject_game_invite(app_id)

    def test_game_several_game_invites(self):
        app_ids = [
            self.APPLICATION_ID_1, self.APPLICATION_ID_2, self.APPLICATION_ID_3
        ]
        for app_id in app_ids:
            self.dialog_page.invite_game(app_id)
            self.assertTrue(self.dialog_page.find_game_invite_by_id(app_id),
                            "Game with app_id=" + app_id + " is not opened")
            self.dialog_page.close_game()
            self.dialog_page.reject_game_invite(app_id)

    def test_game_invite_apply(self):
        app_id = self.APPLICATION_ID_1
        self.dialog_page.invite_game(app_id)
        self.assertTrue(self.dialog_page.find_game_invite_by_id(app_id),
                        "game #" + app_id + " is not opened")

        self.dialog_page.close_game()
        self.dialog_page.apply_game_invite(app_id)
        self.assertTrue(
            self.dialog_page.existence_game(app_id),
            "Enter in the game #" + app_id + " by button is failed")
        self.dialog_page.close_game()
        self.dialog_page.reject_game_invite(app_id)

    def test_game_invite_reject(self):
        app_id = self.APPLICATION_ID_2
        self.dialog_page.invite_game(app_id)
        self.assertTrue(self.dialog_page.find_game_invite_by_id(app_id),
                        "game #" + app_id + " is not opened")

        self.dialog_page.close_game()
        self.dialog_page.reject_game_invite(app_id)
        self.assertTrue(self.dialog_page.existence_play_again_button(),
                        "test_game_invite_reject failed")

    def test_game_invite_play_again(self):
        app_id = self.APPLICATION_ID_2
        self.dialog_page.invite_game(app_id)

        self.assertTrue(self.dialog_page.existence_game_invite_in_dialog(),
                        "game is not opened")
        self.dialog_page.close_game()
        self.dialog_page.reject_game_invite(app_id)
        self.dialog_page.play_again_game_invite(app_id)
        self.assertTrue(self.dialog_page.existence_game(app_id),
                        "game #" + app_id + " is not reopened")
        self.dialog_page.close_game()

    def test_open_avatar(self):
        self.dialog_page.open_menu()
        self.dialog_page.open_avatar()
        self.assertTrue(self.dialog_page.existence_big_avatar(),
                        "test_open_original_photo failed")

    def test_send_postcard(self):
        self.dialog_page.send_postcard()
        self.assertTrue(self.dialog_page.check_sending_postcard(),
                        "test_send_postcard failed")

    def test_postcards_search(self):
        self.dialog_page.search_postcards(self.SEARCH_REQUEST)
        self.assertFalse(self.dialog_page.is_empty_postcard_search(),
                         "test_postcards_search failed")

    def test_postcards_search_by_suggest(self):
        self.dialog_page.search_postcards_by_suggest()
        self.assertFalse(self.dialog_page.is_empty_postcard_search(),
                         "test_postcards_search_by_suggest failed")

    def test_postcards_bad_search(self):
        self.dialog_page.search_postcards(self.BAD_SEARCH_REQUEST)
        self.assertTrue(self.dialog_page.is_empty_postcard_search(),
                        "test_postcards_bad_search failed")

    def test_postcards_search_and_send(self):
        self.dialog_page.find_and_send_postcard(self.SEARCH_REQUEST)
        self.assertTrue(self.dialog_page.check_sending_postcard(),
                        "test_postcards_search_and_send failed")
Example #10
0
class TestsFindDialogMsg(unittest.TestCase):

    def setUp(self):
        browser = os.environ.get('BROWSER', os.environ['BROWSER'])

        self.driver = Remote(
            command_executor='http://127.0.0.1:4444/wd/hub',
            desired_capabilities=getattr(DesiredCapabilities, browser).copy()
        )
        self.driver.maximize_window()

        self.BOT_1_LOGIN = "******"
        self.PASSWORD = os.environ['PASSWORD']
        self.CURRENT_DIALOG_URL = ""

        self.dialog_page = DialogPage(self.driver)
        self.message_page = MessagePage(self.driver)
        self.auth_page = AuthPage(self.driver)
        self.auth_page.sign_in(self.BOT_1_LOGIN, self.PASSWORD)
        self.main_page = MainPage(self.driver)
        self.main_page.open_messages()

        self.MESSAGE_TEXT = "testNumber1"
        self.RED_POWER = u"☭☭☭☭☭☭"
        self.URL_OF_MESSAGES = "https://ok.ru/messages"

        self.create_dialog()
        self.CURRENT_DIALOG_URL = self.driver.current_url

    def tearDown(self):
        self.driver.get(self.CURRENT_DIALOG_URL)
        self.delete_dialog()
        self.driver.quit()

    def create_dialog(self):
        self.message_page.create_dialog()
        self.message_page.choose_companion()
        self.dialog_page.wait_for_loader()

    def delete_dialog(self):
        self.dialog_page.open_menu()
        dilog_menu_page = DialogMenuPage(self.driver)
        dilog_menu_page.delete_dialog()
        confirm_page = ConfirmPage(self.driver)
        confirm_page.confirm()

    def test_find_message(self):
        self.dialog_page.send_message(self.MESSAGE_TEXT)
        self.dialog_page.find_message(self.MESSAGE_TEXT)
        self.assertEquals(
            self.MESSAGE_TEXT,
            self.message_page.get_found_message_text())

    def test_wrong_find_message(self):
        self.dialog_page.send_message(self.MESSAGE_TEXT)
        self.driver.get(self.URL_OF_MESSAGES)
        self.dialog_page.find_message(self.RED_POWER)
        self.assertTrue(
            self.message_page.get_existance_of_dialogs_empty(),
            "test_wrong_find_message failed")

    def test_find_dialog(self):
        dialog_name = self.dialog_page.get_dialog_name()
        self.dialog_page.find_dialog(dialog_name)
        self.assertTrue(
            self.message_page.get_existance_of_search_result(),
            "test_find_dialog failed")

    def test_wrong_find_dialog(self):
        self.dialog_page.send_message(self.MESSAGE_TEXT)
        dialog_name = self.dialog_page.get_dialog_name()
        self.driver.get(self.URL_OF_MESSAGES)
        self.dialog_page.find_dialog(self.RED_POWER)
        self.assertTrue(
            self.message_page.get_existance_of_dialogs_empty(),
            "test_find_dialog failed")
class TestsGroupDialogs(unittest.TestCase):

    def setUp(self):
        browser = os.environ.get('BROWSER', os.environ['BROWSER'])

        self.driver = Remote(
            command_executor='http://127.0.0.1:4444/wd/hub',
            desired_capabilities=getattr(DesiredCapabilities, browser).copy()
        )
        self.driver.maximize_window()

        self.MESSAGE_TEXT = "testNumber1"
        self.BOT_1_LOGIN = "******"
        self.PASSWORD = os.environ['PASSWORD']
        self.CURRENT_DIALOG_URL = ""
        self.URL_OF_MESSAGES = "https://ok.ru/messages"
        self.ANOTHER_MESSAGE_TEXT = 'new pinned'
        self.NEW_ENG_TITLE = "Avengers: Infinity War"
        self.NEW_RUS_TITLE = u"Мстители: Война Бесконечности"
        self.NEW_CHINE_TITLE = u"复仇者:无穷的战争"
        self.NEW_TOO_LONG_TITLE = "Avengers: It is really " + "infinity " * 42 + "War"
        self.MAX_TITLE_LENGTH = 200

        self.dialog_page = DialogPage(self.driver)
        self.message_page = MessagePage(self.driver)
        self.auth_page = AuthPage(self.driver)
        self.auth_page.sign_in(self.BOT_1_LOGIN, self.PASSWORD)
        self.main_page = MainPage(self.driver)
        self.main_page.open_messages()
        self.create_dialog()
        self.dialog_page.add_user_to_chat()        

    def create_dialog(self):
        self.message_page.create_dialog()
        self.message_page.choose_companion()
        self.dialog_page.wait_for_loader()

    def tearDown(self):
        self.driver.get(self.CURRENT_DIALOG_URL)
        self.leave_group_chat()
        self.driver.quit()

    def leave_group_chat(self):
        self.dialog_page.open_menu()
        dilog_menu_page = DialogMenuPage(self.driver)
        dilog_menu_page.leave_chat()
        confirm_page = ConfirmPage(self.driver)
        confirm_page.confirm()

    def test_add_user_to_group_chat(self):
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.assertTrue(
            self.dialog_page.get_exsistance_of_created_group_dialog(),
            "test_add_user_to_group_chat failed")

    def test_delete_user_from_group_chat(self):
        self.dialog_page.delete_user_from_chat()
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.assertTrue(
            self.dialog_page.get_exsistance_of_delte_companion(),
            "test_delete_user_from_group_chat failed")

    def test_hide_group_chat(self):
        self.dialog_page.wait_for_loader()
        self.dialog_page.open_menu()
        dilog_menu_page = DialogMenuPage(self.driver)
        dilog_menu_page.hide_chat()

        hide_chat_confirm_page = ConfirmPage(self.driver)
        hide_chat_confirm_page.confirm()
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.driver.get(self.URL_OF_MESSAGES)
        self.assertTrue(
            self.message_page.get_existance_of_dialogs_empty(),
            "test_hide_group_chat failed")

    def test_pin_message(self):
        self.dialog_page.wait_for_loader()
        self.dialog_page.send_message(self.MESSAGE_TEXT)
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.dialog_page.pin_message()
        self.assertTrue(
            self.dialog_page.exsistance_of_pinned_message(),
            "test_pin_message failed")

    def test_change_pinned_message(self):
        self.dialog_page.wait_for_loader()
        self.dialog_page.send_message(self.MESSAGE_TEXT)
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.dialog_page.pin_message()
        self.dialog_page.send_message(self.ANOTHER_MESSAGE_TEXT)
        self.dialog_page.delete_message()
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.dialog_page.pin_message()
        self.assertTrue(
            self.dialog_page.exsistance_of_pinned_message(),
            "test_change_pinned_message failed")

    def test_unpin_message(self):
        self.dialog_page.wait_for_loader()
        self.dialog_page.send_message(self.MESSAGE_TEXT)
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.dialog_page.pin_message()
        self.dialog_page.unpin_message()
        self.driver.refresh()
        self.assertFalse(
            self.dialog_page.exsistance_of_pinned_message(),
            "test_unpin_message failed")

    # There was an idea, to bring together a group of remarkable people.
    # To see if could become something more. And when they needed us,
    # we can fight the battles, that they never could. (c) Infinity War

    def test_change_title(self):
        self.dialog_page.wait_for_loader()
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.dialog_page.open_menu()
        dialog_menu_page = DialogMenuPage(self.driver)
        dialog_menu_page.change_title(self.NEW_ENG_TITLE)
        title = dialog_menu_page.get_title()
        self.assertEqual(self.NEW_ENG_TITLE, title)

    def test_set_rus_title(self):
        self.dialog_page.wait_for_loader()
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.dialog_page.open_menu()
        dialog_menu_page = DialogMenuPage(self.driver)
        dialog_menu_page.change_title(self.NEW_RUS_TITLE)
        title = dialog_menu_page.get_title()
        self.assertEqual(self.NEW_RUS_TITLE, title)

    def test_set_chine_title(self):
        self.dialog_page.wait_for_loader()
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.dialog_page.open_menu()
        dialog_menu_page = DialogMenuPage(self.driver)
        dialog_menu_page.change_title(self.NEW_CHINE_TITLE)
        title = dialog_menu_page.get_title()
        self.assertEqual(self.NEW_CHINE_TITLE, title)

    def test_set_empty_title(self):
        self.dialog_page.wait_for_loader()
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.dialog_page.open_menu()
        dialog_menu_page = DialogMenuPage(self.driver)
        old_title = dialog_menu_page.get_title()
        dialog_menu_page.change_title("")
        new_title = dialog_menu_page.get_title()
        self.assertEqual(old_title, new_title)

    def test_set_too_long_title(self):
        self.dialog_page.wait_for_loader()
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.dialog_page.open_menu()
        dialog_menu_page = DialogMenuPage(self.driver)
        dialog_menu_page.change_title(self.NEW_TOO_LONG_TITLE)
        new_title = dialog_menu_page.get_title()
        cut_title = self.NEW_TOO_LONG_TITLE[:self.MAX_TITLE_LENGTH]
        self.assertEqual(new_title, cut_title)

    def test_change_title_several_times(self):
        self.dialog_page.wait_for_loader()
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.dialog_page.open_menu()
        dialog_menu_page = DialogMenuPage(self.driver)
        dialog_menu_page.change_title(self.NEW_RUS_TITLE)
        dialog_menu_page.change_title(self.NEW_CHINE_TITLE)
        dialog_menu_page.change_title(self.NEW_ENG_TITLE)
        title = dialog_menu_page.get_title()
        self.assertEqual(self.NEW_ENG_TITLE, title)

    # I know what it’s like to lose. To feel so desperately that you’re right,
    # yet to fail nonetheless. Dread it, run from it, destiny arrives all the same. (c) Thanos

    def test_set_dialog_photo_of_mad_titan(self):
        self.dialog_page.wait_for_loader()
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.dialog_page.open_menu()
        dialog_menu_page = DialogMenuPage(self.driver)
        dialog_menu_page.change_photo(os.getcwd() + "/tests/static/thanos.jpg")
        self.assertTrue(
            self.dialog_page.existence_change_photo_notification(),
            "Failed to update photo of group dialog")

    def test_update_dialog_photo_2(self):
        self.dialog_page.wait_for_loader()
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.dialog_page.open_menu()
        dialog_menu_page = DialogMenuPage(self.driver)
        dialog_menu_page.change_photo(os.getcwd() + "/tests/static/sabaton_high.jpg")
        self.assertTrue(
            self.dialog_page.existence_change_photo_notification(),
            "Failed to update photo_2 of group dialog")

    def test_update_dialog_photo_jpeg(self):
        self.dialog_page.wait_for_loader()
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.dialog_page.open_menu()
        dialog_menu_page = DialogMenuPage(self.driver)
        dialog_menu_page.change_photo(os.getcwd() + "/tests/static/sabaton_low.jpeg")
        self.assertTrue(
            self.dialog_page.existence_change_photo_notification(),
            "Failed to update photo.jpeg of group dialog")

    def test_update_dialog_photo_png(self):
        self.dialog_page.wait_for_loader()
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.dialog_page.open_menu()
        dialog_menu_page = DialogMenuPage(self.driver)
        dialog_menu_page.change_photo(os.getcwd() + "/tests/static/sabaton_png.png")
        self.assertTrue(
            self.dialog_page.existence_change_photo_notification(),
            "Failed to update photo.png of group dialog")

    def test_update_dialog_photo_invalid_format_1(self):
        self.dialog_page.wait_for_loader()
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.dialog_page.open_menu()
        dialog_menu_page = DialogMenuPage(self.driver)
        dialog_menu_page.change_photo(os.getcwd() + "/tests/static/awd.txt")
        err_msg = dialog_menu_page.get_message_of_error_notification()
        self.assertEquals(err_msg, u"Файл неверного типа.")

    def test_update_dialog_photo_invalid_format_2(self):
        self.dialog_page.wait_for_loader()
        self.CURRENT_DIALOG_URL = self.driver.current_url
        self.dialog_page.open_menu()
        dialog_menu_page = DialogMenuPage(self.driver)
        dialog_menu_page.change_photo(os.getcwd() + "/tests/static/sabaton_high.mp4")
        err_msg = dialog_menu_page.get_message_of_error_notification()
        self.assertEquals(err_msg, u"Файл неверного типа.")
class TwoAccauntsManagement(unittest.TestCase):

    def setUp(self):
        browser = os.environ.get('BROWSER', os.environ['BROWSER'])

        self.driver = Remote(
            command_executor='http://127.0.0.1:4444/wd/hub',
            desired_capabilities=getattr(DesiredCapabilities, browser).copy()
        )
        self.driver.maximize_window()

        self.MESSAGE_TEXT = "testNumber1"
        self.LONG_MESSAGE_TEXT = "test" * 100
        self.RED_POWER = u"☭☭☭☭☭☭"  # special unicode
        self.RUSSIAN_ARMENIAN_MESSAGE = u"привет աշխարհ"
        self.NOT_VALID_MESSAGE = "?" * 4100
        self.EMPTY_MESSAGE = ""

        self.BOT_1_LOGIN = "******"
        self.BOT_2_LOGIN = "******"
        self.PASSWORD = os.environ['PASSWORD']
        self.CURRENT_DIALOG_URL = ""

        self.dialog_page = DialogPage(self.driver)
        self.message_page = MessagePage(self.driver)
        self.auth_page = AuthPage(self.driver)
        self.auth_page.sign_in(self.BOT_1_LOGIN, self.PASSWORD)
        self.main_page = MainPage(self.driver)
        self.main_page.open_messages()
        self.URL_OF_DIALOG_WITH_ME = "https://ok.ru/messages/575662066926"
        self.URL_OF_MESSAGES = "https://ok.ru/messages"

        self.NEED_TO_BLOCK_USER = False
        self.NEED_TO_CHANGE_ACC = False

        self.create_dialog()
        self.CURRENT_DIALOG_URL = self.driver.current_url

    def tearDown(self):
        if(self.NEED_TO_BLOCK_USER):
            self.dialog_page.block_user()
        if(self.NEED_TO_CHANGE_ACC):
            self.auth_page.chage_account(self.BOT_1_LOGIN, self.PASSWORD)
        self.driver.get(self.CURRENT_DIALOG_URL)
        self.delete_dialog()
        self.driver.quit()

    def create_dialog(self):
        self.message_page.create_dialog()
        self.message_page.choose_companion()
        self.dialog_page.wait_for_loader()

    def delete_dialog(self):
        self.dialog_page.open_menu()
        dilog_menu_page = DialogMenuPage(self.driver)
        dilog_menu_page.delete_dialog()
        confirm_page = ConfirmPage(self.driver)
        confirm_page.confirm()

    def send_self_message_from_other_acc(self, msg):
        self.auth_page.chage_account(self.BOT_2_LOGIN, self.PASSWORD)
        self.driver.get(self.URL_OF_DIALOG_WITH_ME)
        self.dialog_page.send_message(msg)
        self.auth_page.chage_account(self.BOT_1_LOGIN, self.PASSWORD)
        self.driver.get(self.CURRENT_DIALOG_URL)

    def test_send_message_to_blocked_user(self):
        self.NEED_TO_CHANGE_ACC = True
        self.dialog_page.send_message(self.MESSAGE_TEXT)

        self.auth_page.chage_account(self.BOT_2_LOGIN, self.PASSWORD)
        self.assertEquals(
            self.main_page.get_new_message_text(),
            self.MESSAGE_TEXT)

    def test_send_red_power_message_to_blocked_user(self):
        self.NEED_TO_CHANGE_ACC = True
        self.dialog_page.send_message(self.RED_POWER)

        self.auth_page.chage_account(self.BOT_2_LOGIN, self.PASSWORD)
        self.assertEquals(
            self.main_page.get_new_message_text(),
            self.RED_POWER)

    def test_send_rus_arm_message_to_blocked_user(self):
        self.NEED_TO_CHANGE_ACC = True
        self.dialog_page.send_message(self.RUSSIAN_ARMENIAN_MESSAGE)

        self.auth_page.chage_account(self.BOT_2_LOGIN, self.PASSWORD)
        self.assertEquals(
            self.main_page.get_new_message_text(),
            self.RUSSIAN_ARMENIAN_MESSAGE)

    def test_send_long_message_to_blocked_user(self):
        self.NEED_TO_CHANGE_ACC = True
        self.dialog_page.send_message(self.LONG_MESSAGE_TEXT)

        self.auth_page.chage_account(self.BOT_2_LOGIN, self.PASSWORD)
        self.assertEquals(
            self.main_page.get_new_message_text(),
            self.LONG_MESSAGE_TEXT)

    def test_send_not_valid_message_to_blocked_user(self):
        self.NEED_TO_CHANGE_ACC = True
        self.dialog_page.send_message(self.NOT_VALID_MESSAGE)

        self.auth_page.chage_account(self.BOT_2_LOGIN, self.PASSWORD)
        self.assertNotEquals(
            self.main_page.get_new_message_text(),
            self.NOT_VALID_MESSAGE)

    def test_send_empty_message_to_blocked_user(self):
        self.NEED_TO_CHANGE_ACC = True
        self.dialog_page.send_message(self.EMPTY_MESSAGE)

        self.auth_page.chage_account(self.BOT_2_LOGIN, self.PASSWORD)
        self.assertNotEquals(
            self.main_page.get_new_message_text(),
            self.EMPTY_MESSAGE)

    def test_send_message_to_unblocked_user(self):
        self.NEED_TO_CHANGE_ACC = True
        self.dialog_page.unblock_user()
        self.dialog_page.send_message(self.MESSAGE_TEXT)

        self.dialog_page.block_user()
        self.auth_page.chage_account(self.BOT_2_LOGIN, self.PASSWORD)
        self.assertEquals(
            self.main_page.get_new_message_text(),
            self.MESSAGE_TEXT)

    def test_send_red_power_message_to_unblocked_user(self):
        self.NEED_TO_CHANGE_ACC = True
        self.dialog_page.unblock_user()
        self.dialog_page.send_message(self.RED_POWER)

        self.dialog_page.block_user()
        self.auth_page.chage_account(self.BOT_2_LOGIN, self.PASSWORD)
        self.assertEquals(
            self.main_page.get_new_message_text(),
            self.RED_POWER)

    def test_send_rus_arm_message_to_unblocked_user(self):
        self.NEED_TO_CHANGE_ACC = True
        self.dialog_page.unblock_user()
        self.dialog_page.send_message(self.RUSSIAN_ARMENIAN_MESSAGE)

        self.dialog_page.block_user()
        self.auth_page.chage_account(self.BOT_2_LOGIN, self.PASSWORD)
        self.assertEquals(
            self.main_page.get_new_message_text(),
            self.RUSSIAN_ARMENIAN_MESSAGE)

    def test_send_long_message_to_unblocked_user(self):
        self.NEED_TO_CHANGE_ACC = True
        self.dialog_page.unblock_user()
        self.dialog_page.send_message(self.LONG_MESSAGE_TEXT)

        self.dialog_page.block_user()
        self.auth_page.chage_account(self.BOT_2_LOGIN, self.PASSWORD)
        self.assertEquals(
            self.main_page.get_new_message_text(),
            self.LONG_MESSAGE_TEXT)

    def test_send_not_valid_message_to_unblocked_user(self):
        self.NEED_TO_CHANGE_ACC = True
        self.dialog_page.unblock_user()
        self.dialog_page.send_message(self.NOT_VALID_MESSAGE)

        self.dialog_page.block_user()
        self.auth_page.chage_account(self.BOT_2_LOGIN, self.PASSWORD)
        self.assertNotEquals(
            self.main_page.get_new_message_text(),
            self.NOT_VALID_MESSAGE)

    def test_send_empty_message_to_unblocked_user(self):
        self.NEED_TO_CHANGE_ACC = True
        self.dialog_page.unblock_user()
        self.dialog_page.send_message(self.EMPTY_MESSAGE)

        self.dialog_page.block_user()
        self.auth_page.chage_account(self.BOT_2_LOGIN, self.PASSWORD)
        self.assertNotEquals(
            self.main_page.get_new_message_text(),
            self.EMPTY_MESSAGE)

    def test_get_message_from_blocked_user(self):
        self.NEED_TO_CHANGE_ACC = True
        self.auth_page.chage_account(self.BOT_2_LOGIN, self.PASSWORD)
        self.driver.get(self.URL_OF_DIALOG_WITH_ME)
        self.dialog_page.send_message(self.MESSAGE_TEXT)
        self.CURRENT_DIALOG_URL = self.driver.current_url

        self.auth_page.chage_account(self.BOT_1_LOGIN, self.PASSWORD)
        self.assertFalse(
            self.main_page.get_existance_of_new_message(),
            "test_get_message_from_blocked_user failed")
        self.BOT_1_LOGIN = self.BOT_2_LOGIN

    def test_get_long_message_from_blocked_user(self):
        self.NEED_TO_CHANGE_ACC = True
        self.auth_page.chage_account(self.BOT_2_LOGIN, self.PASSWORD)
        self.driver.get(self.URL_OF_DIALOG_WITH_ME)
        self.dialog_page.send_message(self.LONG_MESSAGE_TEXT)
        self.CURRENT_DIALOG_URL = self.driver.current_url

        self.auth_page.chage_account(self.BOT_1_LOGIN, self.PASSWORD)
        self.assertFalse(
            self.main_page.get_existance_of_new_message(),
            "test_get_message_from_blocked_user failed")
        self.BOT_1_LOGIN = self.BOT_2_LOGIN

    def test_video_call(self):
        self.dialog_page.begin_video_call()
        self.assertTrue(
            self.dialog_page.video_call_exists(),
            "test_video_call failed")

    def test_support_window(self):
        self.dialog_page.open_support()
        self.assertTrue(
            self.dialog_page.support_window_exists(),
            "test_support_window failed")

    def test_present_page(self):
        self.dialog_page.go_to_present_page()
        self.dialog_page.wait_for_nav_loader()
        self.assertTrue(
            self.dialog_page.present_page_exists(),
            "test_present_page failed")
        self.main_page.open_messages()

    def test_money_page(self):
        self.dialog_page.go_to_money_page()
        self.dialog_page.wait_for_payment_loader()

        self.assertTrue(
            self.dialog_page.money_page_exists(),
            "test_money_page failed")

    def test_money_transfers_page(self):
        self.dialog_page.go_to_money_page()
        self.dialog_page.wait_for_payment_loader()
        self.dialog_page.go_to_transfers_page()

        self.assertTrue(
            self.dialog_page.money_page_exists(),
            "test_money_transfers_page failed")

    def test_profile_from_dialog(self):
        self.dialog_page.go_to_profile()
        self.dialog_page.wait_for_nav_loader()
        self.assertTrue(
            self.dialog_page.profile_page_exists(),
            "profile_from_dialog failed")
        self.main_page.open_messages()

    def test_report_message(self):
        self.NEED_TO_BLOCK_USER = True
        self.dialog_page.unblock_user()
        self.send_self_message_from_other_acc(self.MESSAGE_TEXT)
        self.dialog_page.report_message()
        self.dialog_page.confirm_report()
        self.assertTrue(
            self.dialog_page.existence_reported_message(),
            "test_report_message failed")

    def test_report_unicode_message(self):
        self.NEED_TO_BLOCK_USER = True
        self.dialog_page.unblock_user()
        self.send_self_message_from_other_acc(self.RED_POWER)
        self.dialog_page.report_message()
        self.dialog_page.confirm_report()
        self.assertTrue(
            self.dialog_page.existence_reported_message(),
            "test_report_unicode_message failed")

    def test_cancel_report_message(self):
        self.NEED_TO_BLOCK_USER = True
        self.dialog_page.unblock_user()
        self.send_self_message_from_other_acc(self.MESSAGE_TEXT)
        self.dialog_page.report_message()
        self.dialog_page.cancel_report()
        self.assertFalse(
            self.dialog_page.existence_reported_message(),
            "test_cancel_report_message failed")

    def test_close_report_message(self):
        self.NEED_TO_BLOCK_USER = True
        self.dialog_page.unblock_user()
        self.send_self_message_from_other_acc(self.MESSAGE_TEXT)
        self.dialog_page.report_message()
        self.dialog_page.close_report()
        self.assertFalse(
            self.dialog_page.existence_reported_message(),
            "test_cancel_report_message failed")
class TestsSendMessages(unittest.TestCase):
    def setUp(self):
        browser = os.environ.get('BROWSER', os.environ['BROWSER'])

        self.driver = Remote(command_executor='http://127.0.0.1:4444/wd/hub',
                             desired_capabilities=getattr(
                                 DesiredCapabilities, browser).copy())
        self.driver.maximize_window()

        self.BOT_1_LOGIN = "******"
        self.PASSWORD = os.environ['PASSWORD']
        self.CURRENT_DIALOG_URL = ""

        self.USUAL_MESSAGE_TEXT = 'USUAL TEXT'
        self.CHINESE_TEXT = u'測試漢字'
        self.EMPTY_MESSAGE_TEXT = ''
        self.LONG_VALID_MESSAGE = '_123' * 512
        self.LONG_INVALID_MESSAGE = '_123' * 1024
        self.MESSAGE_EDITED_TEXT = ' IS_EDITED'
        self.MESSAGE_ANSWERED_TEXT = ' IS_ANSWERED'

        self.dialog_page = DialogPage(self.driver)
        self.message_page = MessagePage(self.driver)
        self.auth_page = AuthPage(self.driver)
        self.auth_page.sign_in(self.BOT_1_LOGIN, self.PASSWORD)
        self.main_page = MainPage(self.driver)
        self.main_page.open_messages()
        self.create_dialog()
        self.CURRENT_DIALOG_URL = self.driver.current_url

    def tearDown(self):
        self.driver.get(self.CURRENT_DIALOG_URL)
        self.delete_dialog()
        self.driver.quit()

    def create_dialog(self):
        self.message_page.create_dialog()
        self.message_page.choose_companion()
        self.dialog_page.wait_for_loader()

    def delete_dialog(self):
        self.dialog_page.open_menu()
        dilog_menu_page = DialogMenuPage(self.driver)
        dilog_menu_page.delete_dialog()
        confirm_page = ConfirmPage(self.driver)
        confirm_page.confirm()

    def test_send_usual_message(self):
        self.dialog_page.send_message(self.USUAL_MESSAGE_TEXT)
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test send usual message failed")

    def test_send_empty_message(self):
        self.dialog_page.send_message(self.EMPTY_MESSAGE_TEXT)
        self.assertFalse(self.dialog_page.sent_message_exists(),
                         "test send empty message failed")

    def test_send_unicode_message(self):
        self.dialog_page.send_message(self.CHINESE_TEXT)
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test send unicode message failed")

    def test_send_long_valid_message(self):
        self.dialog_page.send_message(self.LONG_VALID_MESSAGE)
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test send long valid message failed")

    def test_send_long_invalid_message(self):
        self.dialog_page.send_message(self.LONG_INVALID_MESSAGE)
        self.assertTrue(self.dialog_page.long_message_error_exists(),
                        "test send long invalid message failed")

    def test_usual_edit_usual_message(self):
        self.dialog_page.send_message(self.USUAL_MESSAGE_TEXT)
        self.dialog_page.edit_and_send_message(self.MESSAGE_EDITED_TEXT)
        self.driver.refresh()
        self.assertEquals(self.dialog_page.get_sent_message_text(),
                          self.USUAL_MESSAGE_TEXT + self.MESSAGE_EDITED_TEXT)

    def test_empty_edit_unicode_message(self):
        self.dialog_page.send_message(self.CHINESE_TEXT)
        self.dialog_page.edit_and_send_message(self.EMPTY_MESSAGE_TEXT)
        self.driver.refresh()
        self.assertEquals(self.dialog_page.get_sent_message_text(),
                          self.CHINESE_TEXT + self.EMPTY_MESSAGE_TEXT)

    def test_unicode_edit_unicode_message(self):
        self.dialog_page.send_message(self.CHINESE_TEXT)
        self.dialog_page.edit_and_send_message(self.CHINESE_TEXT)
        self.driver.refresh()
        self.assertEquals(self.dialog_page.get_sent_message_text(),
                          self.CHINESE_TEXT + self.CHINESE_TEXT)

    def test_usual_answer_unicode_message(self):
        self.dialog_page.send_message(self.CHINESE_TEXT)
        self.dialog_page.answer_message(self.MESSAGE_ANSWERED_TEXT)
        self.driver.refresh()
        self.assertTrue(self.dialog_page.get_exsistance_of_answered_message(),
                        "test_usual_answer_message failed")

    def test_unicode_answer_usual_message(self):
        self.dialog_page.send_message(self.USUAL_MESSAGE_TEXT)
        self.dialog_page.answer_message(self.CHINESE_TEXT)
        self.driver.refresh()
        self.assertTrue(self.dialog_page.get_exsistance_of_answered_message(),
                        "test_unicode_answer_message failed")

    def test_forward_usual_message(self):
        self.dialog_page.send_message(self.USUAL_MESSAGE_TEXT)
        self.dialog_page.forward_message()
        self.message_page.choose_companion_forward_message()
        self.driver.refresh()
        self.assertTrue(self.dialog_page.get_exsistance_of_forwarded_message(),
                        "test_forward_message failed")

    def test_forward_unicode_message(self):
        self.dialog_page.send_message(self.CHINESE_TEXT)
        self.dialog_page.forward_message()
        self.message_page.choose_companion_forward_message()
        self.driver.refresh()
        self.assertTrue(self.dialog_page.get_exsistance_of_forwarded_message(),
                        "test_forward_message failed")

    def test_forward_long_valid_message(self):
        LOOP_TEXT = '_123'
        LOOP_TEXT *= 512
        self.dialog_page.send_message(LOOP_TEXT)
        self.dialog_page.forward_message()
        self.message_page.choose_companion_forward_message()
        self.driver.refresh()
        self.assertTrue(self.dialog_page.get_exsistance_of_forwarded_message(),
                        "test_forward_message failed")

    def test_delete_usual_message(self):
        self.dialog_page.send_message(self.USUAL_MESSAGE_TEXT)
        self.dialog_page.delete_message()
        self.driver.refresh()
        self.assertTrue(self.dialog_page.no_messages_text_exists(),
                        "test_delete_message failed")

    def test_delete_long_valid_message(self):
        LOOP_TEXT = '_123'
        LOOP_TEXT *= 512
        self.dialog_page.send_message(LOOP_TEXT)
        self.dialog_page.delete_message()
        self.driver.refresh()
        self.assertTrue(self.dialog_page.no_messages_text_exists(),
                        "test_delete_message failed")

    def test_delete_long_invalid_message(self):
        LOOP_TEXT = '_123'
        LOOP_TEXT *= 1024
        self.dialog_page.send_message(LOOP_TEXT)
        self.dialog_page.delete_message()
        self.driver.refresh()
        self.assertTrue(self.dialog_page.no_messages_text_exists(),
                        "test_delete_message failed")

    def test_send_chocolate_smile(self):
        self.dialog_page.send_chocolate_smile()
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_smile failed")

    def test_send_whale_smile(self):
        self.dialog_page.send_whale_smile()
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_whale_smile failed")

    def test_send_many_smiles(self):
        self.dialog_page.send_combo_wombo_smile()
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_many_smile failed")
Example #14
0
class TestsSendDocuments(unittest.TestCase):
    def setUp(self):
        browser = os.environ.get('BROWSER', os.environ['BROWSER'])

        self.driver = Remote(command_executor='http://127.0.0.1:4444/wd/hub',
                             desired_capabilities=getattr(
                                 DesiredCapabilities, browser).copy())
        self.driver.maximize_window()

        self.BOT_1_LOGIN = "******"
        self.PASSWORD = os.environ['PASSWORD']
        self.CURRENT_DIALOG_URL = ""

        self.dialog_page = DialogPage(self.driver)
        self.message_page = MessagePage(self.driver)
        self.auth_page = AuthPage(self.driver)
        self.auth_page.sign_in(self.BOT_1_LOGIN, self.PASSWORD)
        self.main_page = MainPage(self.driver)
        self.main_page.open_messages()

        self.create_dialog()
        self.CURRENT_DIALOG_URL = self.driver.current_url

    def tearDown(self):
        self.driver.get(self.CURRENT_DIALOG_URL)
        self.delete_dialog()
        self.driver.quit()

    def create_dialog(self):
        self.message_page.create_dialog()
        self.message_page.choose_companion()
        self.dialog_page.wait_for_loader()

    def delete_dialog(self):
        self.dialog_page.open_menu()
        dilog_menu_page = DialogMenuPage(self.driver)
        dilog_menu_page.delete_dialog()
        confirm_page = ConfirmPage(self.driver)
        confirm_page.confirm()

    def test_send_document_txt(self):
        self.dialog_page.send_document(os.getcwd() + "/tests/static/awd.txt")
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_document_txt failed")

    def test_send_document_video(self):
        self.dialog_page.send_document(os.getcwd() +
                                       "/tests/static/sabaton_low.mp4")
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_document_video failed")

    def test_send_document_photo(self):
        self.dialog_page.send_document(os.getcwd() +
                                       "/tests/static/sabaton_low.jpeg")
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_document_photo failed")

    def test_send_document_pages(self):
        self.dialog_page.send_document(os.getcwd() +
                                       "/tests/static/sabaton.pages")
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_document_pages failed")

    def test_send_photo(self):
        self.dialog_page.send_photo(os.getcwd() + "/tests/static/sabaton.jpg")
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_photo failed")

    def test_send_photo_wrong_format(self):
        self.dialog_page.send_photo(os.getcwd() + "/tests/static/awd.txt")
        self.assertTrue(self.dialog_page.get_wrong_photo_format(),
                        "test_send_photo_wrong_format failed")

    def test_send_photo_high_res(self):
        self.dialog_page.send_photo(os.getcwd() +
                                    "/tests/static/sabaton_high.jpg")
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_photo_high_res failed")

    def test_send_photo_low_res(self):
        self.dialog_page.send_photo(os.getcwd() +
                                    "/tests/static/sabaton_low.jpeg")
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_photo_low_res failed")

    def test_send_photo_png_format(self):
        self.dialog_page.send_photo(os.getcwd() +
                                    "/tests/static/sabaton_png.png")
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_photo_png_format failed")

    def test_send_video_low_res(self):
        self.dialog_page.send_video(os.getcwd() +
                                    "/tests/static/sabaton_low.mp4")
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_video_low_res failed")

    def test_send_video_high_res(self):
        self.dialog_page.send_video(os.getcwd() +
                                    "/tests/static/sabaton_high.mp4")
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_video_high_res failed")

    def test_send_video_no_sound(self):
        self.dialog_page.send_video(os.getcwd() +
                                    "/tests/static/sabaton_no_sound.mp4")
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_video_no_sound failed")

    def test_send_video_webm_fromat(self):
        self.dialog_page.send_video(os.getcwd() +
                                    "/tests/static/sabaton_webm.webm")
        self.assertTrue(self.dialog_page.sent_message_exists(),
                        "test_send_video_webm_fromat failed")

    def test_send_video_wrong_fromat(self):
        self.dialog_page.send_video(os.getcwd() + "/tests/static/awd.txt")
        self.assertTrue(self.dialog_page.get_wrong_photo_format(),
                        "test_send_video_webm_fromat failed")