diff --git a/test/appium/apis/ropsten_api.py b/test/appium/apis/ropsten_api.py deleted file mode 100644 index 20953e9e50..0000000000 --- a/test/appium/apis/ropsten_api.py +++ /dev/null @@ -1,38 +0,0 @@ -import logging - -import pytest -import requests -import time - - -def get_transactions(address: str) -> dict: - url = 'http://ropsten.etherscan.io/api?module=account&action=txlist&address=0x%s&sort=desc' % address - return requests.request('GET', url=url).json()['result'] - - -def is_transaction_successful(transaction_hash: str) -> int: - url = "https://ropsten.etherscan.io/api?module=transaction&action=getstatus&txhash=%s" % transaction_hash - return not int(requests.request('GET', url=url).json()['result']['isError']) - - -def get_balance(address): - url = 'http://ropsten.etherscan.io/api?module=account&action=balance&address=0x%s&tag=latest' % address - for i in range(5): - try: - return int(requests.request('GET', url).json()["result"]) - except ValueError: - pass - - -def verify_balance_is_updated(initial_balance, recipient_address, wait_time=240): - counter = 0 - while True: - if counter == wait_time: - pytest.fail('Balance is not changed during %s seconds, funds were not received!' % wait_time) - elif initial_balance == get_balance(recipient_address): - counter += 10 - time.sleep(10) - logging.info('Waiting %s seconds for funds' % counter) - else: - logging.info('Transaction was received and verified on ropsten.etherscan.io') - break diff --git a/test/appium/apis/third_party_apis.py b/test/appium/apis/third_party_apis.py deleted file mode 100644 index 336b996d1c..0000000000 --- a/test/appium/apis/third_party_apis.py +++ /dev/null @@ -1,6 +0,0 @@ -import requests - - -def get_ethereum_price_in_usd() -> float: - url = 'https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD' - return float(requests.request('GET', url).json()['USD']) diff --git a/test/appium/tests/__init__.py b/test/appium/tests/__init__.py index 51c009a7b8..76ac9eb75e 100644 --- a/test/appium/tests/__init__.py +++ b/test/appium/tests/__init__.py @@ -1,4 +1,5 @@ import asyncio +from datetime import datetime @asyncio.coroutine @@ -18,8 +19,10 @@ class TestData(object): self.test_name = None self.apk_name = None + test_data = TestData() + basic_user = {'password': "newuniquepassword12", 'passphrase': "tree weekend ceiling awkward universe pyramid glimpse raven pair lounge grant grief", 'username': "Splendid Useless Racerunner"} @@ -63,3 +66,7 @@ transaction_users_wallet['B_USER']['username'] = "Muffled Purple Milksnake" transaction_users_wallet['B_USER']['address'] = "5261ceba31e3a7204b498b2dd20220a6057738d1" transaction_users_wallet['B_USER']['public_key'] = "0x04cd70746f3df6cae7b45c32c211bd7e9e95ed5a1ec470db8f3b1f244eed182" \ "1d4a2053d7671802c5f7ce5b81f5fc2016a8109e1bc83f151ceff21f08c0cdcc6e4" + + +def get_current_time(): + return datetime.now().strftime('%-m%-d%-H%-M%-S') diff --git a/test/appium/tests/api_requests.py b/test/appium/tests/api_requests.py new file mode 100644 index 0000000000..e8cf0b5af8 --- /dev/null +++ b/test/appium/tests/api_requests.py @@ -0,0 +1,68 @@ +import logging +import pytest +import requests +import time + + +def get_transactions(address: str) -> dict: + url = 'http://ropsten.etherscan.io/api?module=account&action=txlist&address=0x%s&sort=desc' % address + return requests.request('GET', url=url).json()['result'] + + +def is_transaction_successful(transaction_hash: str) -> int: + url = "https://ropsten.etherscan.io/api?module=transaction&action=getstatus&txhash=%s" % transaction_hash + return not int(requests.request('GET', url=url).json()['result']['isError']) + + +def get_balance(address): + url = 'http://ropsten.etherscan.io/api?module=account&action=balance&address=0x%s&tag=latest' % address + for i in range(5): + try: + return int(requests.request('GET', url).json()["result"]) + except ValueError: + pass + + +def find_transaction_on_ropsten(address: str, transaction_hash: str): + transactions = get_transactions(address=address) + for transaction in transactions: + if transaction['hash'] == transaction_hash: + logging.info('Transaction is found in Ropsten network') + return + pytest.fail('Transaction is not found in Ropsten network') + + +def verify_balance_is_updated(initial_balance, recipient_address, wait_time=240): + counter = 0 + while True: + if counter >= wait_time: + pytest.fail('Balance is not changed during %s seconds, funds were not received!' % wait_time) + elif initial_balance == get_balance(recipient_address): + counter += 10 + time.sleep(10) + logging.info('Waiting %s seconds for funds' % counter) + else: + logging.info('Transaction is received') + return + + +def get_donate(address, wait_time=300): + initial_balance = get_balance(address) + counter = 0 + if initial_balance < 1000000000000000000: + response = requests.request('GET', 'http://51.15.45.169:3001/donate/0x%s' % address).json() + while True: + if counter >= wait_time: + pytest.fail("Donation was not received during %s seconds!" % wait_time) + elif get_balance(address) == initial_balance: + counter += 10 + time.sleep(10) + logging.info('Waiting %s seconds for donation' % counter) + else: + logging.info('Got %s for %s' % (response["amount_eth"], address)) + return + + +def get_ethereum_price_in_usd() -> float: + url = 'https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD' + return float(requests.request('GET', url).json()['USD']) diff --git a/test/appium/tests/basetestcase.py b/test/appium/tests/base_test_case.py similarity index 91% rename from test/appium/tests/basetestcase.py rename to test/appium/tests/base_test_case.py index 5be86668af..6cec54f88a 100644 --- a/test/appium/tests/basetestcase.py +++ b/test/appium/tests/base_test_case.py @@ -94,15 +94,19 @@ class AbstractTestCase: def environment(self): return pytest.config.getoption('env') + @property + def implicitly_wait(self): + return 10 -class LocalMultiplyDeviceTestCase(AbstractTestCase): + +class LocalMultipleDeviceTestCase(AbstractTestCase): def setup_method(self, method): capabilities = self.add_local_devices_to_capabilities() self.driver_1 = webdriver.Remote(self.executor_local, capabilities[0]) self.driver_2 = webdriver.Remote(self.executor_local, capabilities[1]) for driver in self.driver_1, self.driver_2: - driver.implicitly_wait(10) + driver.implicitly_wait(self.implicitly_wait) def teardown_method(self, method): for driver in self.driver_1, self.driver_2: @@ -112,7 +116,7 @@ class LocalMultiplyDeviceTestCase(AbstractTestCase): pass -class SauceMultiplyDeviceTestCase(AbstractTestCase): +class SauceMultipleDeviceTestCase(AbstractTestCase): @classmethod def setup_class(cls): @@ -125,7 +129,7 @@ class SauceMultiplyDeviceTestCase(AbstractTestCase): self.executor_sauce_lab, self.capabilities_sauce_lab)) for driver in self.driver_1, self.driver_2: - driver.implicitly_wait(10) + driver.implicitly_wait(self.implicitly_wait) def teardown_method(self, method): for driver in self.driver_1, self.driver_2: @@ -151,7 +155,7 @@ class SingleDeviceTestCase(AbstractTestCase): self.driver = webdriver.Remote(capabilities[self.environment]['executor'], capabilities[self.environment]['capabilities']) - self.driver.implicitly_wait(10) + self.driver.implicitly_wait(self.implicitly_wait) def teardown_method(self, method): if self.environment == 'sauce': @@ -162,10 +166,10 @@ class SingleDeviceTestCase(AbstractTestCase): pass -environments = {'local': LocalMultiplyDeviceTestCase, - 'sauce': SauceMultiplyDeviceTestCase} +environments = {'local': LocalMultipleDeviceTestCase, + 'sauce': SauceMultipleDeviceTestCase} -class MultiplyDeviceTestCase(environments[pytest.config.getoption('env')]): +class MultipleDeviceTestCase(environments[pytest.config.getoption('env')]): pass diff --git a/test/appium/tests/conftest.py b/test/appium/tests/conftest.py index 69e635011b..0b4bc6bb24 100644 --- a/test/appium/tests/conftest.py +++ b/test/appium/tests/conftest.py @@ -18,6 +18,7 @@ def get_latest_apk(): dates.sort(key=lambda date: datetime.strptime(date, "%d-%b-%Y %H:%M"), reverse=True) return re.findall('>(.*k)\s*%s' % dates[0], raw_data)[0] + latest_nightly_apk = dict() latest_nightly_apk['name'] = get_latest_apk() latest_nightly_apk['url'] = storage + latest_nightly_apk['name'] diff --git a/test/appium/tests/preconditions.py b/test/appium/tests/preconditions.py deleted file mode 100644 index 9a85bbcee6..0000000000 --- a/test/appium/tests/preconditions.py +++ /dev/null @@ -1,45 +0,0 @@ -from datetime import datetime - - -def set_password_as_new_user(*args): - for view in args: - view.request_password_icon.click() - view.chat_request_input.send_keys("qwerty1234") - view.confirm() - view.chat_request_input.send_keys("qwerty1234") - view.confirm() - view.find_full_text( - "Here is your signing phrase. You will use it to verify your transactions. Write it down and keep it safe!") - - -def change_user_details(*args): - users_details = dict() - for device, view in enumerate(args): - current_time = datetime.now().strftime('%-m%-d%-H%-M%-S') - new_status = '#newstatus_%s' % current_time - new_username = 'New_User_Name_%s' % current_time - - view.user_status_box.click() - view.user_status_input.clear() - view.user_status_input.send_keys(new_status) - view.username_input.clear() - view.username_input.send_keys(new_username) - view.save_button.click() - - users_details[device] = dict() - users_details[device]['status'] = new_status - users_details[device]['name'] = new_username - return users_details - - -def recover_access(home, passphrase, password, username): - login = home.recover_button.click() - login.passphrase_input.send_keys(passphrase) - login.password_input.send_keys(password) - login.confirm_recover_access.click() - recovered_user = login.element_by_text(username, 'button') - login.confirm() - recovered_user.click() - login.password_input.send_keys(password) - login.sign_in_button.click() - login.find_full_text('Chats', 60) diff --git a/test/appium/tests/test_multiple_devices.py b/test/appium/tests/test_multiple_devices.py new file mode 100644 index 0000000000..42a0f9f74f --- /dev/null +++ b/test/appium/tests/test_multiple_devices.py @@ -0,0 +1,189 @@ +import pytest +from selenium.common.exceptions import NoSuchElementException, TimeoutException +from tests import api_requests +from tests.base_test_case import MultipleDeviceTestCase +from tests import user_flow, transaction_users, get_current_time +from views.console_view import ConsoleView + + +@pytest.mark.all +class TestMultipleDevices(MultipleDeviceTestCase): + + @pytest.mark.discover + def test_new_profile_name_and_status_on_discover(self): + device_1, device_2 = ConsoleView(self.driver_1), ConsoleView(self.driver_2) + for device in device_1, device_2: + user_flow.create_user(device) + device_1.back_button.click() + device_2.back_button.click() + device_1_chat, device_2_chat = device_1.get_chat_view(), device_2.get_chat_view() + device_2_public_key = user_flow.get_public_key(device_2_chat) + user_flow.add_contact(device_1_chat, device_2_public_key) + device_1_chat.chat_message_input.send_keys('test123') + device_1_chat.send_message_button.click() + device_1_chat.back_button.click() + device_2_chat.back_button.click() + new_chat_d2 = device_2_chat.element_by_text('test123', 'button') + new_chat_d2.click() + device_2_chat.add_to_contacts.click() + for _ in range(2): + device_1_chat.back_button.click() + device_2_chat.back_button.click() + device_1_profile_drawer = device_1_chat.profile_button.click() + device_2_profile_drawer = device_2_chat.profile_button.click() + device_1_profile, device_2_profile = \ + device_1_profile_drawer.profile_icon.click(), device_2_profile_drawer.profile_icon.click() + users_details = user_flow.get_new_username_and_status(device_1_profile, + device_2_profile) + device_1_profile.back_button.click() + device_2_profile.back_button.click() + device_1_discover = device_1_profile.discover_button.click() + device_2_discover = device_2_profile.discover_button.click() + for device in device_1_discover, device_2_discover: + device.all_popular.click() + for k in users_details: + device.find_full_text(users_details[k]['name']) + device.find_full_text(' ' + users_details[k]['status']) + device.back_button.click() + device.all_recent.click() + for k in users_details: + device.find_full_text(users_details[k]['name']) + device.find_full_text(users_details[k]['status'] + ' ') + + @pytest.mark.chat + def test_one_to_one_chat(self): + device_1, device_2 = ConsoleView(self.driver_1), ConsoleView(self.driver_2) + for device in device_1, device_2: + user_flow.create_user(device) + device_1.back_button.click() + device_2.back_button.click() + device_1_chat = device_1.get_chat_view() + device_2_chat = device_2.get_chat_view() + device_1_public_key = user_flow.get_public_key(device_1_chat) + user_flow.add_contact(device_2_chat, device_1_public_key) + message_1 = 'SOMETHING' + message_2 = 'another SOMETHING' + user_d1_name = device_2_chat.user_name_text.text + device_2_chat.chat_message_input.send_keys(message_1) + device_2_chat.send_message_button.click() + device_1_chat.back_button.click() + device_1_chat.find_full_text(message_1) + one_to_one_chat_d1 = device_1_chat.element_by_text(message_1, 'button') + one_to_one_chat_d1.click() + one_to_one_chat_d2 = device_2_chat.element_by_text(user_d1_name, 'button') + one_to_one_chat_d2.click() + device_2_chat.chat_message_input.send_keys(message_2) + device_2_chat.send_message_button.click() + device_1_chat.find_full_text(message_2) + + @pytest.mark.chat + def test_group_chat_send_receive_messages_and_remove_user(self): + device_1, device_2 = ConsoleView(self.driver_1), \ + ConsoleView(self.driver_2) + for device in device_1, device_2: + user_flow.create_user(device) + device_1.back_button.click() + device_2.back_button.click() + device_1_chat = device_1.get_chat_view() + device_2_chat = device_2.get_chat_view() + device_1_public_key = user_flow.get_public_key(device_1_chat) + user_flow.add_contact(device_2_chat, device_1_public_key) + device_1_user_name = device_2_chat.user_name_text.text + for _ in range(3): + device_2.back_button.click() + chat_name = 'new_chat' + message_1 = 'first SOMETHING' + message_2 = 'second SOMETHING' + message_3 = 'third SOMETHING' + user_flow.create_group_chat(device_2_chat, device_1_user_name, chat_name) + + # send_and_receive_messages + device_2_chat.chat_message_input.send_keys(message_1) + device_2_chat.send_message_button.click() + device_1.back_button.click() + device_1_chat = device_1.get_chat_view() + device_1_chat.find_full_text(message_1) + group_chat_d1 = device_1_chat.element_by_text(chat_name, 'button') + group_chat_d1.click() + device_2_chat.chat_message_input.send_keys(message_2) + device_2_chat.send_message_button.click() + device_1_chat.find_full_text(message_2) + + # remove user + device_2_chat.group_chat_options.click() + device_2_chat.chat_settings.click() + for _ in range(2): + try: + device_2_chat.user_options.click() + except (NoSuchElementException, TimeoutException): + pass + device_2_chat.remove_button.click() + device_2_chat.confirm() + device_2.back_button.click() + + # verify removed user receives no messages + device_2_chat.chat_message_input.send_keys(message_3) + device_2_chat.send_message_button.click() + device_1_chat.find_text_part("removed you from group chat") + message_text = device_1_chat.element_by_text(message_3, 'text') + if message_text.is_element_present(20): + pytest.fail('Message is shown for the user which has been removed from the GroupChat', False) + + @pytest.mark.transaction + @pytest.mark.parametrize("test, recipient, sender", [('group_chat', + transaction_users['A_USER'], transaction_users['B_USER']), + ('one_to_one_chat', + transaction_users['B_USER'], transaction_users['A_USER']) + ], + ids=['group_chat', 'one_to_one_chat']) + def test_send_funds_via_request(self, test, recipient, sender): + device_1, device_2 = ConsoleView(self.driver_1), ConsoleView(self.driver_2) + user_flow.recover_access(device_1, + passphrase=recipient['passphrase'], + password=recipient['password'], + username=recipient['username']) + user_flow.recover_access(device_2, + passphrase=sender['passphrase'], + password=sender['password'], + username=sender['username']) + device_2_chat = device_2.get_chat_view() + device_1_chat = device_1.get_chat_view() + if test == 'group_chat': + user_flow.add_contact(device_1_chat, sender['public_key']) + for _ in range(2): + device_1_chat.back_button.click() + group_chat_name = 'gtr_%s' % get_current_time() + user_flow.create_group_chat(device_1_chat, sender['username'], group_chat_name) + group_chat_d2 = device_2_chat.element_by_text(group_chat_name, 'button') + group_chat_d2.click() + else: + device_1_chat.element_by_text_part(sender['username'][:25], 'button').click() + device_1_chat.request_command.click() + amount = device_1_chat.get_unique_amount() + if test == 'group_chat': + device_1_chat.first_recipient_button.click() + device_1_chat.send_as_keyevent(amount) + else: + device_1_chat.chat_message_input.set_value(amount) + device_1_chat.send_message_button.click() + initial_balance_recipient = api_requests.get_balance(recipient['address']) + if test == 'group_chat': + device_1_chat.find_full_text('from ' + sender['username'], 20) + device_2_chat.find_full_text('from ' + sender['username'], 20) + device_2_chat.element_by_text_part(recipient['username'][:25], 'button').click() + device_2_chat.element_by_text_part('Requesting %s ETH' % amount, 'button').click() + device_2_chat.send_message_button.click() + device_2_send_transaction = device_2_chat.get_send_transaction_view() + device_2_send_transaction.sign_transaction_button.click() + device_2_send_transaction.enter_password_input.send_keys(sender['password']) + device_2_send_transaction.sign_transaction_button.click() + device_2_send_transaction.got_it_button.click() + api_requests.verify_balance_is_updated(initial_balance_recipient, recipient['address']) + device_2_chat.back_button.click() + device_2_wallet = device_2_chat.wallet_button.click() + transactions_view = device_2_wallet.transactions_button.click() + transaction_element = transactions_view.transactions_table.find_transaction(amount=amount) + transaction_details_view = transaction_element.click() + transaction_hash = transaction_details_view.get_transaction_hash() + api_requests.find_transaction_on_ropsten(address=sender['address'], + transaction_hash=transaction_hash) diff --git a/test/appium/tests/test_multiply_device.py b/test/appium/tests/test_multiply_device.py deleted file mode 100644 index ef61bdca83..0000000000 --- a/test/appium/tests/test_multiply_device.py +++ /dev/null @@ -1,243 +0,0 @@ -import pytest -from selenium.common.exceptions import NoSuchElementException - -from apis.ropsten_api import get_balance, verify_balance_is_updated -from tests.basetestcase import MultiplyDeviceTestCase -from tests.preconditions import set_password_as_new_user, change_user_details, recover_access -from tests import transaction_users -from views.base_view import verify_transaction_in_ropsten -from views.chats import get_unique_amount -from views.home import HomeView - - -@pytest.mark.all -class TestMultiplyDevices(MultiplyDeviceTestCase): - - @pytest.mark.discover - def test_new_profile_name_and_status_on_discover(self): - device_1, device_2 = HomeView(self.driver_1), HomeView(self.driver_2) - set_password_as_new_user(device_1, device_2) - device_1.back_button.click() - device_2.back_button.click() - - chats_d1, chats_d2 = device_1.get_chats(), device_2.get_chats() - chats_d2.profile_button.click() - profile_d2 = chats_d2.profile_icon.click() - d2_public_key = profile_d2.public_key_text.text - - chats_d1.plus_button.click() - chats_d1.add_new_contact.click() - chats_d1.public_key_edit_box.send_keys(d2_public_key) - chats_d1.confirm() - chats_d1.confirm_public_key_button.click() - chats_d1.chat_message_input.send_keys('test123') - chats_d1.send_message_button.click() - chats_d2.back_button.click() - - new_chat_d2 = chats_d2.element_by_text('test123', 'button') - new_chat_d2.click() - - for _ in range(3): - chats_d1.back_button.click() - chats_d2.add_to_contacts.click() - chats_d2.back_button.click() - chats_d1.profile_button.click() - chats_d2.profile_button.click() - - profile_d1, profile_d2 = chats_d1.profile_icon.click(), chats_d2.profile_icon.click() - users_details = change_user_details(profile_d1, profile_d2) - profile_d1.back_button.click() - profile_d2.back_button.click() - discover_d1 = profile_d1.discover_button.click() - discover_d2 = profile_d2.discover_button.click() - for device in discover_d1, discover_d2: - device.all_popular.click() - for k in users_details: - device.find_full_text(users_details[k]['name']) - device.find_full_text(' ' + users_details[k]['status']) - device.back_button.click() - device.all_recent.click() - for k in users_details: - device.find_full_text(users_details[k]['name']) - device.find_full_text(users_details[k]['status'] + ' ') - - @pytest.mark.chat - def test_one_to_one_chat(self): - - device_1, device_2 = HomeView(self.driver_1), HomeView(self.driver_2) - set_password_as_new_user(device_1, device_2) - device_1.back_button.click() - - chats_d1 = device_1.get_chats() - chats_d1.profile_button.click() - profile_d1 = chats_d1.profile_icon.click() - key = profile_d1.public_key_text.text - device_2.back_button.click() - - chats_d2 = device_2.get_chats() - chats_d2.plus_button.click() - chats_d2.add_new_contact.click() - chats_d2.public_key_edit_box.send_keys(key) - chats_d2.confirm() - chats_d2.confirm_public_key_button.click() - - message_1 = 'SOMETHING' - message_2 = 'another SOMETHING' - user_d1_name = chats_d2.user_name_text.text - - chats_d2.chat_message_input.send_keys(message_1) - chats_d2.send_message_button.click() - - chats_d1.back_button.click() - chats_d1.find_full_text(message_1) - one_to_one_chat_d1 = chats_d1.element_by_text(message_1, 'button') - one_to_one_chat_d1.click() - - one_to_one_chat_d2 = chats_d2.element_by_text(user_d1_name, 'button') - one_to_one_chat_d2.click() - chats_d2.chat_message_input.send_keys(message_2) - chats_d2.send_message_button.click() - - chats_d1.find_full_text(message_2) - - @pytest.mark.chat - def test_group_chat_send_receive_messages_and_remove_user(self): - - device_1, device_2 = HomeView(self.driver_1), \ - HomeView(self.driver_2) - set_password_as_new_user(device_2, device_1) - - device_1.back_button.click() - chats_d1 = device_1.get_chats() - chats_d1.profile_button.click() - profile_d1 = chats_d1.profile_icon.click() - key = profile_d1.public_key_text.text - - device_2.back_button.click() - chats_d2 = device_2.get_chats() - chats_d2.plus_button.click() - chats_d2.add_new_contact.click() - chats_d2.public_key_edit_box.send_keys(key) - chats_d2.confirm() - chats_d2.confirm_public_key_button.click() - user_name_d1 = chats_d2.user_name_text.text - - for _ in range(2): - device_2.back_button.click() - chats_d2.new_group_chat_button.click() - - user_contact = chats_d2.element_by_text(user_name_d1, 'button') - user_contact.scroll_to_element() - user_contact.click() - chats_d2.next_button.click() - - chat_name = 'new_chat' - message_1 = 'first SOMETHING' - message_2 = 'second SOMETHING' - message_3 = 'third SOMETHING' - - chats_d2.name_edit_box.send_keys(chat_name) - chats_d2.save_button.click() - - # send_and_receive_messages - - chats_d2.chat_message_input.send_keys(message_1) - chats_d2.send_message_button.click() - - profile_d1.back_button.click() - chats_d1 = profile_d1.get_chats() - chats_d1.find_full_text(message_1) - group_chat_d1 = chats_d1.element_by_text(chat_name, 'button') - group_chat_d1.click() - - chats_d2.chat_message_input.send_keys(message_2) - chats_d2.send_message_button.click() - - chats_d1.find_full_text(message_2) - - # remove_user - - chats_d2.group_chat_options.click() - chats_d2.chat_settings.click() - chats_d2.confirm() - chats_d2.user_options.click() - chats_d2.remove_button.click() - device_2.back_button.click() - - # chats_d2.find_full_text("You\'ve removed " + user_name_d1) - - chats_d2.chat_message_input.send_keys(message_3) - chats_d2.send_message_button.click() - - chats_d1.find_text_part("removed you from group chat") - message_text = chats_d1.element_by_text(message_3, 'text') - if message_text.is_element_present(20): - pytest.fail('Message is shown for the user which has been removed from the GroupChat', False) - - @pytest.mark.transaction - @pytest.mark.parametrize("test, recipient, sender", [('group_chat', - transaction_users['A_USER'], transaction_users['B_USER']), - ('one_to_one_chat', - transaction_users['B_USER'], transaction_users['A_USER'])], - ids=['group_chat', - 'one_to_one_chat']) - def test_send_funds_via_request(self, test, recipient, sender): - device_1, device_2 = HomeView(self.driver_1), HomeView(self.driver_2) - recover_access(device_1, - passphrase=recipient['passphrase'], - password=recipient['password'], - username=recipient['username']) - chats_d1 = device_1.get_chats() - recover_access(device_2, - passphrase=sender['passphrase'], - password=sender['password'], - username=sender['username']) - chats_d2 = device_2.get_chats() - try: - chats_d1.element_by_text_part(sender['username'][:25], 'button').click() - except NoSuchElementException: - chats_d1.plus_button.click() - chats_d1.add_new_contact.click() - chats_d1.public_key_edit_box.send_keys(sender['public_key']) - chats_d1.confirm() - chats_d1.confirm_public_key_button.click() - if test == 'group_chat': - for _ in range(2): - chats_d1.back_button.click() - chats_d1.new_group_chat_button.click() - sender_username = chats_d1.element_by_text(sender['username'], 'button') - sender_username.scroll_to_element() - sender_username.click() - chats_d1.next_button.click() - chat_name = 'transaction_group_chat' - chats_d1.name_edit_box.send_keys(chat_name) - chats_d1.save_button.click() - group_chat_d2 = chats_d2.element_by_text(chat_name, 'button') - group_chat_d2.click() - chats_d1.request_funds_button.click() - amount = get_unique_amount() - if test == 'group_chat': - chats_d1.first_recipient_button.click() - chats_d1.send_as_keyevent(amount) - else: - chats_d1.chat_message_input.set_value(amount) - chats_d1.send_message_button.click() - initial_balance_recipient = get_balance(recipient['address']) - if test == 'group_chat': - chats_d1.find_full_text('from ' + sender['username'], 60) - chats_d2.find_full_text('from ' + sender['username'], 60) - chats_d2.element_by_text_part(recipient['username'][:25], 'button').click() - chats_d2.element_by_text_part('Requesting %s ETH' % amount, 'button').click() - chats_d2.send_message_button.click() - chats_d2.sign_transaction_button.click() - chats_d2.enter_password_input.send_keys(sender['password']) - chats_d2.sign_transaction_button.click() - chats_d2.got_it_button.click() - verify_balance_is_updated(initial_balance_recipient, recipient['address']) - chats_d2.back_button.click() - wallet = chats_d2.wallet_button.click() - tr_view = wallet.transactions_button.click() - transaction = tr_view.transactions_table.find_transaction(amount=amount) - details_view = transaction.click() - transaction_hash = details_view.get_transaction_hash() - verify_transaction_in_ropsten(address=sender['address'], transaction_hash=transaction_hash) diff --git a/test/appium/tests/test_networks.py b/test/appium/tests/test_networks.py index 71c47fb81e..2bf13a1304 100644 --- a/test/appium/tests/test_networks.py +++ b/test/appium/tests/test_networks.py @@ -1,8 +1,8 @@ import pytest from itertools import combinations_with_replacement -from tests.basetestcase import MultiplyDeviceTestCase, SingleDeviceTestCase -from tests.preconditions import set_password_as_new_user -from views.home import HomeView +from tests.base_test_case import MultipleDeviceTestCase, SingleDeviceTestCase +from tests import user_flow +from views.console_view import ConsoleView from selenium.common.exceptions import TimeoutException @@ -13,20 +13,20 @@ class TestNetwork(SingleDeviceTestCase): 'Mainnet', 'Mainnet with upstream RPC']) def test_network_switch(self, network): - home = HomeView(self.driver) - set_password_as_new_user(home) - home.back_button.click() - chats = home.get_chats() - chats.profile_button.click() - profile = chats.profile_icon.click() - login = profile.switch_network(network) - login.first_account_button.click() - login.password_input.send_keys('qwerty1234') - login.sign_in_button.click() - login.find_full_text('Chats', 20) + console = ConsoleView(self.driver) + user_flow.create_user(console) + console.back_button.click() + chats = console.get_chat_view() + profile_drawer = chats.profile_button.click() + profile_view = profile_drawer.profile_icon.click() + sign_in_view = profile_view.switch_network(network) + sign_in_view.first_account_button.click() + sign_in_view.password_input.send_keys('qwerty1234') + sign_in_view.sign_in_button.click() + sign_in_view.find_full_text('Chats', 20) -class TestNetworkChats(MultiplyDeviceTestCase): +class TestNetworkChats(MultipleDeviceTestCase): network_combinations = list(combinations_with_replacement( ['Ropsten', 'Rinkeby', 'Mainnet', @@ -36,54 +36,51 @@ class TestNetworkChats(MultiplyDeviceTestCase): @pytest.mark.parametrize("network", network_combinations, ids=[i[0] + ' & ' + i[1] for i in network_combinations]) def test_one_to_one_chat_between(self, network): - device_1, device_2 = HomeView(self.driver_1), HomeView(self.driver_2) - set_password_as_new_user(device_1, device_2) + device_1, device_2 = ConsoleView(self.driver_1), ConsoleView(self.driver_2) + for device in device_1, device_2: + user_flow.create_user(device) device_1.back_button.click() - chats_d1 = device_1.get_chats() - chats_d1.profile_button.click() - profile_d1 = chats_d1.profile_icon.click() - key = profile_d1.public_key_text.text + device_1_chats = device_1.get_chat_view() + device_1_profile_drawer= device_1_chats.profile_button.click() + device_1_profile_view = device_1_profile_drawer.profile_icon.click() + device_1_public_key = device_1_profile_view.public_key_text.text if network[0] != 'Ropsten with upstream RPC': - login_d1 = profile_d1.switch_network(network[0]) + login_d1 = device_1_profile_view.switch_network(network[0]) login_d1.first_account_button.click() login_d1.password_input.send_keys('qwerty1234') login_d1.sign_in_button.click() login_d1.find_full_text('Chats', 60) else: - profile_d1.back_button.click() + device_1_profile_view.back_button.click() device_2.back_button.click() - chats_d2 = device_2.get_chats() + device_2_chats = device_2.get_chat_view() if network[1] != 'Ropsten with upstream RPC': - chats_d2.profile_button.click() - profile_d2 = chats_d2.profile_icon.click() - login_d2 = profile_d2.switch_network(network[1]) - login_d2.first_account_button.click() - login_d2.password_input.send_keys('qwerty1234') - login_d2.sign_in_button.click() - login_d2.find_full_text('Chats', 60) - chats_d2.plus_button.click() - chats_d2.add_new_contact.click() - chats_d2.public_key_edit_box.send_keys(key) - chats_d2.confirm() - chats_d2.confirm_public_key_button.click() + device_2_profile_drawer = device_2_chats.profile_button.click() + device_2_profile_view = device_2_profile_drawer.profile_icon.click() + device_2_sign_in = device_2_profile_view.switch_network(network[1]) + device_2_sign_in.first_account_button.click() + device_2_sign_in.password_input.send_keys('qwerty1234') + device_2_sign_in.sign_in_button.click() + device_2_sign_in.find_full_text('Chats', 60) + user_flow.add_contact(device_2_chats,device_1_public_key ) message_1 = network[0] message_2 = network[1] - user_d1_name = chats_d2.user_name_text.text - chats_d2.chat_message_input.send_keys(message_2) - chats_d2.send_message_button.click() + user_d1_name = device_2_chats.user_name_text.text + device_2_chats.chat_message_input.send_keys(message_2) + device_2_chats.send_message_button.click() errors = list() try: - chats_d1.find_full_text(message_2) + device_1_chats.find_full_text(message_2) except TimeoutException: errors.append("Message '%s' wasn't received by Device #1") - one_to_one_chat_d1 = chats_d1.element_by_text(message_2, 'button') + one_to_one_chat_d1 = device_1_chats.element_by_text(message_2, 'button') one_to_one_chat_d1.click() - one_to_one_chat_d2 = chats_d2.element_by_text(user_d1_name, 'button') + one_to_one_chat_d2 = device_2_chats.element_by_text(user_d1_name, 'button') one_to_one_chat_d2.click() - chats_d1.chat_message_input.send_keys(message_1) - chats_d1.send_message_button.click() + device_1_chats.chat_message_input.send_keys(message_1) + device_1_chats.send_message_button.click() try: - chats_d2.find_full_text(message_1) + device_2_chats.find_full_text(message_1) except TimeoutException: errors.append("Message '%s' wasn't received by Device #2") if errors: diff --git a/test/appium/tests/test_sanity.py b/test/appium/tests/test_sanity.py index f485168ba6..423f9915c6 100644 --- a/test/appium/tests/test_sanity.py +++ b/test/appium/tests/test_sanity.py @@ -1,86 +1,34 @@ import pytest import time -from tests.basetestcase import SingleDeviceTestCase -from views.home import HomeView -from tests.preconditions import set_password_as_new_user +from tests.base_test_case import SingleDeviceTestCase +from views.console_view import ConsoleView +from tests import user_flow from tests import basic_user @pytest.mark.all -class TestAccess(SingleDeviceTestCase): - - @pytest.mark.profile - def test_change_profile_name_and_status(self): - home = HomeView(self.driver) - set_password_as_new_user(home) - chats = home.get_chats() - chats.back_button.click() - chats.profile_button.click() - profile = chats.profile_icon.click() - - new_status = '#newstatus' - new_username = 'NewUserName!' - - profile.user_status_box.click() - profile.user_status_input.clear() - profile.user_status_input.send_keys(new_status) - profile.username_input.clear() - profile.username_input.send_keys(new_username) - profile.save_button.click() - profile.back_button.click() - - chats.profile_button.click() - login = chats.switch_users_button.click() - user = login.element_by_text(new_username, 'button') - user.click() - login.password_input.send_keys('qwerty1234') - login.sign_in_button.click() - home.find_full_text('Chats', 60) - chats.profile_button.click() - for text in new_status + ' ', new_username: - chats.find_full_text(text, 5) - - @pytest.mark.recover - def test_recover_access(self): - home = HomeView(self.driver) - set_password_as_new_user(home) - chats = home.get_chats() - chats.back_button.click() - chats.profile_button.click() - login = chats.switch_users_button.click() - login.recover_access_button.click() - login.passphrase_input.send_keys(basic_user['passphrase']) - login.password_input.send_keys(basic_user['password']) - login.confirm_recover_access.click() - recovered_user = login.element_by_text(basic_user['username'], 'button') - recovered_user.click() - login.password_input.send_keys(basic_user['password']) - login.sign_in_button.click() - home.find_full_text('Chats', 60) - if basic_user['password'] in str(home.logcat): - pytest.fail('Password in logcat!!!', pytrace=False) +class TestSanity(SingleDeviceTestCase): @pytest.mark.sign_in @pytest.mark.parametrize("verification", ["invalid", "valid"]) def test_sign_in(self, verification): - verifications = {"valid": {"input": "qwerty1234", "outcome": "Chats"}, "invalid": {"input": "12345ewq", "outcome": "Wrong password"}} - home = HomeView(self.driver) - set_password_as_new_user(home) - chats = home.get_chats() - chats.back_button.click() - chats.profile_button.click() - login = chats.switch_users_button.click() - login.first_account_button.click() - login.password_input.send_keys(verifications[verification]['input']) - login.sign_in_button.click() - home.find_full_text(verifications[verification]["outcome"], 60) - if verifications[verification]["input"] in str(home.logcat): + console_view = ConsoleView(self.driver) + user_flow.create_user(console_view) + chats_view = console_view.get_chat_view() + chats_view.back_button.click() + profile_drawer = chats_view.profile_button.click() + sign_in_view = profile_drawer.switch_users_button.click() + sign_in_view.first_account_button.click() + sign_in_view.password_input.send_keys(verifications[verification]['input']) + sign_in_view.sign_in_button.click() + console_view.find_full_text(verifications[verification]["outcome"], 60) + if verifications[verification]["input"] in str(console_view.logcat): pytest.fail('Password in logcat!!!', pytrace=False) @pytest.mark.password @@ -97,13 +45,61 @@ class TestAccess(SingleDeviceTestCase): "outcome": "Here is your signing phrase. " "You will use it to verify your transactions. " "Write it down and keep it safe!"}} - home = HomeView(self.driver) - home.request_password_icon.click() - home.chat_request_input.send_keys(verifications[verification]["input"]) - home.confirm() + console = ConsoleView(self.driver) + console.request_password_icon.click() + console.chat_request_input.send_keys(verifications[verification]["input"]) + console.confirm() if 'short' not in verification: - home.chat_request_input.send_keys("new_unique_password") - home.confirm() - home.find_full_text(verifications[verification]["outcome"]) - if verifications[verification]["input"] in str(home.logcat): + console.chat_request_input.send_keys("new_unique_password") + console.confirm() + console.find_full_text(verifications[verification]["outcome"]) + if verifications[verification]["input"] in str(console.logcat): + pytest.fail('Password in logcat!!!', pytrace=False) + + @pytest.mark.profile + def test_change_profile_name_and_status(self): + new_status = '#newstatus' + new_username = 'NewUserName!' + console_view = ConsoleView(self.driver) + user_flow.create_user(console_view) + chats_view = console_view.get_chat_view() + chats_view.back_button.click() + profile_drawer = chats_view.profile_button.click() + profile_view = profile_drawer.profile_icon.click() + profile_view.user_status_box.click() + profile_view.user_status_input.clear() + profile_view.user_status_input.send_keys(new_status) + profile_view.username_input.clear() + profile_view.username_input.send_keys(new_username) + profile_view.save_button.click() + profile_view.back_button.click() + chats_view.profile_button.click() + sign_in_view = profile_drawer.switch_users_button.click() + user = sign_in_view.element_by_text(new_username, 'button') + user.click() + sign_in_view.password_input.send_keys('qwerty1234') + sign_in_view.sign_in_button.click() + chats_view.find_full_text('Chats', 60) + chats_view.profile_button.click() + for text in new_status + ' ', new_username: + chats_view.find_full_text(text, 5) + + @pytest.mark.recover + def test_recover_access(self): + console_view = ConsoleView(self.driver) + user_flow.create_user(console_view) + chats_view = console_view.get_chat_view() + chats_view.back_button.click() + profile_drawer = chats_view.profile_button.click() + sign_in_view = profile_drawer.switch_users_button.click() + recover_access_view = sign_in_view.recover_access_button.click() + recover_access_view.passphrase_input.send_keys(basic_user['passphrase']) + recover_access_view.password_input.send_keys(basic_user['password']) + recover_access_view.confirm_recover_access.click() + recovered_user = sign_in_view.element_by_text(basic_user['username'], 'button') + recovered_user.click() + sign_in_view.password_input.send_keys(basic_user['password']) + sign_in_view.sign_in_button.click() + console_view.find_full_text('Chats', 60) + if basic_user['password'] in str(console_view.logcat): pytest.fail('Password in logcat!!!', pytrace=False) diff --git a/test/appium/tests/test_transaction.py b/test/appium/tests/test_transaction.py index 0003652736..2e95e4b794 100644 --- a/test/appium/tests/test_transaction.py +++ b/test/appium/tests/test_transaction.py @@ -1,109 +1,96 @@ import pytest import time - -from apis.ropsten_api import verify_balance_is_updated, get_balance -from tests.basetestcase import SingleDeviceTestCase -from views.home import HomeView -from tests.preconditions import recover_access -from tests import transaction_users -from selenium.common.exceptions import TimeoutException +from views.console_view import ConsoleView +from tests.base_test_case import SingleDeviceTestCase +from tests import user_flow, transaction_users, api_requests, get_current_time +from selenium.common.exceptions import TimeoutException, NoSuchElementException @pytest.mark.all class TestTransactions(SingleDeviceTestCase): @pytest.mark.transaction - @pytest.mark.parametrize("test, recipient, sender", [('group_chat', 'A_USER', 'B_USER'), - ('one_to_one_chat', 'B_USER', 'A_USER'), - ('wrong_password', 'A_USER', 'B_USER')], + @pytest.mark.parametrize("test, recipient", [('group_chat', 'A_USER'), + ('one_to_one_chat', 'B_USER'), + ('wrong_password', 'A_USER')], ids=['group_chat', 'one_to_one_chat', 'wrong_password']) - def test_send_transaction(self, test, recipient, sender): - home = HomeView(self.driver) - recover_access(home, - transaction_users[sender]['passphrase'], - transaction_users[sender]['password'], - transaction_users[sender]['username']) - chats = home.get_chats() - chats.wait_for_syncing_complete() - - sender_address = transaction_users[sender]['address'] + def test_transaction_send_command(self, test, recipient): + console_view = ConsoleView(self.driver) + user_flow.create_user(console_view) + console_view.back_button.click() + chats_view = console_view.get_chat_view() recipient_address = transaction_users[recipient]['address'] recipient_key = transaction_users[recipient]['public_key'] - initial_balance_recipient = get_balance(recipient_address) + transaction_amount = '0.001' + sender_address = user_flow.get_address(chats_view) + chats_view.back_button.click() + api_requests.get_donate(sender_address) + initial_balance_recipient = api_requests.get_balance(recipient_address) - chats.plus_button.click() - chats.add_new_contact.click() - chats.public_key_edit_box.send_keys(recipient_key) - chats.confirm() - chats.confirm_public_key_button.click() + # next 2 lines are bypassing issue #2417 + wallet_view = chats_view.wallet_button.click() + wallet_view.chats_button.click() + user_flow.add_contact(chats_view, recipient_key) if test == 'group_chat': - user_name = chats.user_name_text.text - for _ in range(2): - chats.back_button.click() - chats.new_group_chat_button.click() - user_contact = chats.element_by_text(user_name, 'button') - user_contact.scroll_to_element() - user_contact.click() - chats.next_button.click() - chats.name_edit_box.send_keys('chat_send_transaction') - chats.save_button.click() - - chats.send_funds_button.click() - if test == 'group_chat': - chats.first_recipient_button.click() - chats.send_as_keyevent('0,1') + for _ in range(3): + chats_view.back_button.click() + user_flow.create_group_chat(chats_view, transaction_users[recipient]['username'], + 'trg_%s' % get_current_time()) else: - chats.send_as_keyevent('0,1') - chats.send_message_button.click() - chats.sign_transaction_button.wait_for_element(20) - chats.sign_transaction_button.click() - + chats_view.element_by_text(transaction_users[recipient]['username'], 'button').click() + chats_view.send_command.click() + if test == 'group_chat': + chats_view.first_recipient_button.click() + chats_view.send_as_keyevent(transaction_amount) + else: + chats_view.send_as_keyevent(transaction_amount) + chats_view.send_message_button.click() + send_transaction_view = chats_view.get_send_transaction_view() + send_transaction_view.sign_transaction_button.wait_for_element(5) + send_transaction_view.sign_transaction_button.click() if test == 'wrong_password': - chats.enter_password_input.send_keys('invalid') - chats.sign_transaction_button.click() - chats.find_full_text('Wrong password', 20) - + send_transaction_view.enter_password_input.send_keys('invalid') + send_transaction_view.sign_transaction_button.click() + send_transaction_view.find_full_text('Wrong password', 20) else: - chats.enter_password_input.send_keys(transaction_users[sender]['password']) - chats.sign_transaction_button.click() - chats.got_it_button.click() - chats.find_full_text('0.1') + send_transaction_view.enter_password_input.send_keys('qwerty1234') + send_transaction_view.sign_transaction_button.click() + send_transaction_view.got_it_button.click() + send_transaction_view.find_full_text(transaction_amount) try: - chats.find_full_text('Sent', 10) + chats_view.find_full_text('Sent', 10) except TimeoutException: - chats.find_full_text('Delivered', 10) + chats_view.find_full_text('Delivered', 10) if test == 'group_chat': - chats.find_full_text('to ' + transaction_users[recipient]['username'], 60) - verify_balance_is_updated(initial_balance_recipient, recipient_address) + chats_view.find_full_text('to ' + transaction_users[recipient]['username'], 60) + api_requests.verify_balance_is_updated(initial_balance_recipient, recipient_address) @pytest.mark.transaction def test_send_transaction_from_daap(self): - home = HomeView(self.driver) - recover_access(home, - transaction_users['B_USER']['passphrase'], - transaction_users['B_USER']['password'], - transaction_users['B_USER']['username']) - chats = home.get_chats() - + console = ConsoleView(self.driver) + user_flow.recover_access(console, + transaction_users['B_USER']['passphrase'], + transaction_users['B_USER']['password'], + transaction_users['B_USER']['username']) + chats_view = console.get_chat_view() address = transaction_users['B_USER']['address'] - initial_balance = get_balance(address) - contacts = chats.contacts_button.click() - auction_house = contacts.auction_house_button.click() - + initial_balance = api_requests.get_balance(address) + contacts_view = chats_view.contacts_button.click() + auction_house = contacts_view.auction_house_button.click() auction_house.toggle_navigation_button.click() auction_house.new_auction_button.click() auction_house.name_to_reserve_input.click() auction_name = time.strftime('%Y-%m-%d-%H-%M') auction_house.send_as_keyevent(auction_name) auction_house.register_name_button.click() - - chats.sign_transaction_button.wait_for_element(20) - chats.sign_transaction_button.click() - chats.enter_password_input.send_keys(transaction_users['B_USER']['password']) - chats.sign_transaction_button.click() - chats.got_it_button.click() + send_transaction_view = chats_view.get_send_transaction_view() + send_transaction_view.sign_transaction_button.wait_for_element(20) + send_transaction_view.sign_transaction_button.click() + send_transaction_view.enter_password_input.send_keys(transaction_users['B_USER']['password']) + send_transaction_view.sign_transaction_button.click() + send_transaction_view.got_it_button.click() auction_house.find_full_text('You are the proud owner of the name: ' + auction_name, 120) - verify_balance_is_updated(initial_balance, address) + api_requests.verify_balance_is_updated(initial_balance, address) diff --git a/test/appium/tests/test_wallet.py b/test/appium/tests/test_wallet.py index bd7fb89ed2..7f86b364a6 100644 --- a/test/appium/tests/test_wallet.py +++ b/test/appium/tests/test_wallet.py @@ -1,13 +1,8 @@ import pytest - -from apis.ropsten_api import get_balance, verify_balance_is_updated -from apis.third_party_apis import get_ethereum_price_in_usd -from tests.basetestcase import SingleDeviceTestCase -from views.base_view import verify_transaction_in_ropsten -from views.chats import get_unique_amount -from views.home import HomeView -from tests.preconditions import set_password_as_new_user, recover_access -from tests import transaction_users_wallet +from selenium.common.exceptions import TimeoutException, NoSuchElementException +from tests import api_requests, user_flow, transaction_users_wallet +from tests.base_test_case import SingleDeviceTestCase +from views.console_view import ConsoleView @pytest.mark.all @@ -15,121 +10,111 @@ class TestWallet(SingleDeviceTestCase): @pytest.mark.wallet def test_wallet_error_messages(self): - home = HomeView(self.driver) - set_password_as_new_user(home) - chats = home.get_chats() + console = ConsoleView(self.driver) + user_flow.create_user(console) + chats = console.get_chat_view() chats.back_button.click() - wallet_view = chats.wallet_button.click() wallet_view.send_button.click() - wallet_view.amount_edit_box.send_keys('asd') - wallet_view.find_full_text('Amount is not a valid number') - wallet_view.amount_edit_box.send_keys('0,1') - wallet_view.find_full_text('Insufficient funds') + send_transaction = wallet_view.get_send_transaction_view() + send_transaction.amount_edit_box.send_keys('asd') + send_transaction.find_full_text('Amount is not a valid number') + send_transaction.amount_edit_box.send_keys('0,1') + send_transaction.find_full_text('Insufficient funds') @pytest.mark.wallet def test_request_transaction_from_wallet(self): - home = HomeView(self.driver) - recover_access(home, - transaction_users_wallet['A_USER']['passphrase'], - transaction_users_wallet['A_USER']['password'], - transaction_users_wallet['A_USER']['username']) - chats = home.get_chats() - chats.wait_for_syncing_complete() - + console_view = ConsoleView(self.driver) + user_flow.recover_access(console_view, + transaction_users_wallet['A_USER']['passphrase'], + transaction_users_wallet['A_USER']['password'], + transaction_users_wallet['A_USER']['username']) + chats_view = console_view.get_chat_view() recipient_key = transaction_users_wallet['B_USER']['public_key'] - - chats.plus_button.click() - chats.add_new_contact.click() - chats.public_key_edit_box.send_keys(recipient_key) - chats.confirm() - chats.confirm_public_key_button.click() - + user_flow.add_contact(chats_view, recipient_key) for _ in range(3): - chats.back_button.click() - wallet = chats.wallet_button.click() - wallet.request_button.click() - wallet.amount_edit_box.scroll_to_element() - wallet.amount_edit_box.send_keys('0.1') - wallet.send_request_button.click() - user_contact = chats.element_by_text(transaction_users_wallet['B_USER']['username'], 'button') + try: + chats_view.back_button.click() + except(TimeoutException, NoSuchElementException): + pass + wallet_view = chats_view.wallet_button.click() + wallet_view.request_button.click() + send_transaction_view = wallet_view.get_send_transaction_view() + send_transaction_view.amount_edit_box.scroll_to_element() + send_transaction_view.amount_edit_box.send_keys('0.1') + wallet_view.send_request_button.click() + user_contact = chats_view.element_by_text(transaction_users_wallet['B_USER']['username'], 'button') user_contact.click() - chats.find_text_part('Requesting 0.1 ETH') + chats_view.find_text_part('Requesting 0.1 ETH') @pytest.mark.parametrize("test, recipient, sender", [('sign_now', 'A_USER', 'B_USER'), ('sign_later', 'B_USER', 'A_USER')], ids=['sign_now', 'sign_later']) def test_send_transaction_from_wallet(self, test, recipient, sender): - home = HomeView(self.driver) - recover_access(home, - transaction_users_wallet[sender]['passphrase'], - transaction_users_wallet[sender]['password'], - transaction_users_wallet[sender]['username']) - chats = home.get_chats() - chats.wait_for_syncing_complete() - + console_view = ConsoleView(self.driver) + user_flow.recover_access(console_view, + transaction_users_wallet[sender]['passphrase'], + transaction_users_wallet[sender]['password'], + transaction_users_wallet[sender]['username']) + chats_view = console_view.get_chat_view() recipient_key = transaction_users_wallet[recipient]['public_key'] recipient_address = transaction_users_wallet[recipient]['address'] - initial_balance_recipient = get_balance(recipient_address) - - chats.plus_button.click() - chats.add_new_contact.click() - chats.public_key_edit_box.send_keys(recipient_key) - chats.confirm() - chats.confirm_public_key_button.click() - + initial_balance_recipient = api_requests.get_balance(recipient_address) + user_flow.add_contact(chats_view, recipient_key) for _ in range(3): - chats.back_button.click() - wallet = chats.wallet_button.click() - wallet.send_button.click() - wallet.amount_edit_box.click() - amount = get_unique_amount() - wallet.send_as_keyevent(amount) - wallet.confirm() - wallet.chose_recipient_button.click() - wallet.deny_button.click() - wallet.chose_from_contacts_button.click() - user_contact = chats.element_by_text(transaction_users_wallet[recipient]['username'], 'button') + try: + chats_view.back_button.click() + except(TimeoutException, NoSuchElementException): + pass + wallet_view = chats_view.wallet_button.click() + wallet_view.send_button.click() + send_transaction = wallet_view.get_send_transaction_view() + send_transaction.amount_edit_box.click() + amount = send_transaction.get_unique_amount() + send_transaction.send_as_keyevent(amount) + send_transaction.confirm() + send_transaction.chose_recipient_button.click() + send_transaction.deny_button.click() + send_transaction.chose_from_contacts_button.click() + user_contact = send_transaction.element_by_text(transaction_users_wallet[recipient]['username'], 'button') user_contact.click() - if test == 'sign_later': - chats.sign_later_button.click() - wallet.yes_button.click() - wallet.ok_button_apk.click() - tr_view = wallet.transactions_button.click() - tr_view.unsigned_tab.click() - tr_view.sign_button.click() - - chats.sign_transaction_button.click() - chats.enter_password_input.send_keys(transaction_users_wallet[sender]['password']) - chats.sign_transaction_button.click() - chats.got_it_button.click() - verify_balance_is_updated(initial_balance_recipient, recipient_address) + send_transaction.sign_later_button.click() + send_transaction.yes_button.click() + send_transaction.ok_button_apk.click() + transactions_view = wallet_view.transactions_button.click() + transactions_view.unsigned_tab.click() + transactions_view.sign_button.click() + send_transaction.sign_transaction_button.click() + send_transaction.enter_password_input.send_keys(transaction_users_wallet[sender]['password']) + send_transaction.sign_transaction_button.click() + send_transaction.got_it_button.click() + api_requests.verify_balance_is_updated(initial_balance_recipient, recipient_address) if test == 'sign_later': - tr_view.history_tab.click() + transactions_view.history_tab.click() else: - chats.wallet_button.click() - tr_view = wallet.transactions_button.click() - transaction = tr_view.transactions_table.find_transaction(amount=amount) + chats_view.wallet_button.click() + transactions_view = wallet_view.transactions_button.click() + transaction = transactions_view.transactions_table.find_transaction(amount=amount) details_view = transaction.click() transaction_hash = details_view.get_transaction_hash() - verify_transaction_in_ropsten(address=transaction_users_wallet[sender]['address'], - transaction_hash=transaction_hash) + api_requests.find_transaction_on_ropsten(address=transaction_users_wallet[sender]['address'], + transaction_hash=transaction_hash) @pytest.mark.wallet def test_eth_and_currency_balance(self): errors = list() - home = HomeView(self.driver) - recover_access(home, - passphrase=transaction_users_wallet['A_USER']['passphrase'], - password=transaction_users_wallet['A_USER']['password'], - username=transaction_users_wallet['A_USER']['username']) - chats = home.get_chats() + console = ConsoleView(self.driver) + user_flow.recover_access(console, + passphrase=transaction_users_wallet['A_USER']['passphrase'], + password=transaction_users_wallet['A_USER']['password'], + username=transaction_users_wallet['A_USER']['username']) + chats_view = console.get_chat_view() + wallet = chats_view.wallet_button.click() address = transaction_users_wallet['A_USER']['address'] - balance = get_balance(address) / 1000000000000000000 - wallet = chats.wallet_button.click() - eth_rate = get_ethereum_price_in_usd() + balance = api_requests.get_balance(address) / 1000000000000000000 + eth_rate = api_requests.get_ethereum_price_in_usd() wallet_balance = wallet.get_eth_value() if wallet_balance != balance: errors.append('Balance %s is not equal to the expected %s' % (wallet_balance, balance)) diff --git a/test/appium/tests/user_flow.py b/test/appium/tests/user_flow.py new file mode 100644 index 0000000000..bbf3d3db5c --- /dev/null +++ b/test/appium/tests/user_flow.py @@ -0,0 +1,74 @@ +from tests import get_current_time + + +def create_user(console): + console.request_password_icon.click() + console.chat_request_input.send_keys("qwerty1234") + console.confirm() + console.chat_request_input.send_keys("qwerty1234") + console.confirm() + console.find_full_text( + "Here is your signing phrase. You will use it to verify your transactions. Write it down and keep it safe!") + + +def recover_access(console, passphrase, password, username): + recover_access_view = console.recover_button.click() + recover_access_view.passphrase_input.send_keys(passphrase) + recover_access_view.password_input.send_keys(password) + recover_access_view.confirm_recover_access.click() + recovered_user = recover_access_view.element_by_text(username, 'button') + recover_access_view.confirm() + recovered_user.click() + recover_access_view.password_input.send_keys(password) + recover_access_view.sign_in_button.click() + recover_access_view.find_full_text('Chats', 60) + + +def get_public_key(chat): + profile_drawer = chat.profile_button.click() + profile_view = profile_drawer.profile_icon.click() + return profile_view.public_key_text.text + + +def get_address(chat): + profile_drawer = chat.profile_button.click() + profile_view = profile_drawer.profile_icon.click() + return profile_view.profile_address_text.text + + +def add_contact(chat, public_key): + start_new_chat = chat.plus_button.click() + start_new_chat.add_new_contact.click() + start_new_chat.public_key_edit_box.send_keys(public_key) + start_new_chat.confirm() + start_new_chat.confirm_public_key_button.click() + + +def create_group_chat(chat, username_to_add, group_chat_name='new_group_chat'): + start_new_chat = chat.plus_button.click() + start_new_chat.new_group_chat_button.click() + user_contact = start_new_chat.element_by_text(username_to_add, 'button') + user_contact.scroll_to_element() + user_contact.click() + start_new_chat.next_button.click() + start_new_chat.name_edit_box.send_keys(group_chat_name) + start_new_chat.save_button.click() + + +def get_new_username_and_status(*args): + users_details = dict() + for device, view in enumerate(args): + current_time = get_current_time() + new_status = '#newstatus_%s' % current_time + new_username = 'New_User_Name_%s' % current_time + + view.user_status_box.click() + view.user_status_input.clear() + view.user_status_input.send_keys(new_status) + view.username_input.clear() + view.username_input.send_keys(new_username) + view.save_button.click() + users_details[device] = dict() + users_details[device]['status'] = new_status + users_details[device]['name'] = new_username + return users_details diff --git a/test/appium/views/base_element.py b/test/appium/views/base_element.py index 73adcc93fe..c90d0539f8 100644 --- a/test/appium/views/base_element.py +++ b/test/appium/views/base_element.py @@ -37,11 +37,11 @@ class BaseElement(object): return None def find_element(self): - logging.info('Looking for %s' % self.name) + self.info('Looking for %s' % self.name) return self.driver.find_element(self.locator.by, self.locator.value) def find_elements(self): - logging.info('Looking for %s' % self.name) + self.info('Looking for %s' % self.name) return self.driver.find_elements(self.locator.by, self.locator.value) def wait_for_element(self, seconds=10): @@ -54,7 +54,7 @@ class BaseElement(object): try: return self.find_element() except NoSuchElementException: - logging.info('Scrolling to %s' % self.name) + self.info('Scrolling to %s' % self.name) action.press(x=0, y=1000).move_to(x=200, y=-1000).release().perform() def is_element_present(self, sec=5): @@ -68,6 +68,10 @@ class BaseElement(object): def text(self): return self.find_element().text + def info(self, text): + if not "Base" in text: + logging.info(text) + class BaseEditBox(BaseElement): @@ -76,15 +80,15 @@ class BaseEditBox(BaseElement): def send_keys(self, value): self.find_element().send_keys(value) - logging.info('Type %s to %s' % (value, self.name)) + self.info('Type %s to %s' % (value, self.name)) def set_value(self, value): self.find_element().set_value(value) - logging.info('Set %s to %s' % (value, self.name)) + self.info('Type %s to %s' % (value, self.name)) def clear(self): self.find_element().clear() - logging.info('Clear text in %s' % self.name) + self.info('Clear text in %s' % self.name) class BaseText(BaseElement): @@ -95,7 +99,7 @@ class BaseText(BaseElement): @property def text(self): text = self.find_element().text - logging.info('%s is %s' % (self.name, text)) + self.info('%s is %s' % (self.name, text)) return text @@ -106,5 +110,5 @@ class BaseButton(BaseElement): def click(self): self.find_element().click() - logging.info('Tap on %s' % self.name) + self.info('Tap on %s' % self.name) return self.navigate() diff --git a/test/appium/views/base_view.py b/test/appium/views/base_view.py index d5de0fae19..b428a9fbf2 100644 --- a/test/appium/views/base_view.py +++ b/test/appium/views/base_view.py @@ -1,11 +1,9 @@ -from selenium.common.exceptions import NoSuchElementException - -from apis.ropsten_api import get_transactions, is_transaction_successful, get_balance -from views.base_element import BaseElement, BaseButton, BaseEditBox, BaseText import logging import time import pytest -import requests +from views.base_element import * +from tests import api_requests +from datetime import datetime class BackButton(BaseButton): @@ -40,36 +38,6 @@ class DenyButton(BaseButton): self.locator = self.Locator.xpath_selector("//*[@text='Deny']") -class ContactsButton(BaseButton): - def __init__(self, driver): - super(ContactsButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//*[@text='Contacts']") - - def navigate(self): - from views.contacts import ContactsViewObject - return ContactsViewObject(self.driver) - - -class WalletButton(BaseButton): - def __init__(self, driver): - super(WalletButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//*[@text='Wallet']") - - def navigate(self): - from views.wallet import WalletViewObject - return WalletViewObject(self.driver) - - -class DiscoverButton(BaseButton): - def __init__(self, driver): - super(DiscoverButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//*[@text='Discover']") - - def navigate(self): - from views.discover import DiscoverView - return DiscoverView(self.driver) - - class YesButton(BaseButton): def __init__(self, driver): super(YesButton, self).__init__(driver) @@ -82,9 +50,9 @@ class NoButton(BaseButton): self.locator = self.Locator.xpath_selector("//*[@text='No']") -class OkButtonAPK(BaseButton): +class OkButton(BaseButton): def __init__(self, driver): - super(OkButtonAPK, self).__init__(driver) + super(OkButton, self).__init__(driver) self.locator = self.Locator.xpath_selector("//*[@text='OK']") @@ -94,15 +62,40 @@ class ContinueButtonAPK(BaseButton): self.locator = self.Locator.xpath_selector("//*[@text='Continue']") -def verify_transaction_in_ropsten(address: str, transaction_hash: str): - transactions = get_transactions(address=address) - for transaction in transactions: - if transaction['hash'] == transaction_hash: - logging.info('Transaction is found in Ropsten network') - if not is_transaction_successful(transaction_hash=transaction_hash): - pytest.fail('Transaction is not successful') - return - pytest.fail('Transaction was not found via Ropsten API') +class ContactsButton(BaseButton): + def __init__(self, driver): + super(ContactsButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Contacts']/..") + + def navigate(self): + from views.contacts_view import ContactsView + return ContactsView(self.driver) + + +class WalletButton(BaseButton): + def __init__(self, driver): + super(WalletButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Wallet']/..") + + def navigate(self): + from views.wallet_view import WalletView + return WalletView(self.driver) + + +class DiscoverButton(BaseButton): + def __init__(self, driver): + super(DiscoverButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Discover']/..") + + def navigate(self): + from views.discover_view import DiscoverView + return DiscoverView(self.driver) + + +class ChatsButton(BaseButton): + def __init__(self, driver): + super(ChatsButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Chats']/..") class SaveButton(BaseButton): @@ -112,6 +105,13 @@ class SaveButton(BaseButton): "//android.widget.TextView[@text='SAVE']") +class NextButton(BaseButton): + def __init__(self, driver): + super(NextButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector( + "//android.widget.TextView[@text='NEXT']") + + class ChatRequestInput(BaseEditBox): def __init__(self, driver): @@ -133,14 +133,7 @@ class StatusAppIcon(BaseButton): "//*[@text='Status']") -class ChatsButton(BaseButton): - def __init__(self, driver): - super(ChatsButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector( - "//*[@text='Chats']") - - -class BaseViewObject(object): +class BaseView(object): def __init__(self, driver): self.driver = driver @@ -150,7 +143,8 @@ class BaseViewObject(object): self.allow_button = AllowButton(self.driver) self.deny_button = DenyButton(self.driver) self.continue_button_apk = ContinueButtonAPK(self.driver) - self.ok_button_apk = OkButtonAPK(self.driver) + self.ok_button_apk = OkButton(self.driver) + self.next_button = NextButton(self.driver) self.apps_button = AppsButton(self.driver) self.status_app_icon = StatusAppIcon(self.driver) @@ -163,6 +157,13 @@ class BaseViewObject(object): self.chat_request_input = ChatRequestInput(self.driver) + self.element_types = { + 'base': BaseElement, + 'button': BaseButton, + 'edit_box': BaseEditBox, + 'text': BaseText + } + @property def logcat(self): return self.driver.get_log("logcat") @@ -198,51 +199,28 @@ class BaseViewObject(object): return element.wait_for_element(wait_time) def element_by_text(self, text, element_type='base'): - - element_types = { - 'base': BaseElement, - 'button': BaseButton, - 'edit_box': BaseEditBox, - 'text': BaseText - } - - element = element_types[element_type](self.driver) + logging.info("Looking for an element by text: '%s'" % text) + element = self.element_types[element_type](self.driver) element.locator = element.Locator.xpath_selector('//*[@text="' + text + '"]') return element def element_by_text_part(self, text, element_type='base'): - - element_types = { - 'base': BaseElement, - 'button': BaseButton, - 'edit_box': BaseEditBox, - 'text': BaseText - } - - element = element_types[element_type](self.driver) + logging.info("Looking for an element by text part: '%s'" % text) + element = self.element_types[element_type](self.driver) element.locator = element.Locator.xpath_selector('//*[contains(@text, "' + text + '")]') return element - def get_chats(self): - from views.chats import ChatsViewObject - return ChatsViewObject(self.driver) + def get_chat_view(self): + from views.chat_view import ChatView + return ChatView(self.driver) - def get_login(self): - from views.login import LoginView - return LoginView(self.driver) + def get_sign_in_view(self): + from views.sign_in_view import SignInView + return SignInView(self.driver) - def get_donate(self, address, wait_time=300): - initial_balance = get_balance(address) - counter = 0 - if initial_balance < 1000000000000000000: - response = requests.request('GET', 'http://46.101.129.137:3001/donate/0x%s' % address).json() - while True: - if counter == wait_time: - pytest.fail("Donation was not received during %s seconds!" % wait_time) - elif get_balance(address) == initial_balance: - counter += 10 - time.sleep(10) - logging.info('Waiting %s seconds for donation' % counter) - else: - logging.info('Got %s for %s' % (response["amount"], address)) - break + def get_send_transaction_view(self): + from views.send_transaction_view import SendTransactionView + return SendTransactionView(self.driver) + + def get_unique_amount(self): + return '0.0%s' % datetime.now().strftime('%-m%-d%-H%-M%-S').strip('0') diff --git a/test/appium/views/chat_view.py b/test/appium/views/chat_view.py new file mode 100644 index 0000000000..037a3ca393 --- /dev/null +++ b/test/appium/views/chat_view.py @@ -0,0 +1,137 @@ +from views.base_view import BaseView +from views.base_element import * + + +class ProfileButton(BaseButton): + def __init__(self, driver): + super(ProfileButton, self).__init__(driver) + self.locator = self.Locator.accessibility_id('toolbar-hamburger-menu') + + def navigate(self): + from views.profile_drawer_view import ProfileDrawer + return ProfileDrawer(self.driver) + + +class PlusButton(BaseButton): + def __init__(self, driver): + super(PlusButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector( + "//android.widget.TextView[@text='+']") + + def navigate(self): + from views.start_new_chat_view import StarNewChatView + return StarNewChatView(self.driver) + + +class ConsoleButton(BaseButton): + def __init__(self, driver): + super(ConsoleButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector( + "//*[@text='Console']") + + +class ChatMessageInput(BaseEditBox): + def __init__(self, driver): + super(ChatMessageInput, self).__init__(driver) + self.locator = self.Locator.accessibility_id('chat-message-input') + + +class SendMessageButton(BaseButton): + def __init__(self, driver): + super(SendMessageButton, self).__init__(driver) + self.locator = self.Locator.accessibility_id("send-message-button") + + def click(self): + self.find_element().click() + logging.info('Tap on %s' % self.name) + + +class AddToContacts(BaseButton): + def __init__(self, driver): + super(AddToContacts, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Add to contacts']") + + +class UserNameText(BaseText): + def __init__(self, driver): + super(UserNameText, self).__init__(driver) + self.locator = \ + self.Locator.xpath_selector("//android.widget.ScrollView//android.widget.TextView") + + +class SendCommand(BaseButton): + def __init__(self, driver): + super(SendCommand, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='/send']") + + +class RequestCommand(BaseButton): + def __init__(self, driver): + super(RequestCommand, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='/request']") + + +class GroupChatOptions(BaseButton): + def __init__(self, driver): + super(GroupChatOptions, self).__init__(driver) + self.locator = self.Locator.xpath_selector( + "//android.view.ViewGroup[2]//android.widget.TextView[@text='n']") + + +class ChatSettings(BaseButton): + def __init__(self, driver): + super(ChatSettings, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Settings']") + + +class UserOptions(BaseButton): + def __init__(self, driver): + super(UserOptions, self).__init__(driver) + self.locator = self.Locator.xpath_selector('//android.widget.ImageView[@content-desc="chat-icon"]' + '/../..//android.view.View') + + +class RemoveButton(BaseButton): + def __init__(self, driver): + super(RemoveButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Remove']") + + +class FirstRecipient(BaseButton): + def __init__(self, driver): + super(FirstRecipient, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Choose recipient']/.." + "//android.widget.ImageView[@content-desc='chat-icon']") + + +class ChatView(BaseView): + def __init__(self, driver): + super(ChatView, self).__init__(driver) + + self.profile_button = ProfileButton(self.driver) + self.plus_button = PlusButton(self.driver) + self.console_button = ConsoleButton(self.driver) + + self.chat_message_input = ChatMessageInput(self.driver) + self.send_message_button = SendMessageButton(self.driver) + self.add_to_contacts = AddToContacts(self.driver) + self.user_name_text = UserNameText(self.driver) + + self.send_command = SendCommand(self.driver) + self.request_command = RequestCommand(self.driver) + + self.group_chat_options = GroupChatOptions(self.driver) + self.chat_settings = ChatSettings(self.driver) + self.user_options = UserOptions(self.driver) + self.remove_button = RemoveButton(self.driver) + + self.first_recipient_button = FirstRecipient(self.driver) + + def wait_for_syncing_complete(self): + logging.info('Waiting for syncing complete:') + while True: + try: + sync = self.find_text_part('Syncing', 10) + logging.info(sync.text) + except TimeoutException: + break diff --git a/test/appium/views/chats.py b/test/appium/views/chats.py deleted file mode 100644 index 1441eeca2c..0000000000 --- a/test/appium/views/chats.py +++ /dev/null @@ -1,251 +0,0 @@ -from datetime import datetime - -from views.base_view import BaseViewObject -import time -from views.base_element import * - - -class ProfileButton(BaseButton): - def __init__(self, driver): - super(ProfileButton, self).__init__(driver) - self.locator = self.Locator.accessibility_id('toolbar-hamburger-menu') - - class ProfileIcon(BaseButton): - def __init__(self, driver): - super(ProfileButton.ProfileIcon, self).__init__(driver) - self.locator = self.Locator.accessibility_id('drawer-profile-icon') - - def navigate(self): - from views.profile import ProfileViewObject - return ProfileViewObject(self.driver) - - class SwitchUsersButton(BaseButton): - def __init__(self, driver): - super(ProfileButton.SwitchUsersButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='SWITCH USERS']") - - def click(self): - time.sleep(2) - self.find_element().click() - logging.info('Tap on %s' % self.name) - return self.navigate() - - def navigate(self): - from views.login import LoginView - return LoginView(self.driver) - - -class PlusButton(BaseButton): - def __init__(self, driver): - super(PlusButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector( - "//android.widget.TextView[@text='+']") - - -class ConsoleButton(BaseButton): - def __init__(self, driver): - super(ConsoleButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector( - "//*[@text='Console']") - - -class AddNewContactButton(BaseButton): - def __init__(self, driver): - super(AddNewContactButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector( - "//android.widget.TextView[@text='Add new contact']") - - -class NewContactButton(BaseButton): - def __init__(self, driver): - super(NewContactButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='']") - - -class NewGroupChatButton(BaseButton): - def __init__(self, driver): - super(NewGroupChatButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector( - "//android.widget.TextView[@text='New group chat']") - - class NextButton(BaseButton): - def __init__(self, driver): - super(NewGroupChatButton.NextButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector( - "//android.widget.TextView[@text='NEXT']") - - class NameEditBox(BaseEditBox): - def __init__(self, driver): - super(NewGroupChatButton.NameEditBox, self).__init__(driver) - self.locator = \ - self.Locator.xpath_selector("//android.widget.EditText[@NAF='true']") - - class GroupChatOptions(BaseButton): - def __init__(self, driver): - super(NewGroupChatButton.GroupChatOptions, self).__init__(driver) - self.locator = self.Locator.xpath_selector( - "//android.view.ViewGroup[2]//android.widget.TextView[@text='n']") - - class ChatSettings(BaseButton): - def __init__(self, driver): - super(NewGroupChatButton.ChatSettings, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Settings']") - - class UserOptions(BaseButton): - def __init__(self, driver): - super(NewGroupChatButton.UserOptions, self).__init__(driver) - self.locator = self.Locator.xpath_selector('//android.widget.ImageView[@content-desc="chat-icon"]' - '/../..//android.view.View') - - class RemoveButton(BaseButton): - def __init__(self, driver): - super(NewGroupChatButton.RemoveButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Remove']") - - -class PublicKeyEditBox(BaseEditBox): - def __init__(self, driver): - super(PublicKeyEditBox, self).__init__(driver) - self.locator = \ - self.Locator.xpath_selector("//android.widget.EditText[@NAF='true']") - - -class ConfirmPublicKeyButton(BaseButton): - def __init__(self, driver): - super(ConfirmPublicKeyButton, self).__init__(driver) - self.locator = \ - self.Locator.xpath_selector('(//android.view.ViewGroup[@content-desc="icon"])[2]') - - -class ChatMessageInput(BaseEditBox): - def __init__(self, driver): - super(ChatMessageInput, self).__init__(driver) - self.locator = self.Locator.accessibility_id('chat-message-input') - - -class SendMessageButton(BaseButton): - def __init__(self, driver): - super(SendMessageButton, self).__init__(driver) - self.locator = self.Locator.accessibility_id("send-message-button") - - def click(self): - self.find_element().click() - logging.info('Tap on %s' % self.name) - - -class AddToContacts(BaseButton): - def __init__(self, driver): - super(AddToContacts, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//*[@text='Add to contacts']") - - -class UserNameText(BaseText): - def __init__(self, driver): - super(UserNameText, self).__init__(driver) - self.locator = \ - self.Locator.xpath_selector("//android.widget.ScrollView//android.widget.TextView") - - -class SendFundsButton(BaseButton): - def __init__(self, driver): - super(SendFundsButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//*[@text='/send']") - - class FirstRecipient(BaseButton): - def __init__(self, driver): - super(SendFundsButton.FirstRecipient, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//*[@text='Choose recipient']/.." - "//android.widget.ImageView[@content-desc='chat-icon']") - - class SignTransactionButton(BaseButton): - def __init__(self, driver): - super(SendFundsButton.SignTransactionButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//*[@text='SIGN TRANSACTION']") - - class SignLaterButton(BaseButton): - def __init__(self, driver): - super(SendFundsButton.SignLaterButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//*[@text='SIGN LATER']") - - class PasswordInput(BaseEditBox): - def __init__(self, driver): - super(SendFundsButton.PasswordInput, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//*[@text='Password']") - - class EnterPasswordInput(BaseEditBox): - def __init__(self, driver): - super(SendFundsButton.EnterPasswordInput, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//android.widget.EditText[@NAF='true']") - - class ConfirmButton(BaseButton): - def __init__(self, driver): - super(SendFundsButton.ConfirmButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//*[@text='CONFIRM']") - - class GotItButton(BaseButton): - def __init__(self, driver): - super(SendFundsButton.GotItButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//*[@text='GOT IT']") - - -class RequestFundsButton(BaseButton): - def __init__(self, driver): - super(RequestFundsButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//*[@text='/request']") - - -class ChatsViewObject(BaseViewObject): - def __init__(self, driver): - super(ChatsViewObject, self).__init__(driver) - self.driver = driver - - self.profile_button = ProfileButton(self.driver) - self.profile_icon = ProfileButton.ProfileIcon(self.driver) - self.switch_users_button = ProfileButton.SwitchUsersButton(self.driver) - - self.plus_button = PlusButton(self.driver) - self.add_new_contact = AddNewContactButton(self.driver) - self.console_button = ConsoleButton(self.driver) - - self.public_key_edit_box = PublicKeyEditBox(self.driver) - self.confirm_public_key_button = ConfirmPublicKeyButton(self.driver) - - self.new_group_chat_button = NewGroupChatButton(self.driver) - self.next_button = NewGroupChatButton.NextButton(self.driver) - self.name_edit_box = NewGroupChatButton.NameEditBox(self.driver) - self.group_chat_options = NewGroupChatButton.GroupChatOptions(self.driver) - self.chat_settings = NewGroupChatButton.ChatSettings(self.driver) - self.user_options = NewGroupChatButton.UserOptions(self.driver) - self.remove_button = NewGroupChatButton.RemoveButton(self.driver) - - self.chat_message_input = ChatMessageInput(self.driver) - self.send_message_button = SendMessageButton(self.driver) - self.add_to_contacts = AddToContacts(self.driver) - self.user_name_text = UserNameText(self.driver) - - self.send_funds_button = SendFundsButton(self.driver) - - self.first_recipient_button = SendFundsButton.FirstRecipient(self.driver) - self.sign_transaction_button = SendFundsButton.SignTransactionButton(self.driver) - self.sign_later_button = SendFundsButton.SignLaterButton(self.driver) - self.confirm_button = SendFundsButton.ConfirmButton(self.driver) - self.password_input = SendFundsButton.PasswordInput(self.driver) - self.enter_password_input = SendFundsButton.EnterPasswordInput(self.driver) - self.got_it_button = SendFundsButton.GotItButton(self.driver) - - self.new_contact_button = NewContactButton(self.driver) - - self.request_funds_button = RequestFundsButton(self.driver) - - def wait_for_syncing_complete(self): - logging.info('Waiting for syncing complete:') - while True: - try: - sync = self.find_text_part('Syncing', 10) - logging.info(sync.text) - except TimeoutException: - break - - -def get_unique_amount(): - return '0.0%s' % datetime.now().strftime('%-m%-d%-H%-M%-S').strip('0') diff --git a/test/appium/views/home.py b/test/appium/views/console_view.py similarity index 77% rename from test/appium/views/home.py rename to test/appium/views/console_view.py index 82d516b3e4..ac83aa18bd 100644 --- a/test/appium/views/home.py +++ b/test/appium/views/console_view.py @@ -1,6 +1,7 @@ -from views.base_view import BaseViewObject +from views.base_view import BaseView from views.base_element import * + class RequestPasswordIcon(BaseButton): def __init__(self, driver): @@ -21,18 +22,23 @@ class RecoverButton(BaseButton): self.locator = self.Locator.xpath_selector("//*[@text='Recover']") def navigate(self): - from views.login import LoginView - return LoginView(self.driver) + from views.recover_access_view import RecoverAccessView + return RecoverAccessView(self.driver) -class HomeView(BaseViewObject): +class ConsoleView(BaseView): def __init__(self, driver): - super(HomeView, self).__init__(driver) + super(ConsoleView, self).__init__(driver) + + self.request_password_icon = RequestPasswordIcon(self.driver) + self.recover_button = RecoverButton(self.driver) + + self.accept_agreements() + + def accept_agreements(self): for i in self.ok_button_apk, self.continue_button_apk: try: i.click() except (NoSuchElementException, TimeoutException): pass - self.request_password_icon = RequestPasswordIcon(self.driver) - self.recover_button = RecoverButton(self.driver) diff --git a/test/appium/views/contacts.py b/test/appium/views/contacts.py deleted file mode 100644 index e6cb54f3df..0000000000 --- a/test/appium/views/contacts.py +++ /dev/null @@ -1,24 +0,0 @@ -from views.base_element import BaseElement, BaseButton, BaseEditBox, BaseText -import logging -import time -import pytest - - -class AuctionHouseButton(BaseButton): - - def __init__(self, driver): - super(AuctionHouseButton, self).__init__(driver) - self.locator = self.Locator.xpath_selector( - "(//android.widget.TextView[@text='Auction House'])[1]") - - def navigate(self): - from views.web_views.auction_house import AuctionHouseWebView - return AuctionHouseWebView(self.driver) - - -class ContactsViewObject(object): - - def __init__(self, driver): - self.driver = driver - - self.auction_house_button = AuctionHouseButton(self.driver) diff --git a/test/appium/views/contacts_view.py b/test/appium/views/contacts_view.py new file mode 100644 index 0000000000..05053fd038 --- /dev/null +++ b/test/appium/views/contacts_view.py @@ -0,0 +1,48 @@ +from views.base_element import * +from views.base_view import BaseView + + +class AuctionHouseButton(BaseButton): + + def __init__(self, driver): + super(AuctionHouseButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector( + "(//android.widget.TextView[@text='Auction House'])[1]") + + def navigate(self): + from views.web_views.auction_house import AuctionHouseWebView + return AuctionHouseWebView(self.driver) + + +class PlusButton(BaseButton): + def __init__(self, driver): + super(PlusButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector( + "//android.widget.TextView[@text='+']") + + +class PublicKeyEditBox(BaseEditBox): + def __init__(self, driver): + super(PublicKeyEditBox, self).__init__(driver) + self.locator = \ + self.Locator.xpath_selector("//android.widget.EditText[@NAF='true']") + + +class ConfirmPublicKeyButton(BaseButton): + def __init__(self, driver): + super(ConfirmPublicKeyButton, self).__init__(driver) + self.locator = \ + self.Locator.xpath_selector('(//android.view.ViewGroup[@content-desc="icon"])[2]') + + +class ContactsView(BaseView): + + def __init__(self, driver): + super(ContactsView, self).__init__(driver) + self.driver = driver + + self.plus_button = PlusButton(self.driver) + self.public_key_edit_box = PublicKeyEditBox(self.driver) + self.confirm_public_key_button = ConfirmPublicKeyButton(self.driver) + + self.auction_house_button = AuctionHouseButton(self.driver) diff --git a/test/appium/views/discover.py b/test/appium/views/discover_view.py similarity index 89% rename from test/appium/views/discover.py rename to test/appium/views/discover_view.py index edfc254a19..02f77dcf94 100644 --- a/test/appium/views/discover.py +++ b/test/appium/views/discover_view.py @@ -1,4 +1,4 @@ -from views.base_view import BaseViewObject +from views.base_view import BaseView import time from views.base_element import * @@ -18,7 +18,7 @@ class AllPopular(BaseButton): self.locator = self.Locator.xpath_selector("//*[@text='Popular #hashtags']/..//*[@text='ALL']") -class DiscoverView(BaseViewObject): +class DiscoverView(BaseView): def __init__(self, driver): super(DiscoverView, self).__init__(driver) diff --git a/test/appium/views/profile_drawer_view.py b/test/appium/views/profile_drawer_view.py new file mode 100644 index 0000000000..875c080b05 --- /dev/null +++ b/test/appium/views/profile_drawer_view.py @@ -0,0 +1,36 @@ +from views.base_view import BaseView +from views.base_element import * + + +class ProfileIcon(BaseButton): + def __init__(self, driver): + super(ProfileIcon, self).__init__(driver) + self.locator = self.Locator.accessibility_id('drawer-profile-icon') + + def navigate(self): + from views.profile_view import ProfileView + return ProfileView(self.driver) + + +class SwitchUsersButton(BaseButton): + def __init__(self, driver): + super(SwitchUsersButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='SWITCH USERS']") + + def click(self): + self.find_element().click() + logging.info('Tap on %s' % self.name) + return self.navigate() + + def navigate(self): + from views.sign_in_view import SignInView + return SignInView(self.driver) + + +class ProfileDrawer(BaseView): + def __init__(self, driver): + super(ProfileDrawer, self).__init__(driver) + self.driver = driver + + self.profile_icon = ProfileIcon(self.driver) + self.switch_users_button = SwitchUsersButton(self.driver) diff --git a/test/appium/views/profile.py b/test/appium/views/profile_view.py similarity index 54% rename from test/appium/views/profile.py rename to test/appium/views/profile_view.py index eec49863d4..7f4af6430c 100644 --- a/test/appium/views/profile.py +++ b/test/appium/views/profile_view.py @@ -1,4 +1,4 @@ -from views.base_view import BaseViewObject +from views.base_view import BaseView from views.base_element import * @@ -55,41 +55,10 @@ class NetworkSettingsButton(BaseButton): super(NetworkSettingsButton, self).__init__(driver) self.locator = self.Locator.xpath_selector('//*[@text="Network settings"]') - class Ropsten(BaseButton): - - def __init__(self, driver): - super(NetworkSettingsButton.Ropsten, self).__init__(driver) - self.locator = self.Locator.xpath_selector('//*[@text="Ropsten"]') - - class RopstenWithUpstreamRPC(BaseButton): - - def __init__(self, driver): - super(NetworkSettingsButton.RopstenWithUpstreamRPC, self).__init__(driver) - self.locator = self.Locator.xpath_selector('//*[@text="Ropsten with upstream RPC"]') - - class Rinkeby(BaseButton): - - def __init__(self, driver): - super(NetworkSettingsButton.Rinkeby, self).__init__(driver) - self.locator = self.Locator.xpath_selector('//*[@text="Rinkeby"]') - - class RinkebyWithUpstreamRPC(BaseButton): - - def __init__(self, driver): - super(NetworkSettingsButton.RinkebyWithUpstreamRPC, self).__init__(driver) - self.locator = self.Locator.xpath_selector('//*[@text="Rinkeby with upstream RPC"]') - - class Mainnet(BaseButton): - - def __init__(self, driver): - super(NetworkSettingsButton.Mainnet, self).__init__(driver) - self.locator = self.Locator.xpath_selector('//*[@text="Mainnet"]') - - class MainnetWithUpstreamRPC(BaseButton): - - def __init__(self, driver): - super(NetworkSettingsButton.MainnetWithUpstreamRPC, self).__init__(driver) - self.locator = self.Locator.xpath_selector('//*[@text="Mainnet with upstream RPC"]') + class NetworkButton(BaseButton): + def __init__(self, driver, network): + super(NetworkSettingsButton.NetworkButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector('//*[@text="' + network + '"]') class ConnectButton(BaseButton): @@ -98,10 +67,10 @@ class NetworkSettingsButton(BaseButton): self.locator = self.Locator.xpath_selector('//*[@text="CONNECT"]') -class ProfileViewObject(BaseViewObject): +class ProfileView(BaseView): def __init__(self, driver): - super(ProfileViewObject, self).__init__(driver) + super(ProfileView, self).__init__(driver) self.driver = driver self.options_button = OptionsButton(self.driver) @@ -112,24 +81,13 @@ class ProfileViewObject(BaseViewObject): self.profile_address_text = ProfileAddressText(self.driver) self.network_settings_button = NetworkSettingsButton(self.driver) - self.ropsten = NetworkSettingsButton.Ropsten(self.driver) - self.ropsten_upstream_rpc = NetworkSettingsButton.RopstenWithUpstreamRPC(self.driver) - self.rinkeby = NetworkSettingsButton.Rinkeby(self.driver) - self.rinkeby_upstream_rpc_ = NetworkSettingsButton.RinkebyWithUpstreamRPC(self.driver) - self.mainnet = NetworkSettingsButton.Mainnet(self.driver) - self.mainnet_upstream_rpc = NetworkSettingsButton.MainnetWithUpstreamRPC(self.driver) self.connect_button = NetworkSettingsButton.ConnectButton(self.driver) def switch_network(self, network): self.network_settings_button.scroll_to_element() self.network_settings_button.click() - networks = {'Ropsten': self.ropsten, - 'Ropsten with upstream RPC': self.ropsten_upstream_rpc, - 'Rinkeby': self.rinkeby, - 'Rinkeby with upstream RPC': self.ropsten_upstream_rpc, - 'Mainnet': self.mainnet, - 'Mainnet with upstream RPC': self.mainnet_upstream_rpc} - networks[network].click() + network_button = NetworkSettingsButton.NetworkButton(self.driver, network) + network_button.click() self.connect_button.click() - from views.login import LoginView - return LoginView(self.driver) + from views.sign_in_view import SignInView + return SignInView(self.driver) diff --git a/test/appium/views/recover_access_view.py b/test/appium/views/recover_access_view.py new file mode 100644 index 0000000000..1578ab6906 --- /dev/null +++ b/test/appium/views/recover_access_view.py @@ -0,0 +1,27 @@ +from views.base_view import BaseView +from views.sign_in_view import SignInView +from views.base_element import * + + +class PassphraseInput(BaseEditBox): + + def __init__(self, driver): + super(PassphraseInput, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Passphrase']") + + +class ConfirmRecoverAccess(BaseButton): + + def __init__(self, driver): + super(ConfirmRecoverAccess, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='RECOVER ACCESS']") + + +class RecoverAccessView(SignInView): + + def __init__(self, driver): + super(RecoverAccessView, self).__init__(driver) + self.driver = driver + + self.passphrase_input = PassphraseInput(self.driver) + self.confirm_recover_access = ConfirmRecoverAccess(self.driver) diff --git a/test/appium/views/send_transaction_view.py b/test/appium/views/send_transaction_view.py new file mode 100644 index 0000000000..f38cf7a1fd --- /dev/null +++ b/test/appium/views/send_transaction_view.py @@ -0,0 +1,87 @@ +import time + +import pytest +from selenium.common.exceptions import NoSuchElementException + +from views.base_element import * +from views.base_view import BaseView + + +class FirstRecipient(BaseButton): + def __init__(self, driver): + super(FirstRecipient, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Choose recipient']/.." + "//android.widget.ImageView[@content-desc='chat-icon']") + + +class SignTransactionButton(BaseButton): + def __init__(self, driver): + super(SignTransactionButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='SIGN TRANSACTION']") + + +class SignLaterButton(BaseButton): + def __init__(self, driver): + super(SignLaterButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='SIGN LATER']") + + +class AmountEditBox(BaseEditBox, BaseButton): + + def __init__(self, driver): + super(AmountEditBox, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Amount']/..//android.widget.EditText") + + +class PasswordInput(BaseEditBox): + def __init__(self, driver): + super(PasswordInput, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Password']") + + +class EnterPasswordInput(BaseEditBox): + def __init__(self, driver): + super(EnterPasswordInput, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//android.widget.EditText[@NAF='true']") + + +class ConfirmButton(BaseButton): + def __init__(self, driver): + super(ConfirmButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='CONFIRM']") + + +class GotItButton(BaseButton): + def __init__(self, driver): + super(GotItButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='GOT IT']") + + +class ChooseRecipientButton(BaseButton): + + def __init__(self, driver): + super(ChooseRecipientButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Choose recipient...']") + + +class ChooseFromContactsButton(BaseButton): + def __init__(self, driver): + super(ChooseFromContactsButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Choose From Contacts']") + + +class SendTransactionView(BaseView): + def __init__(self, driver): + super(SendTransactionView, self).__init__(driver) + + self.chose_recipient_button = ChooseRecipientButton(self.driver) + self.chose_from_contacts_button = ChooseFromContactsButton(self.driver) + self.first_recipient_button = FirstRecipient(self.driver) + + self.amount_edit_box = AmountEditBox(self.driver) + self.sign_transaction_button = SignTransactionButton(self.driver) + self.sign_later_button = SignLaterButton(self.driver) + self.confirm_button = ConfirmButton(self.driver) + self.password_input = PasswordInput(self.driver) + self.enter_password_input = EnterPasswordInput(self.driver) + self.got_it_button = GotItButton(self.driver) diff --git a/test/appium/views/login.py b/test/appium/views/sign_in_view.py similarity index 63% rename from test/appium/views/login.py rename to test/appium/views/sign_in_view.py index 42f741abc4..9faa8c50ec 100644 --- a/test/appium/views/login.py +++ b/test/appium/views/sign_in_view.py @@ -1,4 +1,4 @@ -from views.base_view import BaseViewObject +from views.base_view import BaseView import pytest from views.base_element import * @@ -30,31 +30,18 @@ class RecoverAccessButton(BaseButton): super(RecoverAccessButton, self).__init__(driver) self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Recover access']") + def navigate(self): + from views.recover_access_view import RecoverAccessView + return RecoverAccessView(self.driver) -class PassphraseInput(BaseEditBox): + +class SignInView(BaseView): def __init__(self, driver): - super(PassphraseInput, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Passphrase']") - - -class ConfirmRecoverAccess(BaseButton): - - def __init__(self, driver): - super(ConfirmRecoverAccess, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='RECOVER ACCESS']") - - -class LoginView(BaseViewObject): - - def __init__(self, driver): - super(LoginView, self).__init__(driver) + super(SignInView, self).__init__(driver) self.driver = driver self.first_account_button = FirstAccountButton(self.driver) self.password_input = PasswordInput(self.driver) self.sign_in_button = SignInButton(self.driver) - self.recover_access_button = RecoverAccessButton(self.driver) - self.passphrase_input = PassphraseInput(self.driver) - self.confirm_recover_access = ConfirmRecoverAccess(self.driver) diff --git a/test/appium/views/start_new_chat_view.py b/test/appium/views/start_new_chat_view.py new file mode 100644 index 0000000000..2244740ea1 --- /dev/null +++ b/test/appium/views/start_new_chat_view.py @@ -0,0 +1,35 @@ +from views.base_element import * +from views.base_view import BaseView +from views.contacts_view import ContactsView + + +class AddNewContactButton(BaseButton): + def __init__(self, driver): + super(AddNewContactButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector( + "//android.widget.TextView[@text='Add new contact']") + + +class NewGroupChatButton(BaseButton): + + def __init__(self, driver): + super(NewGroupChatButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector( + "//android.widget.TextView[@text='New group chat']") + + +class NameEditBox(BaseEditBox): + def __init__(self, driver): + super(NameEditBox, self).__init__(driver) + self.locator = \ + self.Locator.xpath_selector("//android.widget.EditText[@NAF='true']") + + +class StarNewChatView(ContactsView): + def __init__(self, driver): + super(StarNewChatView, self).__init__(driver) + + self.add_new_contact = AddNewContactButton(self.driver) + self.new_group_chat_button = NewGroupChatButton(self.driver) + + self.name_edit_box = NameEditBox(self.driver) diff --git a/test/appium/views/transactions.py b/test/appium/views/transactions_view.py similarity index 88% rename from test/appium/views/transactions.py rename to test/appium/views/transactions_view.py index 55fe13348c..b7d839295a 100644 --- a/test/appium/views/transactions.py +++ b/test/appium/views/transactions_view.py @@ -4,7 +4,7 @@ import pytest from selenium.common.exceptions import NoSuchElementException from views.base_element import BaseElement, BaseButton, BaseText -from views.base_view import BaseViewObject +from views.base_view import BaseView class TransactionTable(BaseElement): @@ -20,15 +20,15 @@ class TransactionTable(BaseElement): self.locator = self.Locator.xpath_selector( "(//android.widget.TextView[contains(@text,'%s ETH')])" % amount) - class TransactionDetailsViewObject(BaseViewObject): + class TransactionDetailsView(BaseView): def __init__(self, driver): - super(TransactionTable.TransactionElement.TransactionDetailsViewObject, self).__init__(driver) + super(TransactionTable.TransactionElement.TransactionDetailsView, self).__init__(driver) self.driver = driver self.locators = dict(transaction_hash="//android.widget.TextView[@text='Hash']/following-sibling::*[1]") class DetailsTextElement(BaseText): def __init__(self, driver, locator): - super(TransactionTable.TransactionElement.TransactionDetailsViewObject.DetailsTextElement, + super(TransactionTable.TransactionElement.TransactionDetailsView.DetailsTextElement, self).__init__(driver) self.locator = self.Locator.xpath_selector(locator) @@ -36,7 +36,7 @@ class TransactionTable(BaseElement): return self.DetailsTextElement(driver=self.driver, locator=self.locators['transaction_hash']).text def navigate(self): - return self.TransactionDetailsViewObject(self.driver) + return self.TransactionDetailsView(self.driver) def get_transaction_element(self, amount: str): return self.TransactionElement(self.driver, amount=amount) @@ -70,9 +70,9 @@ class UnsignedTab(BaseButton): self.locator = self.Locator.xpath_selector("//*[@text='SIGN']") -class TransactionsViewObject(BaseViewObject): +class TransactionsView(BaseView): def __init__(self, driver): - super(TransactionsViewObject, self).__init__(driver) + super(TransactionsView, self).__init__(driver) self.driver = driver self.history_tab = HistoryTab(self.driver) self.unsigned_tab = UnsignedTab(self.driver) diff --git a/test/appium/views/wallet.py b/test/appium/views/wallet_view.py similarity index 80% rename from test/appium/views/wallet.py rename to test/appium/views/wallet_view.py index 947656c9f4..504ae6767a 100644 --- a/test/appium/views/wallet.py +++ b/test/appium/views/wallet_view.py @@ -1,6 +1,6 @@ import logging -from views.base_view import BaseViewObject +from views.base_view import BaseView from views.base_element import BaseButton, BaseEditBox, BaseText @@ -17,6 +17,9 @@ class RequestButton(BaseButton): super(RequestButton, self).__init__(driver) self.locator = self.Locator.xpath_selector("//*[@text='REQUEST']") + def navigate(self): + pass + class SendRequestButton(BaseButton): @@ -25,13 +28,6 @@ class SendRequestButton(BaseButton): self.locator = self.Locator.xpath_selector("//*[@text='SEND REQUEST']") -class AmountEditBox(BaseEditBox, BaseButton): - - def __init__(self, driver): - super(AmountEditBox, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//*[@text='Amount']/..//android.widget.EditText") - - class ChooseRecipientButton(BaseButton): def __init__(self, driver): @@ -46,8 +42,8 @@ class TransactionsButton(BaseButton): self.locator = self.Locator.xpath_selector('(//android.view.ViewGroup[@content-desc="icon"])[4]') def navigate(self): - from views.transactions import TransactionsViewObject - return TransactionsViewObject(self.driver) + from views.transactions_view import TransactionsView + return TransactionsView(self.driver) class ChooseFromContactsButton(BaseButton): @@ -68,19 +64,17 @@ class UsdTotalValueText(BaseText): self.locator = self.Locator.xpath_selector("//*[@text='USD']/../android.widget.TextView[1]") -class WalletViewObject(BaseViewObject): +class WalletView(BaseView): def __init__(self, driver): - super(WalletViewObject, self).__init__(driver) + super(WalletView, self).__init__(driver) self.driver = driver self.send_button = SendButton(self.driver) - self.amount_edit_box = AmountEditBox(self.driver) - self.chose_recipient_button = ChooseRecipientButton(self.driver) - self.chose_from_contacts_button = ChooseFromContactsButton(self.driver) self.transactions_button = TransactionsButton(self.driver) self.eth_asset = EthAssetText(self.driver) self.usd_total_value = UsdTotalValueText(self.driver) self.request_button = RequestButton(self.driver) + self.send_request_button = SendRequestButton(self.driver) def get_usd_total_value(self): diff --git a/test/appium/views/web_views/auction_house.py b/test/appium/views/web_views/auction_house.py index ae3d98e0e5..00ca38a3ab 100644 --- a/test/appium/views/web_views/auction_house.py +++ b/test/appium/views/web_views/auction_house.py @@ -29,7 +29,7 @@ class ReserveAssetName(BaseElement): self.locator = self.Locator.accessibility_id('Register Name') -class AuctionHouseWebView(BaseWebViewObject): +class AuctionHouseWebView(BaseWebView): def __init__(self, driver): super(AuctionHouseWebView, self).__init__(driver) diff --git a/test/appium/views/web_views/base_web_view.py b/test/appium/views/web_views/base_web_view.py index 7925b7304f..248610ba42 100644 --- a/test/appium/views/web_views/base_web_view.py +++ b/test/appium/views/web_views/base_web_view.py @@ -8,10 +8,10 @@ class ProgressBarIcon(BaseElement): self.locator = self.Locator.xpath_selector("//android.widget.ProgressBar") -class BaseWebViewObject(BaseViewObject): +class BaseWebView(BaseView): def __init__(self, driver): - super(BaseWebViewObject, self).__init__(driver) + super(BaseWebView, self).__init__(driver) self.driver = driver self.progress_bar_icon = ProgressBarIcon(self.driver)