added 'test_new_profile_name_and_status_on_discover' and 'test_change_profile_name_and_status'

fixed verification of user status on drawer menu
This commit is contained in:
Anton Danchenko 2017-10-30 13:11:58 +02:00
parent b3a2ddf2b6
commit bd8d967743
10 changed files with 222 additions and 37 deletions

View File

@ -1,3 +1,6 @@
from datetime import datetime
def set_password_as_new_user(*args):
for view in args:
view.request_password_icon.click()
@ -9,6 +12,26 @@ def set_password_as_new_user(*args):
"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)

View File

@ -1,11 +1,59 @@
import pytest
from tests.basetestcase import MultiplyDeviceTestCase
from tests.preconditions import set_password_as_new_user
from tests.preconditions import set_password_as_new_user, change_user_details
from views.home import HomeView
@pytest.mark.all
class TestChats(MultiplyDeviceTestCase):
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()
chats_d1.back_button.click()
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):

View File

@ -9,6 +9,37 @@ 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)
def test_recover_access(self):
home = HomeView(self.driver)
set_password_as_new_user(home)

View File

@ -4,6 +4,7 @@ from tests.basetestcase import SingleDeviceTestCase
from views.home import HomeView
from tests.preconditions import set_password_as_new_user, recover_access
from tests import transaction_users
from selenium.common.exceptions import NoSuchElementException
@pytest.mark.all
@ -65,7 +66,10 @@ class TestTransactions(SingleDeviceTestCase):
chats.sign_transaction_button.click()
chats.got_it_button.click()
chats.find_full_text('0.1')
chats.find_full_text('Sent', 60)
try:
chats.find_full_text('Sent', 10)
except NoSuchElementException:
chats.find_full_text('Delivered', 10)
if test == 'group_chat':
chats.find_full_text('to ' + transaction_users[recipient]['username'], 60)
chats.verify_balance_is_updated(initial_balance_recipient, recipient_address)

View File

@ -53,7 +53,7 @@ class TestWallet(SingleDeviceTestCase):
wallet = chats.wallet_button.click()
wallet.send_button.click()
wallet.amount_edit_box.click()
amount = '0,00%s' % datetime.now().strftime('%f')[:3]
amount = '0,0%s' % datetime.now().strftime('%-m%-d%-H%-M%-S')
wallet.send_as_keyevent(amount)
wallet.confirm()
wallet.chose_recipient_button.click()

View File

@ -82,6 +82,10 @@ class BaseEditBox(BaseElement):
self.find_element().set_value(value)
logging.info('Set %s to %s' % (value, self.name))
def clear(self):
self.find_element().clear()
logging.info('Clear text in %s' % self.name)
class BaseText(BaseElement):

View File

@ -43,6 +43,16 @@ class WalletButton(BaseButton):
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)
@ -93,6 +103,13 @@ def verify_transaction_in_ropsten(address: str, transaction_hash: str):
pytest.fail('Transaction was not found via Ropsten API')
class SaveButton(BaseButton):
def __init__(self, driver):
super(SaveButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector(
"//android.widget.TextView[@text='SAVE']")
class BaseViewObject(object):
def __init__(self, driver):
self.driver = driver
@ -106,6 +123,9 @@ class BaseViewObject(object):
self.contacts_button = ContactsButton(self.driver)
self.wallet_button = WalletButton(self.driver)
self.discover_button = DiscoverButton(self.driver)
self.save_button = SaveButton(self.driver)
def confirm(self):
logging.info("Tap 'Confirm' on native keyboard")

View File

@ -1,5 +1,4 @@
from views.base_view import BaseViewObject
import pytest
import time
from views.base_element import *
@ -10,33 +9,31 @@ class ProfileButton(BaseButton):
super(ProfileButton, self).__init__(driver)
self.locator = self.Locator.accessibility_id('toolbar-hamburger-menu')
class ProfileIcon(BaseButton):
class ProfileIcon(BaseButton):
def __init__(self, driver):
super(ProfileButton.ProfileIcon, self).__init__(driver)
self.locator = self.Locator.accessibility_id('drawer-profile-icon')
def __init__(self, driver):
super(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)
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']")
class SwitchUsersButton(BaseButton):
def click(self):
time.sleep(2)
self.find_element().click()
logging.info('Tap on %s' % self.name)
return self.navigate()
def __init__(self, driver):
super(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)
def navigate(self):
from views.login import LoginView
return LoginView(self.driver)
class PlusButton(BaseButton):
@ -89,12 +86,6 @@ class NewGroupChatButton(BaseButton):
self.locator = \
self.Locator.xpath_selector("//android.widget.EditText[@NAF='true']")
class SaveButton(BaseButton):
def __init__(self, driver):
super(NewGroupChatButton.SaveButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector(
"//android.widget.TextView[@text='SAVE']")
class GroupChatOptions(BaseButton):
def __init__(self, driver):
super(NewGroupChatButton.GroupChatOptions, self).__init__(driver)
@ -152,6 +143,13 @@ class SendMessageButton(BaseButton):
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):
@ -217,8 +215,8 @@ class ChatsViewObject(BaseViewObject):
self.driver = driver
self.profile_button = ProfileButton(self.driver)
self.profile_icon = ProfileIcon(self.driver)
self.switch_users_button = SwitchUsersButton(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)
@ -230,7 +228,6 @@ class ChatsViewObject(BaseViewObject):
self.new_group_chat_button = NewGroupChatButton(self.driver)
self.next_button = NewGroupChatButton.NextButton(self.driver)
self.name_edit_box = NewGroupChatButton.NameEditBox(self.driver)
self.save_button = NewGroupChatButton.SaveButton(self.driver)
self.group_chat_options = NewGroupChatButton.GroupChatOptions(self.driver)
self.chat_settings = NewGroupChatButton.ChatSettings(self.driver)
self.user_options = NewGroupChatButton.UserOptions(self.driver)
@ -238,6 +235,7 @@ class ChatsViewObject(BaseViewObject):
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)

View File

@ -0,0 +1,28 @@
from views.base_view import BaseViewObject
import time
from views.base_element import *
class AllRecent(BaseButton):
def __init__(self, driver):
super(AllRecent, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='Recent statuses']/..//*[@text='ALL']")
class AllPopular(BaseButton):
def __init__(self, driver):
super(AllPopular, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='Popular #hashtags']/..//*[@text='ALL']")
class DiscoverView(BaseViewObject):
def __init__(self, driver):
super(DiscoverView, self).__init__(driver)
self.driver = driver
self.all_popular = AllPopular(self.driver)
self.all_recent = AllRecent(self.driver)

View File

@ -22,6 +22,33 @@ class ProfileAddressText(BaseText):
self.locator = self.Locator.accessibility_id('profile-address')
class OptionsButton(BaseButton):
def __init__(self, driver):
super(OptionsButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector(
'(//android.view.ViewGroup[@content-desc="icon"])[2]')
class UserStatusBox(BaseButton):
def __init__(self, driver):
super(OptionsButton.UserStatusBox, self).__init__(driver)
self.locator = self.Locator.xpath_selector(
'//android.widget.ImageView[@content-desc="chat-icon"]/..//android.widget.ScrollView')
class UsernameInput(BaseEditBox):
def __init__(self, driver):
super(OptionsButton.UsernameInput, self).__init__(driver)
self.locator = self.Locator.xpath_selector('//*[@text="Name"]/..//android.widget.EditText')
class UserStatusInput(BaseEditBox):
def __init__(self, driver):
super(OptionsButton.UserStatusInput, self).__init__(driver)
self.locator = self.Locator.xpath_selector('//android.widget.ScrollView//android.widget.EditText')
class NetworkSettingsButton(BaseButton):
def __init__(self, driver):
@ -71,18 +98,20 @@ class NetworkSettingsButton(BaseButton):
self.locator = self.Locator.xpath_selector('//*[@text="CONNECT"]')
class ProfileViewObject(BaseViewObject):
def __init__(self, driver):
super(ProfileViewObject, self).__init__(driver)
self.driver = driver
self.options_button = OptionsButton(self.driver)
self.username_input = OptionsButton.UsernameInput(self.driver)
self.user_status_box = OptionsButton.UserStatusBox(self.driver)
self.user_status_input = OptionsButton.UserStatusInput(self.driver)
self.public_key_text = PublicKeyText(self.driver)
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)