Added tests for multiaccount

Signed-off-by: Churikova Tetiana <churikova.tm@gmail.com>
This commit is contained in:
yevh-berdnyk 2019-08-16 13:14:23 +03:00 committed by Churikova Tetiana
parent d2a9cb355a
commit 5db9080990
No known key found for this signature in database
GPG Key ID: 0D4EA7B33B47E6D8
6 changed files with 202 additions and 21 deletions

View File

@ -1,6 +1,8 @@
import pytest
import random
import string
from tests import marks, camera_access_error_text
from tests import marks, camera_access_error_text, common_password
from tests.base_test_case import SingleDeviceTestCase
from tests.users import wallet_users, transaction_senders, basic_user
from views.sign_in_view import SignInView
@ -256,3 +258,33 @@ class TestWalletManagement(SingleDeviceTestCase):
if not token_element.is_element_displayed():
self.errors.append('Custom token is not shown on Send Transaction view')
self.verify_no_errors()
@marks.testrail_id(6224)
@marks.critical
def test_add_account_to_multiaccount_instance(self):
sign_in_view = SignInView(self.driver)
sign_in_view.create_user()
wallet_view = sign_in_view.wallet_button.click()
wallet_view.set_up_wallet()
wallet_view.add_account_button.click()
wallet_view.add_an_account_button.click()
wallet_view.generate_new_account_button.click()
wallet_view.generate_account_button.click()
if wallet_view.element_by_text('Account added').is_element_displayed():
self.driver.fail('Account is added without password')
wallet_view.enter_your_password_input.send_keys('000000')
wallet_view.generate_account_button.click()
if not wallet_view.element_by_text_part('Password seems to be incorrect').is_element_displayed():
self.driver.fail("Incorrect password validation is not performed")
wallet_view.enter_your_password_input.clear()
wallet_view.enter_your_password_input.send_keys(common_password)
wallet_view.generate_account_button.click()
account_name = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
wallet_view.account_name_input.send_keys(account_name)
wallet_view.account_color_button.select_color_by_position(1)
wallet_view.finish_button.click()
account_button = wallet_view.get_account_by_name(account_name)
if not account_button.is_element_displayed():
self.driver.fail('Account was not added')
if not account_button.color_matches('multi_account_color.png'):
self.driver.fail('Account color does not match expected')

View File

@ -2,6 +2,7 @@ import time
import emoji
import random
from dateutil import parser
from selenium.common.exceptions import TimeoutException
from support.utilities import generate_timestamp
from tests import marks
@ -223,8 +224,9 @@ class TestPublicChatSingleDevice(SingleDeviceTestCase):
@marks.high
def test_fetch_more_history_in_empty_chat(self):
signin = SignInView(self.driver)
yesterday = (datetime.today() - timedelta(days=1)).strftime("%b %-d, %Y")
before_yesterday = (datetime.today() - timedelta(days=2)).strftime("%b %-d, %Y")
device_time = parser.parse(signin.driver.device_time)
yesterday = (device_time - timedelta(days=1)).strftime("%b %-d, %Y")
before_yesterday = (device_time - timedelta(days=2)).strftime("%b %-d, %Y")
quiet_time_yesterday, quiet_time_before_yesterday = '24 hours', '2 days'
home_view = signin.create_user()
chat = home_view.join_public_chat('montagne-angerufen-two')

View File

@ -410,16 +410,73 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
self.verify_no_errors()
@marks.testrail_id(5429)
@marks.medium
def test_set_currency(self):
sign_in_view = SignInView(self.driver)
user_currency = 'Euro (EUR)'
sign_in_view.create_user()
wallet_view = sign_in_view.wallet_button.click()
wallet_view.set_currency(user_currency)
if not wallet_view.find_text_part('EUR'):
pytest.fail('EUR currency is not displayed')
@marks.testrail_id(5429)
@marks.medium
def test_set_currency(self):
sign_in_view = SignInView(self.driver)
user_currency = 'Euro (EUR)'
sign_in_view.create_user()
wallet_view = sign_in_view.wallet_button.click()
wallet_view.set_currency(user_currency)
if not wallet_view.find_text_part('EUR'):
self.driver.fail('EUR currency is not displayed')
@marks.testrail_id(6225)
@marks.high
def test_send_funds_between_accounts_in_multiaccount_instance(self):
sign_in_view = SignInView(self.driver)
sign_in_view.create_user()
wallet_view = sign_in_view.wallet_button.click()
wallet_view.set_up_wallet()
address = wallet_view.get_wallet_address()[2:]
wallet_view.back_button.click()
self.network_api.get_donate(address)
account_name = 'test account'
wallet_view.add_account(account_name)
wallet_view.accounts_status_account.click()
send_transaction = wallet_view.send_transaction_button.click()
send_transaction.amount_edit_box.click()
transaction_amount = send_transaction.get_unique_amount()
send_transaction.amount_edit_box.set_value(transaction_amount)
send_transaction.confirm()
send_transaction.chose_recipient_button.click()
send_transaction.accounts_button.click()
send_transaction.element_by_text(account_name).click()
send_transaction.sign_transaction_button.click()
send_transaction.sign_transaction()
self.network_api.wait_for_confirmation_of_transaction(address, transaction_amount)
self.network_api.verify_balance_is_updated('0.1', address)
wallet_view.back_button.click()
wallet_view.get_account_by_name(account_name).click()
wallet_view.send_transaction_button.click()
wallet_view.back_button.click()
balance_after_receiving_tx = wallet_view.eth_asset_value.text
if balance_after_receiving_tx != transaction_amount:
self.driver.fail('New account balance %s does not match expected %s after receiving a transaction' % (
balance_after_receiving_tx, transaction_amount))
updated_balance = self.network_api.get_balance(address)
wallet_view.send_transaction_button.click()
send_transaction.amount_edit_box.click()
transaction_amount_1 = round(float(transaction_amount) * 0.7, 11)
send_transaction.amount_edit_box.set_value(str(transaction_amount_1))
send_transaction.confirm()
send_transaction.chose_recipient_button.click()
send_transaction.accounts_button.click()
send_transaction.element_by_text('Status account').click()
send_transaction.sign_transaction_button.click()
total_fee = send_transaction.get_transaction_fee_total()
send_transaction.sign_transaction()
if not wallet_view.element_by_text('Transaction sent').is_element_displayed():
self.driver.fail('Transaction was not sent from the new account')
self.network_api.wait_for_confirmation_of_transaction(address, transaction_amount)
self.network_api.verify_balance_is_updated(updated_balance, address)
balance_after_sending_tx = wallet_view.eth_asset_value.text
expected_balance = str(float(balance_after_receiving_tx) - transaction_amount_1 - float(total_fee))
if balance_after_sending_tx != expected_balance:
self.driver.fail('New account balance %s does not match expected %s after sending a transaction' % (
balance_after_sending_tx, transaction_amount))
@marks.transaction
@ -461,4 +518,3 @@ class TestTransactionWalletMultipleDevice(MultipleDeviceTestCase):
if not chat_2.chat_element_by_text(amount).is_element_displayed():
self.errors.append('Transaction message is not shown in 1-1 chat for the recipient')
self.verify_no_errors()

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -60,6 +60,12 @@ class ChooseRecipientButton(BaseButton):
self.locator = self.Locator.accessibility_id('choose-recipient-button')
class AccountsButton(BaseButton):
def __init__(self, driver):
super(AccountsButton, self).__init__(driver)
self.locator = self.Locator.text_selector('Accounts')
class EnterRecipientAddressButton(BaseButton):
def __init__(self, driver):
super(EnterRecipientAddressButton, self).__init__(driver)
@ -190,6 +196,7 @@ class SendTransactionView(BaseView):
super(SendTransactionView, self).__init__(driver)
self.chose_recipient_button = ChooseRecipientButton(self.driver)
self.accounts_button = AccountsButton(self.driver)
self.enter_recipient_address_button = EnterRecipientAddressButton(self.driver)
self.scan_qr_code_button = ScanQRCodeButton(self.driver)
self.enter_recipient_address_input = EnterRecipientAddressInput(self.driver)

View File

@ -1,7 +1,8 @@
import time
from tests import common_password
from views.base_element import BaseButton, BaseText, BaseEditBox
from views.base_view import BaseView
from views.base_element import BaseButton, BaseText
from selenium.common.exceptions import NoSuchElementException
class SendRequestButton(BaseButton):
@ -192,10 +193,16 @@ class MultiaccountMoreOptions(BaseButton):
self.locator = self.Locator.accessibility_id('accounts-more-options')
class AccountsStatusAccount(BaseButton):
def __init__(self, driver):
super(AccountsStatusAccount, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//android.widget.HorizontalScrollView//*[@text='Status account']")
class AccountElementButton(BaseButton):
def __init__(self, driver, account_name):
super(AccountElementButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector(
"//android.widget.HorizontalScrollView//*[@text='%s']/.." % account_name)
def color_matches(self, expected_color_image_name: str):
amount_text = BaseText(self.driver)
amount_text.locator = amount_text.Locator.xpath_selector(self.locator.value + "//*[@text='0 USD']")
return amount_text.is_element_image_equals_template(expected_color_image_name)
class SendTransactionButton(BaseButton):
@ -230,6 +237,62 @@ class AddCustomTokenButton(BaseButton):
return AddCustomTokenView(self.driver)
class AddAccountButton(BaseButton):
def __init__(self, driver):
super(AddAccountButton, self).__init__(driver)
self.locator = self.Locator.text_selector('Add account')
class AddAnAccountButton(BaseButton):
def __init__(self, driver):
super(AddAnAccountButton, self).__init__(driver)
self.locator = self.Locator.text_selector('Add an account')
class GenerateNewAccountButton(BaseButton):
def __init__(self, driver):
super(GenerateNewAccountButton, self).__init__(driver)
self.locator = self.Locator.text_selector('Generate a new account')
class EnterYourPasswordInput(BaseEditBox):
def __init__(self, driver):
super(EnterYourPasswordInput, self).__init__(driver)
self.locator = self.Locator.xpath_selector(
"//android.widget.TextView[@text='Enter your password']/following-sibling::android.widget.EditText")
class GenerateAccountButton(BaseButton):
def __init__(self, driver):
super(GenerateAccountButton, self).__init__(driver)
self.locator = self.Locator.text_selector('Generate account')
class AccountNameInput(BaseEditBox):
def __init__(self, driver):
super(AccountNameInput, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Account name']"
"/following-sibling::android.view.ViewGroup/android.widget.EditText")
class AccountColorButton(BaseButton):
def __init__(self, driver):
super(AccountColorButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Account color']"
"/following-sibling::android.view.ViewGroup")
def select_color_by_position(self, position: int):
self.click()
self.driver.find_element_by_xpath(
"//*[@text='Cancel']/../preceding-sibling::android.widget.ScrollView/*/*[%s]" % position).click()
class FinishButton(BaseButton):
def __init__(self, driver):
super(FinishButton, self).__init__(driver)
self.locator = self.Locator.text_selector('Finish')
class WalletView(BaseView):
def __init__(self, driver):
super(WalletView, self).__init__(driver)
@ -265,9 +328,17 @@ class WalletView(BaseView):
# elements for multiaccount
self.multiaccount_more_options = MultiaccountMoreOptions(self.driver)
self.accounts_status_account = AccountsStatusAccount(self.driver)
self.accounts_status_account = AccountElementButton(self.driver, 'Status account')
self.collectibles_button = CollectiblesButton(self.driver)
self.set_currency_button = SetCurrencyButton(self.driver)
self.add_account_button = AddAccountButton(self.driver)
self.add_an_account_button = AddAnAccountButton(self.driver)
self.generate_new_account_button = GenerateNewAccountButton(self.driver)
self.enter_your_password_input = EnterYourPasswordInput(self.driver)
self.generate_account_button = GenerateAccountButton(self.driver)
self.account_name_input = AccountNameInput(self.driver)
self.account_color_button = AccountColorButton(self.driver)
self.finish_button = FinishButton(self.driver)
def get_usd_total_value(self):
import re
@ -402,3 +473,16 @@ class WalletView(BaseView):
desired_currency = self.element_by_text_part(desired_currency)
desired_currency.scroll_to_element()
desired_currency.click()
def get_account_by_name(self, account_name: str):
return AccountElementButton(self.driver, account_name)
def add_account(self, account_name: str, password: str = common_password):
self.add_account_button.click()
self.add_an_account_button.click()
self.generate_new_account_button.click()
self.generate_account_button.click()
self.enter_your_password_input.send_keys(password)
self.generate_account_button.click()
self.account_name_input.send_keys(account_name)
self.finish_button.click()