From a7f9998d6c149db2f02fc63a603d45f8729d20f5 Mon Sep 17 00:00:00 2001 From: Churikova Tetiana Date: Mon, 8 Feb 2021 13:52:20 +0100 Subject: [PATCH] e2e: nightly fix Signed-off-by: Churikova Tetiana --- test/appium/support/api/network_api.py | 11 ++++++----- .../atomic/chats/test_chats_management.py | 17 ++++++++--------- .../tests/atomic/chats/test_commands.py | 7 ++++--- .../atomic/chats/test_keycard_commands.py | 19 ++++++++++--------- test/appium/tests/atomic/chats/test_public.py | 8 +++----- .../transactions/test_dapps_transactions.py | 2 +- test/appium/views/base_view.py | 11 ++++++----- test/appium/views/chat_view.py | 12 +++++++++++- test/appium/views/wallet_view.py | 1 + 9 files changed, 50 insertions(+), 38 deletions(-) diff --git a/test/appium/support/api/network_api.py b/test/appium/support/api/network_api.py index db0e3e3886..e21d40b663 100644 --- a/test/appium/support/api/network_api.py +++ b/test/appium/support/api/network_api.py @@ -35,7 +35,7 @@ class NetworkApi(object): except TypeError as e: self.log("Check response from etherscan API. Returned values do not match expected. %s" % e) except JSONDecodeError as e: - self.log(str(e)) + self.log("No valid JSON response from Etherscan: %s " % str(e)) pass def get_token_transactions(self, address: str) -> List[dict]: @@ -47,7 +47,7 @@ class NetworkApi(object): except TypeError as e: self.log("Check response from etherscan API. Returned values do not match expected. %s" % str(e)) except JSONDecodeError as e: - self.log(str(e)) + self.log("No valid JSON response from Etherscan: %s " % str(e)) pass def is_transaction_successful(self, transaction_hash: str) -> int: @@ -92,7 +92,7 @@ class NetworkApi(object): else: transactions = self.get_transactions(address) except JSONDecodeError as e: - self.log(str(e)) + self.log("No valid JSON response from Etherscan: %s " % str(e)) continue try: for transaction in transactions: @@ -141,7 +141,7 @@ class NetworkApi(object): self.log("Trying to get funds from %s" % self.faucet_url) return requests.request('GET', '%s/0x%s' % (self.faucet_url, address)).json() except JSONDecodeError as e: - self.log(str(e)) + self.log("No valid JSON response from Etherscan: %s " % str(e)) pass def faucet_backup(self, address): @@ -155,7 +155,8 @@ class NetworkApi(object): if initial_balance < 1000000000000000000: if external_faucet: self.faucet_backup(address) - self.faucet(address) + else: + self.faucet(address) while True: if counter >= wait_time: pytest.fail("Donation was not received during %s seconds!" % wait_time) diff --git a/test/appium/tests/atomic/chats/test_chats_management.py b/test/appium/tests/atomic/chats/test_chats_management.py index 5db23016ec..5fdf5340a8 100644 --- a/test/appium/tests/atomic/chats/test_chats_management.py +++ b/test/appium/tests/atomic/chats/test_chats_management.py @@ -248,11 +248,11 @@ class TestChatManagement(SingleDeviceTestCase): home.just_fyi("Creating 3 types of chats") chat = home.add_contact(basic_user['public_key']) one_to_one, public, group = basic_user['username'], '#public-delete-long-press', 'group' - chat.get_back_to_home_view() + chat.home_button.click() home.create_group_chat([basic_user['username']], group) - chat.get_back_to_home_view() + chat.home_button.click() home.join_public_chat(public[1:]) - chat.get_back_to_home_view() + chat.home_button.click() home.just_fyi("Clearing history for 3 types of chats and check it will not reappear after re-login") for chat_name in one_to_one, public, group: @@ -260,17 +260,16 @@ class TestChatManagement(SingleDeviceTestCase): chat.send_message(message) if chat.element_by_text(message).is_element_displayed(): self.errors.append('Messages in %s chat are still shown after clearing history' % chat_name) - home = chat.get_back_to_home_view() + home = chat.home_button.click() home.clear_chat_long_press(chat_name) home.relogin() + if home.element_by_text(message).is_element_displayed(): + self.errors.append('Message is still shown in Preview after clearing history and relaunch') for chat_name in one_to_one, public, group: - if home.element_by_text(message).is_element_displayed(): - self.errors.append( - 'Messages in %s chat are still shown in Preview after clearing history and relaunch' % chat_name) chat = home.get_chat(chat_name).click() if chat.element_by_text(message).is_element_displayed(): - self.errors.append('Messages in %s chat are shown after clearing history and relauch' % chat_name) - chat.get_back_to_home_view() + self.errors.append('Messages in %s chat are shown after clearing history and relaunch' % chat_name) + chat.home_button.click() self.errors.verify_no_errors() diff --git a/test/appium/tests/atomic/chats/test_commands.py b/test/appium/tests/atomic/chats/test_commands.py index 3db328badf..4901d16164 100644 --- a/test/appium/tests/atomic/chats/test_commands.py +++ b/test/appium/tests/atomic/chats/test_commands.py @@ -184,13 +184,14 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase): send_transaction.confirm() send_transaction.sign_transaction_button.click() chat_1_sender_message = chat_1.get_outgoing_transaction() - home_1.click_system_home_button() + # TODO: PN is waiting for #11175 + # home_1.click_system_home_button() chat_2 = home_2.get_chat(sender['username']).click() chat_2_receiver_message = chat_2.get_incoming_transaction() chat_2_receiver_message.decline_transaction.click() - home_1.open_notification_bar() - home_1.element_by_text_part('Request address for transaction declined').wait_and_click() + # home_1.open_notification_bar() + # home_1.element_by_text_part('Request address for transaction declined').wait_and_click() [message.transaction_status.wait_for_element_text(message.declined) for message in (chat_1_sender_message, chat_2_receiver_message)] diff --git a/test/appium/tests/atomic/chats/test_keycard_commands.py b/test/appium/tests/atomic/chats/test_keycard_commands.py index 0a4d4fa2ad..e19b293c2f 100644 --- a/test/appium/tests/atomic/chats/test_keycard_commands.py +++ b/test/appium/tests/atomic/chats/test_keycard_commands.py @@ -111,8 +111,8 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase): profile_2 = wallet_2.profile_button.click() profile_2.airplane_mode_button.click() - device_2.home_button.click() - device_2.click_system_home_button() + device_2.home_button.double_click() + # device_2.click_system_home_button() chat_element = home_1.get_chat(sender['username']) chat_element.wait_for_visibility_of_element(30) chat_1 = chat_element.click() @@ -132,14 +132,15 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase): home_2.just_fyi('Check that transaction message is fetched from offline and sign transaction') profile_2.airplane_mode_button.click() - transaction_request_pn = 'Request transaction' - device_2.open_notification_bar() - if not device_2.element_by_text(transaction_request_pn).is_element_displayed(60): - self.errors.append("Push notification is not received after going back from offline") - device_2.element_by_text(transaction_request_pn).click() + # TODO: PN is waiting for #11175 + #transaction_request_pn = 'Request transaction' + # device_2.open_notification_bar() + # if not device_2.element_by_text(transaction_request_pn).is_element_displayed(60): + # self.errors.append("Push notification is not received after going back from offline") + # device_2.element_by_text(transaction_request_pn).click() + home_2.connection_status.wait_for_invisibility_of_element(120) + home_2.get_chat(recipient_username).click() chat_2_sender_message = chat_2.get_outgoing_transaction() - if not chat_2_sender_message.is_element_displayed(): - self.driver.fail('No outgoing transaction in 1-1 chat is shown for sender after requesting STT') chat_2_sender_message.transaction_status.wait_for_element_text(chat_2_sender_message.address_received) send_message = chat_2_sender_message.sign_and_send.click() send_message.next_button.click() diff --git a/test/appium/tests/atomic/chats/test_public.py b/test/appium/tests/atomic/chats/test_public.py index 04d8eb9172..1aea8820b8 100644 --- a/test/appium/tests/atomic/chats/test_public.py +++ b/test/appium/tests/atomic/chats/test_public.py @@ -154,14 +154,12 @@ class TestPublicChatMultipleDevice(MultipleDeviceTestCase): public_chat_name = home_1.get_random_chat_name() chat_1, chat_2 = home_1.join_public_chat(public_chat_name), home_2.join_public_chat(public_chat_name) - browser = device_1.dapp_tab_button.click() + device_1.dapp_tab_button.click() message = 'hello' chat_2.send_message(message) - - if home_1.home_button.public_unread_messages.is_element_displayed(): - device_1.home_button.click_until_absense_of_element(browser.enter_url_editbox) + home_1.home_button.click(desired_view='chat') if not chat_1.chat_element_by_text(message).is_element_displayed(): - self.drivers[0].fail("No message if it received while another tab opened") + self.drivers[0].fail("No message if it is received while another tab opened") class TestPublicChatSingleDevice(SingleDeviceTestCase): diff --git a/test/appium/tests/atomic/transactions/test_dapps_transactions.py b/test/appium/tests/atomic/transactions/test_dapps_transactions.py index d2bfee9db0..d997530ee3 100644 --- a/test/appium/tests/atomic/transactions/test_dapps_transactions.py +++ b/test/appium/tests/atomic/transactions/test_dapps_transactions.py @@ -24,7 +24,7 @@ class TestTransactionDApp(SingleDeviceTestCase): status_test_dapp.wallet_button.click() send_transaction_view.just_fyi('Verify that wallet balance is updated') - wallet_view.wait_balance_is_changed('STT', initial_amount_STT) + wallet_view.wait_balance_is_changed('STT', initial_amount_STT, scan_tokens=True) send_transaction_view.just_fyi('Check logcat for sensitive data') values_in_logcat = send_transaction_view.find_values_in_logcat(password=unique_password) diff --git a/test/appium/views/base_view.py b/test/appium/views/base_view.py index 99836d23bb..85f5b4b823 100644 --- a/test/appium/views/base_view.py +++ b/test/appium/views/base_view.py @@ -86,11 +86,12 @@ class DappTabButton(TabButton): from views.dapps_view import DappsView return DappsView(self.driver) - def click(self, desired_element_text = 'enter_url'): - from views.dapps_view import DappsView - if desired_element_text == 'enter_url': - self.click_until_presence_of_element(DappsView(self.driver).enter_url_editbox) - if desired_element_text == 'webview': + def click(self, desired_element_text=None): + + from views.web_views.base_web_view import BaseWebView + if desired_element_text is None: + self.click_until_presence_of_element(BaseWebView(self.driver).browser_next_page_button) + elif desired_element_text == 'webview': self.find_element().click() else: base_view = BaseView(self.driver) diff --git a/test/appium/views/chat_view.py b/test/appium/views/chat_view.py index 1ded6329a5..0030803a70 100644 --- a/test/appium/views/chat_view.py +++ b/test/appium/views/chat_view.py @@ -74,6 +74,16 @@ class ViewProfileButton(Button): def navigate(self): return ChatView(self.driver) +class ChatOptionsButton(Button): + def __init__(self, driver): + super().__init__(driver, accessibility_id="chat-menu-button") + + def click(self): + self.click_until_presence_of_element(ChatView(self.driver).clear_history_button) + + def navigate(self): + return ChatView(self.driver) + class ProfileSendMessageButton(Button): def __init__(self, driver): @@ -319,7 +329,7 @@ class ChatView(BaseView): self.user_name_text = Text(self.driver, accessibility_id="chat-name-text") self.add_to_contacts = Button(self.driver, accessibility_id="add-to-contacts-button") ## Options - self.chat_options = Button(self.driver, accessibility_id="chat-menu-button") + self.chat_options = ChatOptionsButton(self.driver) self.delete_chat_button = Button(self.driver, translation_id="delete-chat") self.clear_history_button = Button(self.driver, translation_id="clear-history") self.reply_message_button = Button(self.driver, translation_id="message-reply") diff --git a/test/appium/views/wallet_view.py b/test/appium/views/wallet_view.py index 033bf7d753..db46348a0e 100644 --- a/test/appium/views/wallet_view.py +++ b/test/appium/views/wallet_view.py @@ -180,6 +180,7 @@ class WalletView(BaseView): else: self.driver.info('**Balance is updated!**') self.wallet_button.double_click() + self.accounts_status_account.scroll_to_element(direction='up') return self def get_sign_in_phrase(self):