From ce84f81741ffda48bc7b886a012e5ae77dbb16c6 Mon Sep 17 00:00:00 2001 From: yevh-berdnyk Date: Mon, 29 Jul 2019 03:35:36 +0300 Subject: [PATCH] Re-enabled and updated e2e tests Signed-off-by: Serhy --- .../test_wallet_management.py | 49 +++++++++++-------- .../tests/atomic/chats/test_commands.py | 4 +- .../tests/atomic/chats/test_one_to_one.py | 45 +++++++---------- test/appium/tests/base_test_case.py | 4 +- test/appium/views/base_view.py | 29 ++++++++--- test/appium/views/wallet_view.py | 15 ++++-- 6 files changed, 84 insertions(+), 62 deletions(-) diff --git a/test/appium/tests/atomic/account_management/test_wallet_management.py b/test/appium/tests/atomic/account_management/test_wallet_management.py index f5ef48be7d..77f70edc5b 100644 --- a/test/appium/tests/atomic/account_management/test_wallet_management.py +++ b/test/appium/tests/atomic/account_management/test_wallet_management.py @@ -2,7 +2,7 @@ import pytest from tests import marks, camera_access_error_text from tests.base_test_case import SingleDeviceTestCase -from tests.users import wallet_users +from tests.users import wallet_users, transaction_senders, basic_user from views.sign_in_view import SignInView @@ -12,33 +12,42 @@ class TestWalletManagement(SingleDeviceTestCase): @marks.testrail_id(5335) @marks.high - @marks.skip def test_wallet_set_up(self): sign_in = SignInView(self.driver) - sign_in.create_user() + sign_in.recover_access(transaction_senders['A']['passphrase']) wallet = sign_in.wallet_button.click() - text = 'Simple and secure cryptocurrency wallet' - if not wallet.element_by_text(text).is_element_displayed(): - self.errors.append("'%s' is not displayed" % text) - wallet.set_up_button.click() - texts = ['Super-safe transactions', 'You should see these three words before signing each transaction', + texts = ['This is your signing phrase', 'You should see these 3 words before signing each transaction', 'If you see a different combo, cancel the transaction and logout.'] for text in texts: if not wallet.element_by_text_part(text).is_element_displayed(): self.errors.append("'%s' text is not displayed" % text) - phrase_length = len(wallet.sign_in_phrase.list) - if phrase_length != 3: - self.errors.append('Transaction phrase length is %s' % phrase_length) - wallet.done_button.click() - for text in ['Remember this!', "You'll need to recognize this to ensure your " - "transactions are safe. This combo is not stored in your account."]: - if not wallet.element_by_text(text).is_element_displayed(): + phrase = wallet.sign_in_phrase.list + if len(phrase) != 3: + self.errors.append('Transaction phrase length is %s' % len(phrase)) + wallet.remind_me_later_button.click() + wallet.accounts_status_account.click() + send_transaction = wallet.send_transaction_button.click() + send_transaction.amount_edit_box.set_value('0') + send_transaction.confirm() + send_transaction.chose_recipient_button.click() + send_transaction.enter_recipient_address_button.click() + send_transaction.enter_recipient_address_input.set_value(basic_user['address']) + send_transaction.done_button.click() + send_transaction.sign_transaction_button.click() + for text in texts: + if not wallet.element_by_text_part(text).is_element_displayed(): self.errors.append("'%s' text is not displayed" % text) - wallet.yes_button.click() - for element in [wallet.send_transaction_button, wallet.receive_transaction_button, - wallet.transaction_history_button]: - if not element.is_element_displayed(): - self.errors.append('%s button is not shown after wallet setup' % element.name) + phrase_1 = wallet.sign_in_phrase.list + if phrase_1 != phrase: + self.errors.append("Transaction phrase '%s' doesn't match expected '%s'" % (phrase_1, phrase)) + wallet.ok_got_it_button.click() + wallet.back_button.click(times_to_click=2) + wallet.home_button.click() + wallet.wallet_button.click() + for text in texts: + if wallet.element_by_text_part(text).is_element_displayed(): + self.errors.append('Signing phrase pop up appears after wallet set up') + break self.verify_no_errors() @marks.testrail_id(5384) diff --git a/test/appium/tests/atomic/chats/test_commands.py b/test/appium/tests/atomic/chats/test_commands.py index d26dd9fadd..7e28be481d 100644 --- a/test/appium/tests/atomic/chats/test_commands.py +++ b/test/appium/tests/atomic/chats/test_commands.py @@ -164,14 +164,12 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase): @marks.testrail_id(5324) @marks.critical - @marks.skip # re-enable after 8234 for new onboarding merged def test_request_eth_in_wallet(self): self.create_drivers(2) device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) - username_1 = 'user_1' sender = transaction_senders['O'] - home_1 = device_1.create_user(username=username_1) + home_1 = device_1.create_user() profile_1 = home_1.profile_button.click() default_username_1 = profile_1.default_username_text.text home_1 = profile_1.get_back_to_home_view() diff --git a/test/appium/tests/atomic/chats/test_one_to_one.py b/test/appium/tests/atomic/chats/test_one_to_one.py index 8a3084aaf0..c41640cadb 100644 --- a/test/appium/tests/atomic/chats/test_one_to_one.py +++ b/test/appium/tests/atomic/chats/test_one_to_one.py @@ -1,14 +1,15 @@ +import time + +import emoji import pytest import random -import time import string -import emoji -from support.api.network_api import NetworkApi from datetime import datetime from selenium.common.exceptions import TimeoutException + from tests import marks, get_current_time -from tests.users import transaction_senders, transaction_recipients, basic_user from tests.base_test_case import MultipleDeviceTestCase, SingleDeviceTestCase +from tests.users import transaction_senders, transaction_recipients, basic_user from views.sign_in_view import SignInView @@ -17,7 +18,6 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): @marks.testrail_id(5305) @marks.critical - @marks.skip # re-enable after 8234 for new onboarding merged def test_text_message_1_1_chat(self): self.create_drivers(2) device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) @@ -38,25 +38,26 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): device_2_chat.chat_element_by_text(message).wait_for_visibility_of_element() @marks.testrail_id(5310) - @marks.skip @marks.critical def test_offline_messaging_1_1_chat(self): - self.create_drivers(2, offline_mode=True) + self.create_drivers(2) sign_in_1, sign_in_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) - username_2 = 'user_2' - home_1, home_2 = sign_in_1.create_user(), sign_in_2.create_user(username=username_2) + home_1, home_2 = sign_in_1.create_user(), sign_in_2.create_user() public_key_1 = home_1.get_public_key() home_1.home_button.click() - home_1.driver.set_network_connection(1) # airplane mode on primary device + home_1.airplane_mode_button.click() # airplane mode on primary device + profile_2 = home_2.profile_button.click() + username_2 = profile_2.default_username_text.text + profile_2.get_back_to_home_view() chat_2 = home_2.add_contact(public_key_1) message_1 = 'test message' chat_2.chat_message_input.send_keys(message_1) chat_2.send_message_button.click() - chat_2.driver.set_network_connection(1) # airplane mode on secondary device + chat_2.airplane_mode_button.click() # airplane mode on secondary device - home_1.driver.set_network_connection(2) # turning on WiFi connection on primary device + home_1.airplane_mode_button.click() # turning on WiFi connection on primary device home_1.connection_status.wait_for_invisibility_of_element(20) chat_element = home_1.get_chat_with_user(username_2) @@ -64,27 +65,25 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): chat_1 = chat_element.click() chat_1.chat_element_by_text(message_1).wait_for_visibility_of_element(2) - chat_2.driver.set_network_connection(2) # turning on WiFi connection on secondary device - home_1.driver.set_network_connection(1) # airplane mode on primary device + chat_2.airplane_mode_button.click() # turning on WiFi connection on secondary device + home_1.airplane_mode_button.click() # airplane mode on primary device chat_2.element_by_text('Connecting to peers...').wait_for_invisibility_of_element(60) message_2 = 'one more message' chat_2.chat_message_input.send_keys(message_2) chat_2.send_message_button.click() - home_1.driver.set_network_connection(2) # turning on WiFi connection on primary device + home_1.airplane_mode_button.click() # turning on WiFi connection on primary device chat_1 = chat_element.click() chat_1.chat_element_by_text(message_2).wait_for_visibility_of_element(180) @marks.testrail_id(5338) @marks.critical - @marks.skip # re-enable after 8234 for new onboarding merged def test_messaging_in_different_networks(self): self.create_drivers(2) sign_in_1, sign_in_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) - username_1 = 'user_%s' % get_current_time() - home_1, home_2 = sign_in_1.create_user(username_1), sign_in_2.create_user() + home_1, home_2 = sign_in_1.create_user(), sign_in_2.create_user() profile_1 = home_1.profile_button.click() default_username_1 = profile_1.default_username_text.text home_1 = profile_1.get_back_to_home_view() @@ -115,7 +114,6 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): def test_send_message_to_newly_added_contact(self): self.create_drivers(2) device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) - username_1 = 'user_%s' % get_current_time() device_1_home, device_2_home = device_1.create_user(), device_2.create_user() profile_1 = device_1_home.profile_button.click() @@ -152,11 +150,9 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): @marks.testrail_id(5316) @marks.critical - @marks.skip # re-enable after 8234 for new onboarding merged def test_add_to_contacts(self): self.create_drivers(2) device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) - username_1, username_2 = 'user_1', 'user_2' device_1_home, device_2_home = device_1.create_user(), device_2.create_user() profile_1 = device_1_home.profile_button.click() @@ -186,8 +182,8 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): device_2_chat.get_back_to_home_view() device_2_home.plus_button.click() device_2_contacts = device_2_home.start_new_chat_button.click() - if not device_2_contacts.element_by_text(username_1).is_element_displayed(): - self.errors.append('%s is not added to contacts' % username_1) + if not device_2_contacts.element_by_text(default_username_1).is_element_displayed(): + self.errors.append('%s is not added to contacts' % default_username_1) if device_1_chat.user_name_text.text != default_username_2: self.errors.append("Default username '%s' is not shown in one-to-one chat" % default_username_2) @@ -202,7 +198,6 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): def test_send_and_open_links(self): self.create_drivers(2) device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) - username_1, username_2 = 'user_1', 'user_2' home_1, home_2 = device_1.create_user(), device_2.create_user() profile_1 = home_1.profile_button.click() @@ -284,11 +279,9 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): @marks.testrail_id(5362) @marks.critical - @marks.skip # re-enable after 8234 for new onboarding merged def test_unread_messages_counter_1_1_chat(self): self.create_drivers(2) device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) - username_2 = 'user_%s' % get_current_time() device_1_home, device_2_home = device_1.create_user(), device_2.create_user() profile_2 = device_2_home.profile_button.click() default_username_2 = profile_2.default_username_text.text diff --git a/test/appium/tests/base_test_case.py b/test/appium/tests/base_test_case.py index 6680671567..8fd919716f 100644 --- a/test/appium/tests/base_test_case.py +++ b/test/appium/tests/base_test_case.py @@ -219,10 +219,8 @@ class SauceMultipleDeviceTestCase(AbstractTestCase): def setup_method(self, method): self.drivers = dict() - def create_drivers(self, quantity=2, max_duration=1800, custom_implicitly_wait=None, offline_mode=False): + def create_drivers(self, quantity=2, max_duration=1800, custom_implicitly_wait=None): capabilities = {'maxDuration': max_duration} - if offline_mode: - capabilities['platformVersion'] = '6.0' self.drivers = self.loop.run_until_complete(start_threads(quantity, Driver, self.drivers, diff --git a/test/appium/views/base_view.py b/test/appium/views/base_view.py index 6d6a812c90..b1cefb4f23 100644 --- a/test/appium/views/base_view.py +++ b/test/appium/views/base_view.py @@ -1,18 +1,21 @@ -import random -import string import time + import base64 import pytest +import random import re +import string import zbarlight -from tests import common_password -from eth_keys import datatypes -from selenium.common.exceptions import NoSuchElementException, TimeoutException, StaleElementReferenceException from PIL import Image +from appium.webdriver.common.touch_action import TouchAction from datetime import datetime +from eth_keys import datatypes from io import BytesIO -from views.base_element import BaseButton, BaseElement, BaseEditBox, BaseText +from selenium.common.exceptions import NoSuchElementException, TimeoutException, StaleElementReferenceException + from support.device_apps import start_web_browser +from tests import common_password +from views.base_element import BaseButton, BaseElement, BaseEditBox, BaseText class BackButton(BaseButton): @@ -290,6 +293,18 @@ class OkGotItButton(BaseButton): self.wait_for_invisibility_of_element() +class AirplaneModeButton(BaseButton): + def __init__(self, driver): + super(AirplaneModeButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@content-desc='Airplane mode']") + + def click(self): + action = TouchAction(self.driver) + action.press(None, 50, 0).move_to(None, 50, 300).perform() + super(AirplaneModeButton, self).click() + action.tap(None, 50, 600).perform() + + class BaseView(object): def __init__(self, driver): self.driver = driver @@ -326,6 +341,8 @@ class BaseView(object): self.apps_button = AppsButton(self.driver) self.status_app_icon = StatusAppIcon(self.driver) + self.airplane_mode_button = AirplaneModeButton(self.driver) + self.element_types = { 'base': BaseElement, 'button': BaseButton, diff --git a/test/appium/views/wallet_view.py b/test/appium/views/wallet_view.py index d2fb14015c..cc53695b25 100644 --- a/test/appium/views/wallet_view.py +++ b/test/appium/views/wallet_view.py @@ -113,12 +113,18 @@ class SignInPhraseText(BaseText): '//following-sibling::*[2]/android.widget.TextView') @property - def list(self): - return [element.text for element in self.find_elements()] + def string(self): + return self.text @property - def string(self): - return ' '.join(self.list) + def list(self): + return self.string.split() + + +class RemindMeLaterButton(BaseButton): + def __init__(self, driver): + super(RemindMeLaterButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Remind me later']") class AssetTextElement(BaseText): @@ -238,6 +244,7 @@ class WalletView(BaseView): self.set_up_button = SetUpButton(self.driver) self.sign_in_phrase = SignInPhraseText(self.driver) + self.remind_me_later_button = RemindMeLaterButton(self.driver) self.total_amount_text = TotalAmountText(self.driver) self.currency_text = CurrencyText(self.driver)