tests aligned with latest nightly behavior

Signed-off-by: Anton Danchenko <ant.danchenko@gmail.com>
This commit is contained in:
Anton Danchenko 2018-02-19 13:51:53 +02:00
parent 86df18d764
commit 9cae0a5d90
No known key found for this signature in database
GPG Key ID: C2D4819B698627E4
15 changed files with 124 additions and 82 deletions

1
Jenkinsfile vendored
View File

@ -31,6 +31,7 @@ node ('macos1') {
sh 'git checkout -- .'
sh 'git checkout develop'
sh 'git checkout remotes/origin/' + BRANCH_NAME
sh 'git rebase origin/develop'
sh 'rm -rf node_modules'
sh 'cp .env.jenkins .env'

View File

@ -56,7 +56,6 @@ transaction_users = dict()
transaction_users['A_USER'] = dict()
transaction_users['A_USER']['password'] = "qwerty"
transaction_users['A_USER']['passphrase'] = "pet letter very ozone shop humor shuffle bounce convince soda hint brave"
transaction_users['A_USER']['username'] = "Evergreen Handsome Cottontail"
transaction_users['A_USER']['address'] = "67a50ef1d26de6d65dbfbb88172ac1e7017e766d"
transaction_users['A_USER']['public_key'] = "0x040e016b940e067997be8d91298d893ff2bc3580504b4ccb155ea03d183b85f1" \
@ -64,7 +63,6 @@ transaction_users['A_USER']['public_key'] = "0x040e016b940e067997be8d91298d893ff
transaction_users['B_USER'] = dict()
transaction_users['B_USER']['password'] = "qwerty"
transaction_users['B_USER']['passphrase'] = "resemble soap taxi meat reason inflict dilemma calm warrior key gloom again"
transaction_users['B_USER']['username'] = "Brief Organic Xenops"
transaction_users['B_USER']['address'] = "3d672407a7e1250bbff85b7cfdb456f5015164db"
transaction_users['B_USER']['public_key'] = "0x0406b17e5cdfadb2a05e84508b1a2916def6395e6295f57e92b85f915d40bca3" \
@ -87,3 +85,24 @@ transaction_users_wallet['B_USER']['address'] = "5261ceba31e3a7204b498b2dd20220a
transaction_users_wallet['B_USER']['public_key'] = "0x04cd70746f3df6cae7b45c32c211bd7e9e95ed5a1ec470db8f3b1f244eed182" \
"1d4a2053d7671802c5f7ce5b81f5fc2016a8109e1bc83f151ceff21f08c0cdcc6e4"
group_chat_users = dict()
group_chat_users['A_USER'] = dict()
group_chat_users['A_USER']['password'] = "qwerty"
group_chat_users['A_USER']['passphrase'] = "thank fruit brisk pond opera census grid husband claw sight chunk arena"
group_chat_users['A_USER']['username'] = "Soupy Thorough Arrowcrab"
group_chat_users['A_USER']['public_key'] = "0x04354b5882a1a0c1612d81271477925e7209d676f6fa310f8c28b761499ea39d83aacff" \
"380a181362dc5507ff116e8388a03b53f085d39536642529b5212f7cc00"
group_chat_users['B_USER'] = dict()
group_chat_users['B_USER']['password'] = "qwerty"
group_chat_users['B_USER']['passphrase'] = "label ill slender audit atom love vote snap edit program climb beyond"
group_chat_users['B_USER']['username'] = "Sleepy Friendly Eel"
group_chat_users['B_USER']['public_key'] = "0x049fca07d1d85cd8fac7f2615c61323e0e32ad46b93169dfb2b1cdc3bfeb66d1974c575" \
"ba84b79e63fa567ba62d93d45a4f28442a63a9bee353423c02c1b7a7134"
group_chat_users['C_USER'] = dict()
group_chat_users['C_USER']['password'] = "qwerty"
group_chat_users['C_USER']['passphrase'] = "you salmon ticket antique spray panther flee neck scale mad trial exile"
group_chat_users['C_USER']['username'] = "Voluminous Buoyant Mouflon"
group_chat_users['C_USER']['public_key'] = "0x042a59230f87211cf5f6c86203fdf415fd0a5a9ea600baa7b69d476a83e0a7826aa8c87" \
"b9f6aa2c459c0c7115d8c82887a5462d7c2fd4590c2e98aa87ed6caa9ce"

View File

@ -72,7 +72,7 @@ class AbstractTestCase:
desired_caps['appiumVersion'] = '1.7.1'
desired_caps['platformVersion'] = '6.0'
desired_caps['newCommandTimeout'] = 600
desired_caps['fullReset'] = True
desired_caps['fullReset'] = False
desired_caps['unicodeKeyboard'] = True
return desired_caps
@ -106,18 +106,24 @@ class SingleDeviceTestCase(AbstractTestCase):
'capabilities': self.capabilities_local},
'sauce': {'executor': self.executor_sauce_lab,
'capabilities': self.capabilities_sauce_lab}}
self.driver = webdriver.Remote(capabilities[self.environment]['executor'],
capabilities[self.environment]['capabilities'])
self.driver.implicitly_wait(self.implicitly_wait)
test_suite_data.current_test.jobs.append(self.driver.session_id)
counter = 0
self.driver = None
while not self.driver and counter <= 3:
try:
self.driver = webdriver.Remote(capabilities[self.environment]['executor'],
capabilities[self.environment]['capabilities'])
self.driver.implicitly_wait(self.implicitly_wait)
test_suite_data.current_test.jobs.append(self.driver.session_id)
break
except WebDriverException:
counter += 1
def teardown_method(self, method):
if self.environment == 'sauce':
self.print_sauce_lab_info(self.driver)
try:
self.driver.quit()
except WebDriverException:
except (WebDriverException, AttributeError):
pass
@ -162,10 +168,10 @@ class SauceMultipleDeviceTestCase(AbstractTestCase):
def teardown_method(self, method):
for driver in self.drivers:
self.print_sauce_lab_info(self.drivers[driver])
try:
self.print_sauce_lab_info(self.drivers[driver])
self.drivers[driver].quit()
except WebDriverException:
except (WebDriverException, AttributeError):
pass
@classmethod

View File

@ -4,6 +4,7 @@ import pytest
import emoji
from tests.base_test_case import MultipleDeviceTestCase
from tests import group_chat_users
from views.sign_in_view import SignInView
unicode_text_message = '%s%s%s%s %s%s%s%s%s%s%s' % (chr(355), chr(275), chr(353), chr(539), chr(1084), chr(949),
@ -86,21 +87,30 @@ class TestMessages(MultipleDeviceTestCase):
@pytest.mark.pr
def test_group_chat_messages(self):
self.create_drivers(3)
device_1, device_2, device_3 = SignInView(self.drivers[0]), SignInView(self.drivers[1]), \
SignInView(self.drivers[2])
for sign_in in device_1, device_2, device_3:
sign_in.create_user()
device_1, device_2, device_3 = \
SignInView(self.drivers[0]), SignInView(self.drivers[1]), SignInView(self.drivers[2])
for data in (device_1, group_chat_users['A_USER']), \
(device_2, group_chat_users['B_USER']), \
(device_3, group_chat_users['C_USER']):
data[0].recover_access(data[1]['passphrase'], data[1]['password'])
home_1, home_2, home_3 = device_1.get_home_view(), device_2.get_home_view(), device_3.get_home_view()
public_key_2, public_key_3 = home_2.get_public_key(), home_3.get_public_key()
profile_1 = home_1.profile_button.click()
profile_2, profile_3 = home_2.get_profile_view(), home_3.get_profile_view()
username_1, username_2, username_3 = profile_1.username_text.text, profile_2.username_text.text, \
profile_3.username_text.text
for profile in profile_1, profile_2, profile_3:
profile.home_button.click()
public_key_2, public_key_3 = \
group_chat_users['B_USER']['public_key'], \
group_chat_users['C_USER']['public_key']
username_1, username_2, username_3 = \
group_chat_users['A_USER']['username'], \
group_chat_users['B_USER']['username'], \
group_chat_users['C_USER']['username']
for public_key in public_key_2, public_key_3:
home_1.add_contact(public_key)
home_1.back_button.click()
home_1.get_back_to_home_view()
chat_name = 'super_group_chat'
home_1.create_group_chat(sorted([username_2, username_3]), chat_name)
chat_1 = home_1.get_chat_view()

View File

@ -8,7 +8,6 @@ from views.sign_in_view import SignInView
@pytest.mark.all
class TestProfileView(SingleDeviceTestCase):
@pytest.mark.pr
def test_qr_code_and_its_value(self):
sign_in_view = SignInView(self.driver)
sign_in_view.create_user()
@ -26,9 +25,10 @@ class TestProfileView(SingleDeviceTestCase):
home_view = sign_in_view.get_home_view()
home_view.add_contact(basic_user['public_key'])
chat_view = home_view.get_chat_view()
chat_view.user_profile_icon_top_right.click()
chat_view.user_profile_details.click()
chat_view.find_full_text(basic_user['username'])
chat_view.chat_options.click_until_presence_of_element(chat_view.view_profile_button)
chat_view.view_profile_button.click()
for text in basic_user['username'], 'In contacts', 'Send transaction', 'Send message', 'Contact code':
chat_view.find_full_text(text)
@pytest.mark.pr
def test_network_switch(self):
@ -37,7 +37,7 @@ class TestProfileView(SingleDeviceTestCase):
profile_view = sign_in_view.profile_button.click()
sign_in_view = profile_view.switch_network('Rinkeby with upstream RPC')
sign_in_view.first_account_button.click()
sign_in_view.password_input.send_keys('qwerty1234')
sign_in_view.password_input.set_value('qwerty1234')
sign_in_view.sign_in_button.click()
sign_in_view.profile_button.click()
sign_in_view.find_full_text('RINKEBY WITH UPSTREAM RPC', 20)
desired_network = sign_in_view.element_by_text('RINKEBY WITH UPSTREAM RPC')
sign_in_view.profile_button.click_until_presence_of_element(desired_network)

View File

@ -24,6 +24,7 @@ class TestTransaction(SingleDeviceTestCase):
initial_balance_recipient = api_requests.get_balance(recipient['address'])
home_view.add_contact(recipient['public_key'])
chat_view = home_view.get_chat_with_user(recipient['username']).click()
chat_view.commands_button.click()
chat_view.send_command.click()
chat_view.send_as_keyevent(transaction_amount)
send_transaction_view = chat_view.get_send_transaction_view()
@ -50,6 +51,7 @@ class TestTransaction(SingleDeviceTestCase):
transaction_amount = '0.001'
home_view.add_contact(recipient['public_key'])
chat_view = home_view.get_chat_with_user(recipient['username']).click()
chat_view.commands_button.click()
chat_view.send_command.click()
chat_view.send_as_keyevent(transaction_amount)
send_transaction_view = chat_view.get_send_transaction_view()
@ -76,6 +78,7 @@ class TestTransaction(SingleDeviceTestCase):
home_view.get_back_to_home_view()
home_view.create_group_chat([recipient['username']], 'trg_%s' % get_current_time())
chat_view = home_view.get_chat_view()
chat_view.commands_button.click()
chat_view.send_command.click()
chat_view.first_recipient_button.click()
chat_view.send_as_keyevent(transaction_amount)
@ -127,9 +130,9 @@ class TestTransaction(SingleDeviceTestCase):
send_transaction.amount_edit_box.set_value(amount)
send_transaction.confirm()
send_transaction.chose_recipient_button.click()
send_transaction.enter_contact_code_button.click()
send_transaction.enter_recipient_address_button.click()
send_transaction.enter_recipient_address_input.set_value(recipient['address'])
send_transaction.done_button.click()
send_transaction.done_button.click_until_presence_of_element(send_transaction.sign_later_button)
send_transaction.sign_later_button.click()
send_transaction.yes_button.click()
send_transaction.ok_button_apk.click()
@ -142,12 +145,10 @@ class TestTransaction(SingleDeviceTestCase):
send_transaction.got_it_button.click()
api_requests.verify_balance_is_updated(initial_balance_recipient, recipient['address'])
transactions_view.history_tab.click()
transaction = transactions_view.transactions_table.find_transaction(amount=amount)
details_view = transaction.click()
details_view.get_transaction_hash()
transactions_view.transactions_table.find_transaction(amount=amount)
@pytest.mark.pr
def test_send_stt_from_wallet_via_enter_contact_code(self):
def test_send_stt_from_wallet_via_enter_recipient_address(self):
sender = transaction_users_wallet['A_USER']
recipient = transaction_users_wallet['B_USER']
sign_in_view = SignInView(self.driver)
@ -167,7 +168,7 @@ class TestTransaction(SingleDeviceTestCase):
send_transaction.amount_edit_box.set_value(send_transaction.get_unique_amount())
send_transaction.confirm()
send_transaction.chose_recipient_button.click()
send_transaction.enter_contact_code_button.click()
send_transaction.enter_recipient_address_button.click()
send_transaction.enter_recipient_address_input.set_value(recipient['address'])
send_transaction.done_button.click()
send_transaction.sign_transaction_button.click()
@ -219,6 +220,7 @@ class TestTransactions(MultipleDeviceTestCase):
device_1_chat = device_1_home.get_chat_view()
device_2_chat = device_2_home.get_chat_view()
amount = device_1_chat.get_unique_amount()
device_1_chat.commands_button.click()
device_1_chat.request_command.click()
device_1_chat.first_recipient_button.click()
device_1_chat.send_as_keyevent(amount)
@ -249,6 +251,7 @@ class TestTransactions(MultipleDeviceTestCase):
amount = device_1_chat.get_unique_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.commands_button.click_until_presence_of_element(device_1_chat.request_command)
device_1_chat.request_command.click()
device_1_chat.send_as_keyevent(amount)
device_1_chat.send_message_button.click()

View File

@ -122,7 +122,7 @@ class BaseButton(BaseElement):
info('Tap on %s' % self.name)
return self.navigate()
def click_until_presence_of_element(self, desired_element, attempts=5):
def click_until_presence_of_element(self, desired_element, attempts=3):
counter = 0
while not desired_element.is_element_present() and counter <= attempts:
try:

View File

@ -42,6 +42,12 @@ class DenyButton(BaseButton):
self.locator = self.Locator.xpath_selector("//*[@text='Deny']")
class DeleteButton(BaseButton):
def __init__(self, driver):
super(DeleteButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='Delete']")
class YesButton(BaseButton):
def __init__(self, driver):
super(YesButton, self).__init__(driver)
@ -135,16 +141,21 @@ class StatusAppIcon(BaseButton):
"//*[@text='Status']")
class DeleteButton(BaseButton):
class SendMessageButton(BaseButton):
def __init__(self, driver):
super(DeleteButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='Delete']")
super(SendMessageButton, self).__init__(driver)
self.locator = self.Locator.accessibility_id("send-message-button")
def click(self):
self.find_element().click()
info('Tap on %s' % self.name)
class BaseView(object):
def __init__(self, driver):
self.driver = driver
self.send_message_button = SendMessageButton(self.driver)
self.home_button = HomeButton(self.driver)
self.wallet_button = WalletButton(self.driver)
self.profile_button = ProfileButton(self.driver)

View File

@ -11,16 +11,6 @@ class ChatMessageInput(BaseEditBox):
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()
info('Tap on %s' % self.name)
class AddToContacts(BaseButton):
def __init__(self, driver):
super(AddToContacts, self).__init__(driver)
@ -38,7 +28,7 @@ class UserNameText(BaseText):
class TransactionPopupText(BaseText):
def __init__(self, driver):
super(TransactionPopupText, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='Send transaction']")
self.locator = self.Locator.xpath_selector("//*[@text='Specify amount']")
class SendCommand(BaseButton):
@ -46,10 +36,6 @@ class SendCommand(BaseButton):
super(SendCommand, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='/send']")
def click(self):
desired_element = TransactionPopupText(self.driver)
self.click_until_presence_of_element(desired_element=desired_element)
class RequestCommand(BaseButton):
def __init__(self, driver):
@ -116,12 +102,6 @@ class MoreUsersButton(BaseButton):
self.locator = self.Locator.xpath_selector("//android.widget.TextView[contains(@text, 'MORE')]")
class UserProfileIconTopRight(BaseButton):
def __init__(self, driver):
super(UserProfileIconTopRight, self).__init__(driver)
self.locator = self.Locator.accessibility_id('chat-icon')
class UserProfileDetails(BaseButton):
def __init__(self, driver):
super(UserProfileDetails, self).__init__(driver)
@ -138,15 +118,27 @@ class OpenInBrowserButton(BaseButton):
return BaseWebView(self.driver)
class CommandsButton(BaseButton):
def __init__(self, driver):
super(CommandsButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector('(// android.view.ViewGroup[@ content-desc="icon"])[3]')
class ViewProfileButton(BaseButton):
def __init__(self, driver):
super(ViewProfileButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector('//*[@text="View profile"]')
class ChatView(BaseView):
def __init__(self, driver):
super(ChatView, self).__init__(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.commands_button = CommandsButton(self.driver)
self.send_command = SendCommand(self.driver)
self.request_command = RequestCommand(self.driver)
@ -155,13 +147,13 @@ class ChatView(BaseView):
self.delete_chat_button = DeleteChatButton(self.driver)
self.chat_settings = ChatSettings(self.driver)
self.view_profile_button = ViewProfileButton(self.driver)
self.more_users_button = MoreUsersButton(self.driver)
self.user_options = UserOptions(self.driver)
self.remove_button = RemoveButton(self.driver)
self.first_recipient_button = FirstRecipient(self.driver)
self.user_profile_icon_top_right = UserProfileIconTopRight(self.driver)
self.user_profile_details = UserProfileDetails(self.driver)
self.open_in_browser_button = OpenInBrowserButton(self.driver)
@ -195,7 +187,7 @@ class ChatView(BaseView):
[i for i in list(set(expected_messages) - set(received_messages))])))
def send_eth_to_request(self, request, sender_password):
gas_popup = self.element_by_text_part('Send transaction')
gas_popup = self.element_by_text_part('Specify amount')
request.click_until_presence_of_element(gas_popup)
send_transaction = self.get_send_transaction_view()
self.send_message_button.click_until_presence_of_element(send_transaction.sign_transaction_button)

View File

@ -57,9 +57,9 @@ class ConsoleView(BaseView):
def create_user(self):
self.request_password_icon.click()
self.chat_request_input.send_keys("qwerty1234")
self.confirm()
self.send_message_button.click()
self.chat_request_input.send_keys("qwerty1234")
self.confirm()
self.send_message_button.click()
self.find_full_text(
"Here is your signing phrase. You will use it to verify your transactions. Write it down and keep it safe!")

View File

@ -9,7 +9,7 @@ class PlusButton(BaseButton):
def __init__(self, driver):
super(PlusButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector(
"//android.view.ViewGroup/android.widget.TextView[@text='+']")
"//*[@text='+']")
def navigate(self):
from views.start_new_chat_view import StartNewChatView
@ -90,7 +90,7 @@ class HomeView(BaseView):
start_new_chat = self.plus_button.click()
start_new_chat.join_public_chat_button.click()
start_new_chat.chat_name_editbox.send_keys(chat_name)
start_new_chat.confirm_button.click()
start_new_chat.confirm()
def get_public_key(self):
profile_view = self.profile_button.click()

View File

@ -60,13 +60,13 @@ class ChooseRecipientButton(BaseButton):
self.locator = self.Locator.xpath_selector("//*[@text='Specify recipient...']")
def click(self):
desired_element = EnterContactCodeButton(self.driver)
desired_element = EnterRecipientAddressButton(self.driver)
self.click_until_presence_of_element(desired_element=desired_element)
class EnterContactCodeButton(BaseButton):
class EnterRecipientAddressButton(BaseButton):
def __init__(self, driver):
super(EnterContactCodeButton, self).__init__(driver)
super(EnterRecipientAddressButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='Enter recipient address']")
@ -99,7 +99,7 @@ class SendTransactionView(BaseView):
super(SendTransactionView, self).__init__(driver)
self.chose_recipient_button = ChooseRecipientButton(self.driver)
self.enter_contact_code_button = EnterContactCodeButton(self.driver)
self.enter_recipient_address_button = EnterRecipientAddressButton(self.driver)
self.enter_recipient_address_input = EnterRecipientAddressInput(self.driver)
self.first_recipient_button = FirstRecipient(self.driver)
self.recent_recipients_button = RecentRecipientsButton(self.driver)

View File

@ -1,5 +1,5 @@
from selenium.common.exceptions import NoSuchElementException, TimeoutException
from tests import get_current_time
from views.base_element import BaseButton, BaseEditBox
from views.base_view import BaseView
@ -100,18 +100,18 @@ class SignInView(BaseView):
def create_user(self):
self.create_account_button.click()
self.password_input.send_keys('qwerty1234')
self.password_input.set_value('qwerty1234')
self.next_button.click()
self.confirm_password_input.send_keys('qwerty1234')
self.confirm_password_input.set_value('qwerty1234')
self.next_button.click()
self.name_input.wait_for_element(30)
self.name_input.send_keys('Test Name')
self.name_input.wait_for_element(45)
self.name_input.set_value('user_%s' % get_current_time())
self.next_button.click()
self.element_by_text("NO, I DON'T WANT TO SHARE").click()
def recover_access(self, passphrase, password):
recover_access_view = self.i_have_account_button.click()
recover_access_view.passphrase_input.send_keys(passphrase)
recover_access_view.passphrase_input.set_value(passphrase)
recover_access_view.password_input.click()
recover_access_view.password_input.send_keys(password)
recover_access_view.password_input.set_value(password)
recover_access_view.sign_in_button.click()

View File

@ -61,7 +61,7 @@ class EnterUrlEditbox(BaseEditBox):
class UsernameCheckbox(BaseButton):
def __init__(self, driver, username):
super(UsernameCheckbox, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='%s']/../../android.view.ViewGroup[2]/*" % username)
self.locator = self.Locator.xpath_selector("//*[@text='%s']/../../android.widget.CheckBox" % username)
class StartNewChatView(ContactsView):

View File

@ -89,7 +89,7 @@ class ManageAssetsButton(BaseButton):
class STTCheckBox(BaseButton):
def __init__(self, driver):
super(STTCheckBox, self).__init__(driver)
self.locator = self.Locator.xpath_selector("(//*[@text='STT']//..//android.view.ViewGroup)[1]")
self.locator = self.Locator.xpath_selector("//*[@text='STT']//..//android.widget.CheckBox")
class DoneButton(BaseButton):