Automated tests aligned with new design

This commit is contained in:
yevh-berdnyk 2018-01-14 19:43:36 +02:00 committed by Goran Jovic
parent ef57a5ca35
commit cbb77b5f8d
No known key found for this signature in database
GPG Key ID: A778DE3CD7D2D10D
19 changed files with 338 additions and 328 deletions

View File

@ -1,7 +1,7 @@
aiohttp==2.2.3
allpairspy==2.3.0
apipkg==1.4
Appium-Python-Client==0.24
Appium-Python-Client==0.26
async-timeout==1.2.1
asyncio==3.4.3
certifi==2017.7.27.1
@ -17,7 +17,7 @@ pytest-forked==0.2
pytest-xdist==1.20.0
requests==2.18.3
sauceclient==1.0.0
selenium==2.53.6
selenium==3.8.1
six==1.10.0
urllib3==1.22
yarl==0.12.0

View File

@ -9,72 +9,64 @@ from views.console_view import ConsoleView
@pytest.mark.all
class TestMultipleDevices(MultipleDeviceTestCase):
@pytest.mark.skip('Discover functionality is not available')
@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)
for profile in device_1, device_2:
user_flow.create_user(profile)
profile.back_button.click()
device_1_home, device_2_home = device_1.get_home_view(), device_2.get_home_view()
device_2_public_key = user_flow.get_public_key(device_2_home)
user_flow.add_contact(device_1_home, device_2_public_key)
device_1_chat = device_1_home.get_chat_view()
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_home.element_by_text('test123', 'button').click()
device_2_chat = device_2_home.get_chat_view()
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'] + ' ')
device_1_profile, device_2_profile = device_1_chat.profile_button.click(), device_2_chat.profile_button.click()
for profile in device_1_profile, device_2_profile:
user_details = user_flow.get_new_username_and_status(profile)
profile.back_button.click()
discover = profile.discover_button.click()
discover.all_popular.click()
discover.find_full_text(user_details['name'])
discover.find_full_text(' %s' % user_details['status'])
discover.back_button.click()
discover.all_recent.click()
discover.find_full_text(user_details['name'])
discover.find_full_text('%s ' % user_details['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)
device.back_button.click()
device_1_home, device_2_home = device_1.get_home_view(), device_2.get_home_view()
device_1_public_key = user_flow.get_public_key(device_1_home)
user_flow.add_contact(device_2_home, device_1_public_key)
device_2_chat = device_2_home.get_chat_view()
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)
message_2 = 'another SOMETHING'
device_1_home.home_button.click()
device_1_home.find_full_text(message_1)
device_1_home.element_by_text(message_1, 'button').click()
device_1_chat = device_1_home.get_chat_view()
device_1_chat.chat_message_input.send_keys(message_2)
device_1_chat.send_message_button.click()
device_2_chat.find_full_text(message_2)
@pytest.mark.chat
def test_group_chat_send_receive_messages_and_remove_user(self):
@ -82,32 +74,30 @@ class TestMultipleDevices(MultipleDeviceTestCase):
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.back_button.click()
device_1_home = device_1.get_home_view()
device_2_home = device_2.get_home_view()
device_1_public_key = user_flow.get_public_key(device_1_home)
user_flow.add_contact(device_2_home, device_1_public_key)
device_2_chat = device_2_home.get_chat_view()
device_1_user_name = device_2_chat.user_name_text.text
for _ in range(3):
device_2.back_button.click()
device_2_home.back_button.click(times_to_click=3)
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)
user_flow.create_group_chat(device_2_home, 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)
device_1.home_button.click()
device_1_home.find_full_text(message_1)
device_1_home.element_by_text(chat_name, 'button').click()
group_chat_d1 = device_1_home.get_chat_view()
group_chat_d1.chat_message_input.send_keys(message_2)
group_chat_d1.send_message_button.click()
device_2_chat.find_full_text(message_2)
# remove user
device_2_chat.group_chat_options.click()
@ -124,9 +114,8 @@ class TestMultipleDevices(MultipleDeviceTestCase):
# 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):
group_chat_d1.find_text_part("removed you from group chat")
if group_chat_d1.element_by_text(message_3, 'text').is_element_present(20):
pytest.fail('Message is shown for the user which has been removed from the GroupChat', False)
@pytest.mark.transaction
@ -146,18 +135,20 @@ class TestMultipleDevices(MultipleDeviceTestCase):
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()
device_2_home = device_2.get_home_view()
device_1_home = device_1.get_home_view()
user_flow.add_contact(device_1_home, sender['public_key'])
device_1_home.back_button.click(times_to_click=3)
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()
user_flow.create_group_chat(device_1_home, sender['username'], group_chat_name)
device_2_home.element_by_text(group_chat_name, 'button').click()
else:
device_1_chat.element_by_text_part(sender['username'][:25], 'button').click()
one_to_one_chat_device_1 = device_1_home.element_by_text_part(sender['username'][:25], 'button')
one_to_one_chat_device_1.scroll_to_element()
one_to_one_chat_device_1.click()
device_1_chat = device_1_home.get_chat_view()
device_2_chat = device_2_home.get_chat_view()
device_1_chat.request_command.click()
amount = device_1_chat.get_unique_amount()
if test == 'group_chat':
@ -165,12 +156,13 @@ class TestMultipleDevices(MultipleDeviceTestCase):
device_1_chat.send_as_keyevent(amount)
else:
device_1_chat.chat_message_input.set_value(amount)
one_to_one_chat_device_2 = device_2_chat.element_by_text_part(recipient['username'][:25], 'button')
one_to_one_chat_device_2.click()
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()
@ -180,7 +172,7 @@ class TestMultipleDevices(MultipleDeviceTestCase):
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()
device_2_wallet = device_2_home.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()

View File

@ -12,22 +12,18 @@ class TestNetwork(SingleDeviceTestCase):
@pytest.mark.parametrize("network", ['Ropsten', 'Rinkeby', 'Rinkeby with upstream RPC',
'Mainnet', 'Mainnet with upstream RPC'])
def test_network_switch(self, network):
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()
profile_view = console.profile_button.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)
sign_in_view.find_full_text('Wallet', 20)
class TestNetworkChats(MultipleDeviceTestCase):
network_combinations = list(combinations_with_replacement(
['Ropsten', 'Rinkeby', 'Mainnet',
'Rinkeby with upstream RPC', 'Mainnet with upstream RPC', 'Rinkeby with upstream RPC'], 2))
@ -40,47 +36,43 @@ class TestNetworkChats(MultipleDeviceTestCase):
for device in device_1, device_2:
user_flow.create_user(device)
device_1.back_button.click()
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_profile_view = device_1.profile_button.click()
device_1_public_key = device_1_profile_view.public_key_text.text
if network[0] != 'Ropsten with upstream RPC':
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)
login_d1.find_full_text('Wallet', 60)
else:
device_1_profile_view.back_button.click()
device_2.back_button.click()
device_2_chats = device_2.get_chat_view()
device_2_home_view = device_2.get_home_view()
if network[1] != 'Ropsten with upstream RPC':
device_2_profile_drawer = device_2_chats.profile_button.click()
device_2_profile_view = device_2_profile_drawer.profile_icon.click()
device_2_profile_view = device_2.profile_button.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 )
device_2_home_view = device_2_sign_in.sign_in_button.click()
device_2_home_view.find_full_text('Wallet', 60)
user_flow.add_contact(device_2_home_view, device_1_public_key)
device_2_chat = device_2.get_chat_view()
message_1 = network[0]
message_2 = network[1]
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()
device_2_chat.chat_message_input.send_keys(message_2)
device_2_chat.send_message_button.click()
errors = list()
try:
device_1_chats.find_full_text(message_2)
device_1.find_full_text(message_2)
except TimeoutException:
errors.append("Message '%s' wasn't received by Device #1")
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 = device_2_chats.element_by_text(user_d1_name, 'button')
one_to_one_chat_d2.click()
device_1_chats.chat_message_input.send_keys(message_1)
device_1_chats.send_message_button.click()
device_1.element_by_text(message_2, 'button').click()
device_1_chat = device_1.get_chat_view()
device_1_chat.chat_message_input.send_keys(message_1)
device_1_chat.send_message_button.click()
try:
device_2_chats.find_full_text(message_1)
device_2_chat.find_full_text(message_1)
except TimeoutException:
errors.append("Message '%s' wasn't received by Device #2")
if errors:

View File

@ -1,5 +1,4 @@
import pytest
import time
from tests.base_test_case import SingleDeviceTestCase
from views.console_view import ConsoleView
from tests import user_flow
@ -14,20 +13,20 @@ class TestSanity(SingleDeviceTestCase):
def test_sign_in(self, verification):
verifications = {"valid":
{"input": "qwerty1234",
"outcome": "Chats"},
"outcome": "Wallet"},
"invalid":
{"input": "12345ewq",
"outcome": "Wrong password"}}
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()
console_view.back_button.click()
profile_view = console_view.profile_button.click()
profile_view.logout_button.scroll_to_element()
sign_in_view = profile_view.logout_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)
sign_in_view.find_full_text(verifications[verification]["outcome"], 60)
if verifications[verification]["input"] in str(console_view.logcat):
pytest.fail('Password in logcat!!!', pytrace=False)
@ -35,16 +34,16 @@ class TestSanity(SingleDeviceTestCase):
@pytest.mark.parametrize("verification", ["logcat", "mismatch", "short"])
def test_password(self, verification):
verifications = {
"short": {"input": "qwe1",
"outcome": "Password should be not less then 6 symbols."},
"short": {"input": "qwe1",
"outcome": "Password should be not less then 6 symbols."},
"mismatch": {"input": "mismatch1234",
"outcome": "Password confirmation doesn\'t match password."},
"mismatch": {"input": "mismatch1234",
"outcome": "Password confirmation doesn\'t match password."},
"logcat": {"input": "new_unique_password",
"outcome": "Here is your signing phrase. "
"You will use it to verify your transactions. "
"Write it down and keep it safe!"}}
"logcat": {"input": "new_unique_password",
"outcome": "Here is your signing phrase. "
"You will use it to verify your transactions. "
"Write it down and keep it safe!"}}
console = ConsoleView(self.driver)
console.request_password_icon.click()
console.chat_request_input.send_keys(verifications[verification]["input"])
@ -62,36 +61,31 @@ class TestSanity(SingleDeviceTestCase):
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()
console_view.back_button.click()
profile_view = console_view.profile_button.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.click()
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 = profile_view.logout_button.click()
sign_in_view.first_account_button.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()
home_view = sign_in_view.sign_in_button.click()
home_view.find_full_text('Wallet', 60)
home_view.profile_button.click()
for text in new_status + ' ', new_username:
chats_view.find_full_text(text, 5)
home_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()
console_view.back_button.click()
profile_view = console_view.profile_button.click()
sign_in_view = profile_view.logout_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'])
@ -100,6 +94,6 @@ class TestSanity(SingleDeviceTestCase):
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)
console_view.find_full_text('Wallet', 60)
if basic_user['password'] in str(console_view.logcat):
pytest.fail('Password in logcat!!!', pytrace=False)

View File

@ -3,7 +3,7 @@ import time
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
from selenium.common.exceptions import TimeoutException
@pytest.mark.all
@ -11,8 +11,8 @@ class TestTransactions(SingleDeviceTestCase):
@pytest.mark.transaction
@pytest.mark.parametrize("test, recipient", [('group_chat', 'A_USER'),
('one_to_one_chat', 'B_USER'),
('wrong_password', 'A_USER')],
('one_to_one_chat', 'B_USER'),
('wrong_password', 'A_USER')],
ids=['group_chat',
'one_to_one_chat',
'wrong_password'])
@ -20,35 +20,31 @@ class TestTransactions(SingleDeviceTestCase):
console_view = ConsoleView(self.driver)
user_flow.create_user(console_view)
console_view.back_button.click()
chats_view = console_view.get_chat_view()
home_view = console_view.get_home_view()
recipient_address = transaction_users[recipient]['address']
recipient_key = transaction_users[recipient]['public_key']
transaction_amount = '0.001'
sender_address = user_flow.get_address(chats_view)
chats_view.back_button.click()
sender_address = user_flow.get_address(home_view)
home_view.home_button.click()
api_requests.get_donate(sender_address)
initial_balance_recipient = api_requests.get_balance(recipient_address)
# 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)
user_flow.add_contact(home_view, recipient_key)
if test == 'group_chat':
for _ in range(3):
chats_view.back_button.click()
user_flow.create_group_chat(chats_view, transaction_users[recipient]['username'],
home_view.back_button.click(times_to_click=3)
user_flow.create_group_chat(home_view, transaction_users[recipient]['username'],
'trg_%s' % get_current_time())
chat_view = home_view.get_chat_view()
else:
chats_view.element_by_text(transaction_users[recipient]['username'], 'button').click()
chats_view.send_command.click()
chat_view = home_view.get_chat_with_user(transaction_users[recipient]['username']).click()
chat_view.send_command.click()
if test == 'group_chat':
chats_view.first_recipient_button.click()
chats_view.send_as_keyevent(transaction_amount)
chat_view.first_recipient_button.click()
chat_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()
chat_view.send_as_keyevent(transaction_amount)
chat_view.send_message_button.click()
send_transaction_view = chat_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':
@ -61,11 +57,11 @@ class TestTransactions(SingleDeviceTestCase):
send_transaction_view.got_it_button.click()
send_transaction_view.find_full_text(transaction_amount)
try:
chats_view.find_full_text('Sent', 10)
chat_view.find_full_text('Sent', 10)
except TimeoutException:
chats_view.find_full_text('Delivered', 10)
chat_view.find_full_text('Delivered', 10)
if test == 'group_chat':
chats_view.find_full_text('to ' + transaction_users[recipient]['username'], 60)
chat_view.find_full_text('to ' + transaction_users[recipient]['username'], 60)
api_requests.verify_balance_is_updated(initial_balance_recipient, recipient_address)
@pytest.mark.transaction
@ -75,18 +71,18 @@ class TestTransactions(SingleDeviceTestCase):
transaction_users['B_USER']['passphrase'],
transaction_users['B_USER']['password'],
transaction_users['B_USER']['username'])
chats_view = console.get_chat_view()
home_view = console.get_home_view()
address = transaction_users['B_USER']['address']
initial_balance = api_requests.get_balance(address)
contacts_view = chats_view.contacts_button.click()
auction_house = contacts_view.auction_house_button.click()
start_new_chat_view = home_view.plus_button.click()
auction_house = start_new_chat_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()
send_transaction_view = chats_view.get_send_transaction_view()
send_transaction_view = home_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'])

View File

@ -1,5 +1,4 @@
import pytest
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
@ -12,11 +11,9 @@ class TestWallet(SingleDeviceTestCase):
def test_wallet_error_messages(self):
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()
send_transaction = wallet_view.get_send_transaction_view()
console.back_button.click()
wallet_view = console.wallet_button.click()
send_transaction = wallet_view.send_button.click()
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')
@ -29,47 +26,35 @@ class TestWallet(SingleDeviceTestCase):
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()
home_view = console_view.get_home_view()
recipient_key = transaction_users_wallet['B_USER']['public_key']
user_flow.add_contact(chats_view, recipient_key)
for _ in range(3):
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()
user_flow.add_contact(home_view, recipient_key)
home_view.back_button.click(times_to_click=3)
wallet_view = home_view.wallet_button.click()
send_transaction_view = wallet_view.request_button.click()
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_view.find_text_part('Requesting 0.1 ETH')
user_chat = home_view.get_chat_with_user(transaction_users_wallet['B_USER']['username']).click()
user_chat.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'])
ids=['sign_now','sign_later'])
def test_send_transaction_from_wallet(self, test, recipient, sender):
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()
home_view = console_view.get_home_view()
recipient_key = transaction_users_wallet[recipient]['public_key']
recipient_address = transaction_users_wallet[recipient]['address']
initial_balance_recipient = api_requests.get_balance(recipient_address)
user_flow.add_contact(chats_view, recipient_key)
for _ in range(3):
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()
user_flow.add_contact(home_view, recipient_key)
home_view.back_button.click(times_to_click=3)
wallet_view = home_view.wallet_button.click()
send_transaction = wallet_view.send_button.click()
send_transaction.amount_edit_box.click()
amount = send_transaction.get_unique_amount()
send_transaction.send_as_keyevent(amount)
@ -94,7 +79,7 @@ class TestWallet(SingleDeviceTestCase):
if test == 'sign_later':
transactions_view.history_tab.click()
else:
chats_view.wallet_button.click()
home_view.wallet_button.click()
transactions_view = wallet_view.transactions_button.click()
transaction = transactions_view.transactions_table.find_transaction(amount=amount)
details_view = transaction.click()
@ -110,8 +95,8 @@ class TestWallet(SingleDeviceTestCase):
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()
home_view = console.get_home_view()
wallet = home_view.wallet_button.click()
address = transaction_users_wallet['A_USER']['address']
balance = api_requests.get_balance(address) / 1000000000000000000
eth_rate = api_requests.get_ethereum_price_in_usd()

View File

@ -21,31 +21,29 @@ def recover_access(console, passphrase, password, username):
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)
recover_access_view.find_full_text('Wallet', 60)
def get_public_key(chat):
profile_drawer = chat.profile_button.click()
profile_view = profile_drawer.profile_icon.click()
def get_public_key(home):
profile_view = home.profile_button.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()
def get_address(home):
profile_view = home.profile_button.click()
return profile_view.profile_address_text.text
def add_contact(chat, public_key):
start_new_chat = chat.plus_button.click()
def add_contact(home, public_key):
start_new_chat = home.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()
def create_group_chat(home, username_to_add, group_chat_name='new_group_chat'):
start_new_chat = home.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()
@ -55,20 +53,18 @@ def create_group_chat(chat, username_to_add, group_chat_name='new_group_chat'):
start_new_chat.save_button.click()
def get_new_username_and_status(*args):
def get_new_username_and_status(profile):
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
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
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()
users_details['status'] = new_status
users_details['name'] = new_username
return users_details

View File

@ -1,4 +1,4 @@
from appium.webdriver.common.mobileby import By, MobileBy
from appium.webdriver.common.mobileby import MobileBy
from selenium.common.exceptions import NoSuchElementException, TimeoutException
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions
@ -80,16 +80,20 @@ class BaseEditBox(BaseElement):
def send_keys(self, value):
self.find_element().send_keys(value)
self.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)
self.info('Type %s to %s' % (value, self.name))
self.info("Type '%s' to %s" % (value, self.name))
def clear(self):
self.find_element().clear()
self.info('Clear text in %s' % self.name)
def click(self):
self.find_element().click()
self.info('Tap on %s' % self.name)
class BaseText(BaseElement):

View File

@ -1,20 +1,24 @@
import logging
import time
import pytest
from views.base_element import *
from tests import api_requests
from selenium.common.exceptions import NoSuchElementException, TimeoutException
from datetime import datetime
from views.base_element import BaseButton, BaseElement, BaseEditBox, BaseText
class BackButton(BaseButton):
def __init__(self, driver):
super(BackButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@content-desc='toolbar-back-button']")
def click(self):
self.wait_for_element(30)
self.find_element().click()
logging.info('Tap on %s' % self.name)
def click(self, times_to_click: int = 1):
for _ in range(times_to_click):
try:
self.find_element().click()
except (NoSuchElementException, TimeoutException):
pass
logging.info('Tap on %s' % self.name)
return self.navigate()
@ -62,14 +66,14 @@ class ContinueButtonAPK(BaseButton):
self.locator = self.Locator.xpath_selector("//*[@text='Continue']")
class ContactsButton(BaseButton):
class HomeButton(BaseButton):
def __init__(self, driver):
super(ContactsButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='Contacts']/..")
super(HomeButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='Home']/..")
def navigate(self):
from views.contacts_view import ContactsView
return ContactsView(self.driver)
from views.home_view import HomeView
return HomeView(self.driver)
class WalletButton(BaseButton):
@ -82,20 +86,14 @@ class WalletButton(BaseButton):
return WalletView(self.driver)
class DiscoverButton(BaseButton):
class ProfileButton(BaseButton):
def __init__(self, driver):
super(DiscoverButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='Discover']/..")
super(ProfileButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='Profile']/..")
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']/..")
from views.profile_view import ProfileView
return ProfileView(self.driver)
class SaveButton(BaseButton):
@ -112,14 +110,6 @@ class NextButton(BaseButton):
"//android.widget.TextView[@text='NEXT']")
class ChatRequestInput(BaseEditBox):
def __init__(self, driver):
super(ChatRequestInput, self).__init__(driver)
self.locator = \
self.Locator.xpath_selector("//android.widget.EditText[@content-desc!='chat-message-input']")
class AppsButton(BaseButton):
def __init__(self, driver):
super(AppsButton, self).__init__(driver)
@ -137,6 +127,11 @@ class BaseView(object):
def __init__(self, driver):
self.driver = driver
self.home_button = HomeButton(self.driver)
self.button = WalletButton(self.driver)
self.wallet_button = self.button
self.profile_button = ProfileButton(self.driver)
self.yes_button = YesButton(self.driver)
self.no_button = NoButton(self.driver)
self.back_button = BackButton(self.driver)
@ -145,17 +140,10 @@ class BaseView(object):
self.continue_button_apk = ContinueButtonAPK(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)
self.contacts_button = ContactsButton(self.driver)
self.wallet_button = WalletButton(self.driver)
self.discover_button = DiscoverButton(self.driver)
self.chats_button = ChatsButton(self.driver)
self.save_button = SaveButton(self.driver)
self.chat_request_input = ChatRequestInput(self.driver)
self.apps_button = AppsButton(self.driver)
self.status_app_icon = StatusAppIcon(self.driver)
self.element_types = {
'base': BaseElement,
@ -210,6 +198,10 @@ class BaseView(object):
element.locator = element.Locator.xpath_selector('//*[contains(@text, "' + text + '")]')
return element
def get_home_view(self):
from views.home_view import HomeView
return HomeView(self.driver)
def get_chat_view(self):
from views.chat_view import ChatView
return ChatView(self.driver)

View File

@ -1,33 +1,9 @@
import logging
from selenium.common.exceptions import TimeoutException
from views.base_element import BaseButton, BaseEditBox, BaseText
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):
@ -56,7 +32,8 @@ class UserNameText(BaseText):
def __init__(self, driver):
super(UserNameText, self).__init__(driver)
self.locator = \
self.Locator.xpath_selector("//android.widget.ScrollView//android.widget.TextView")
self.Locator.xpath_selector('(//android.view.ViewGroup[@content-desc="toolbar-back-button"]'
'//..//android.widget.TextView)[1]')
class SendCommand(BaseButton):
@ -108,10 +85,6 @@ 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)

View File

@ -1,5 +1,9 @@
import logging
from selenium.common.exceptions import NoSuchElementException, TimeoutException
from views.base_element import BaseButton, BaseEditBox
from views.base_view import BaseView
from views.base_element import *
class RequestPasswordIcon(BaseButton):
@ -26,6 +30,14 @@ class RecoverButton(BaseButton):
return RecoverAccessView(self.driver)
class ChatRequestInput(BaseEditBox):
def __init__(self, driver):
super(ChatRequestInput, self).__init__(driver)
self.locator = \
self.Locator.xpath_selector("//android.widget.EditText[@content-desc!='chat-message-input']")
class ConsoleView(BaseView):
def __init__(self, driver):
@ -33,6 +45,7 @@ class ConsoleView(BaseView):
self.request_password_icon = RequestPasswordIcon(self.driver)
self.recover_button = RecoverButton(self.driver)
self.chat_request_input = ChatRequestInput(self.driver)
self.accept_agreements()

View File

@ -1,4 +1,4 @@
from views.base_element import *
from views.base_element import BaseButton, BaseEditBox
from views.base_view import BaseView

View File

@ -0,0 +1,54 @@
import logging
from selenium.common.exceptions import TimeoutException
from views.base_element import BaseButton
from views.base_view import BaseView
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 ChatElement(BaseButton):
def __init__(self, driver, username):
super(ChatElement, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='%s']" % username)
def navigate(self):
from views.chat_view import ChatView
return ChatView(self.driver)
class HomeView(BaseView):
def __init__(self, driver):
super(HomeView, self).__init__(driver)
self.plus_button = PlusButton(self.driver)
self.console_button = ConsoleButton(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_chat_with_user(self, username):
return ChatElement(self.driver, username)

View File

@ -1,5 +1,7 @@
import logging
from views.base_element import BaseText, BaseButton, BaseEditBox
from views.base_view import BaseView
from views.base_element import *
class PublicKeyText(BaseText):
@ -46,7 +48,7 @@ class OptionsButton(BaseButton):
def __init__(self, driver):
super(OptionsButton.UserStatusInput, self).__init__(driver)
self.locator = self.Locator.xpath_selector('//android.widget.ScrollView//android.widget.EditText')
self.locator = self.Locator.xpath_selector('//android.view.ViewGroup[count(*)=1]/android.widget.EditText')
class NetworkSettingsButton(BaseButton):
@ -67,6 +69,20 @@ class NetworkSettingsButton(BaseButton):
self.locator = self.Locator.xpath_selector('//*[@text="CONNECT"]')
class LogoutButton(BaseButton):
def __init__(self, driver):
super(LogoutButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector('//*[@text="Logout"]')
def click(self):
self.scroll_to_element()
self.find_element().click()
self.info('Tap on %s' % self.name)
from views.sign_in_view import SignInView
return SignInView(self.driver)
class ProfileView(BaseView):
def __init__(self, driver):
@ -82,6 +98,7 @@ class ProfileView(BaseView):
self.network_settings_button = NetworkSettingsButton(self.driver)
self.connect_button = NetworkSettingsButton.ConnectButton(self.driver)
self.logout_button = LogoutButton(self.driver)
def switch_network(self, network):
self.network_settings_button.scroll_to_element()

View File

@ -1,6 +1,5 @@
from views.base_view import BaseView
from views.base_element import BaseEditBox, BaseButton
from views.sign_in_view import SignInView
from views.base_element import *
class PassphraseInput(BaseEditBox):

View File

@ -1,9 +1,4 @@
import time
import pytest
from selenium.common.exceptions import NoSuchElementException
from views.base_element import *
from views.base_element import BaseButton, BaseEditBox
from views.base_view import BaseView

View File

@ -1,6 +1,5 @@
from views.base_element import BaseButton, BaseEditBox
from views.base_view import BaseView
import pytest
from views.base_element import *
class FirstAccountButton(BaseButton):
@ -23,6 +22,10 @@ class SignInButton(BaseButton):
super(SignInButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Sign in']")
def navigate(self):
from views.home_view import HomeView
return HomeView(self.driver)
class RecoverAccessButton(BaseButton):

View File

@ -1,5 +1,4 @@
from views.base_element import *
from views.base_view import BaseView
from views.base_element import BaseButton, BaseEditBox
from views.contacts_view import ContactsView

View File

@ -1,24 +1,29 @@
import logging
from views.base_view import BaseView
from views.base_element import BaseButton, BaseEditBox, BaseText
from views.base_element import BaseButton, BaseText
class SendButton(BaseButton):
def __init__(self, driver):
super(SendButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='SEND']")
self.locator = self.Locator.xpath_selector("//*[@text='Send transaction']")
def navigate(self):
from views.send_transaction_view import SendTransactionView
return SendTransactionView(self.driver)
class RequestButton(BaseButton):
def __init__(self, driver):
super(RequestButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='REQUEST']")
self.locator = self.Locator.xpath_selector("//*[@text='Receive transaction']")
def navigate(self):
pass
from views.send_transaction_view import SendTransactionView
return SendTransactionView(self.driver)
class SendRequestButton(BaseButton):
@ -39,7 +44,7 @@ class TransactionsButton(BaseButton):
def __init__(self, driver):
super(TransactionsButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector('(//android.view.ViewGroup[@content-desc="icon"])[4]')
self.locator = self.Locator.xpath_selector("//*[@text='Transaction History']")
def navigate(self):
from views.transactions_view import TransactionsView
@ -90,4 +95,5 @@ class WalletView(BaseView):
percentage_diff = abs((usd - expected_usd) / ((usd + expected_usd) / 2)) * 100
if percentage_diff > 2:
errors.append('Difference between current (%s) and expected (%s) USD balance > 2%%!!' % (usd, expected_usd))
logging.info('Current USD balance %s is ok' % usd)
else:
logging.info('Current USD balance %s is ok' % usd)