2017-08-28 10:02:20 +00:00
|
|
|
from views.base_view import BaseViewObject
|
2017-09-21 17:01:04 +00:00
|
|
|
import time
|
2017-08-28 10:02:20 +00:00
|
|
|
from views.base_element import *
|
|
|
|
|
|
|
|
|
|
|
|
class ProfileButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ProfileButton, self).__init__(driver)
|
2017-09-11 10:43:42 +00:00
|
|
|
self.locator = self.Locator.accessibility_id('toolbar-hamburger-menu')
|
2017-08-28 10:02:20 +00:00
|
|
|
|
2017-10-30 11:11:58 +00:00
|
|
|
class ProfileIcon(BaseButton):
|
2017-08-28 10:02:20 +00:00
|
|
|
|
2017-10-30 11:11:58 +00:00
|
|
|
def __init__(self, driver):
|
|
|
|
super(ProfileButton.ProfileIcon, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('drawer-profile-icon')
|
2017-08-28 10:02:20 +00:00
|
|
|
|
2017-10-30 11:11:58 +00:00
|
|
|
def navigate(self):
|
|
|
|
from views.profile import ProfileViewObject
|
|
|
|
return ProfileViewObject(self.driver)
|
2017-08-28 10:02:20 +00:00
|
|
|
|
2017-10-30 11:11:58 +00:00
|
|
|
class SwitchUsersButton(BaseButton):
|
2017-09-21 17:01:04 +00:00
|
|
|
|
2017-10-30 11:11:58 +00:00
|
|
|
def __init__(self, driver):
|
|
|
|
super(ProfileButton.SwitchUsersButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='SWITCH USERS']")
|
2017-09-21 17:01:04 +00:00
|
|
|
|
2017-10-30 11:11:58 +00:00
|
|
|
def click(self):
|
|
|
|
time.sleep(2)
|
|
|
|
self.find_element().click()
|
|
|
|
logging.info('Tap on %s' % self.name)
|
|
|
|
return self.navigate()
|
2017-09-26 10:50:34 +00:00
|
|
|
|
2017-10-30 11:11:58 +00:00
|
|
|
def navigate(self):
|
|
|
|
from views.login import LoginView
|
|
|
|
return LoginView(self.driver)
|
2017-09-21 17:01:04 +00:00
|
|
|
|
|
|
|
|
2017-08-28 10:02:20 +00:00
|
|
|
class PlusButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(PlusButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector(
|
|
|
|
"//android.widget.TextView[@text='+']")
|
|
|
|
|
|
|
|
|
2017-09-21 17:01:04 +00:00
|
|
|
class ConsoleButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ConsoleButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector(
|
|
|
|
"//*[@text='Console']")
|
|
|
|
|
|
|
|
|
2017-08-28 10:02:20 +00:00
|
|
|
class AddNewContactButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(AddNewContactButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector(
|
|
|
|
"//android.widget.TextView[@text='Add new contact']")
|
|
|
|
|
|
|
|
|
2017-09-21 17:01:04 +00:00
|
|
|
class NewContactButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(NewContactButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='']")
|
|
|
|
|
|
|
|
|
2017-08-31 13:39:41 +00:00
|
|
|
class NewGroupChatButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(NewGroupChatButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector(
|
|
|
|
"//android.widget.TextView[@text='New group chat']")
|
|
|
|
|
|
|
|
class NextButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(NewGroupChatButton.NextButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector(
|
|
|
|
"//android.widget.TextView[@text='NEXT']")
|
|
|
|
|
|
|
|
class NameEditBox(BaseEditBox):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(NewGroupChatButton.NameEditBox, self).__init__(driver)
|
|
|
|
self.locator = \
|
|
|
|
self.Locator.xpath_selector("//android.widget.EditText[@NAF='true']")
|
|
|
|
|
2017-09-13 14:34:42 +00:00
|
|
|
class GroupChatOptions(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(NewGroupChatButton.GroupChatOptions, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector(
|
|
|
|
"//android.view.ViewGroup[2]//android.widget.TextView[@text='n']")
|
|
|
|
|
|
|
|
class ChatSettings(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(NewGroupChatButton.ChatSettings, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Settings']")
|
|
|
|
|
|
|
|
class UserOptions(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(NewGroupChatButton.UserOptions, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//android.widget.ImageView[@content-desc="chat-icon"]'
|
|
|
|
'/../..//android.view.View')
|
|
|
|
|
|
|
|
class RemoveButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(NewGroupChatButton.RemoveButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Remove']")
|
|
|
|
|
2017-08-31 13:39:41 +00:00
|
|
|
|
2017-08-28 10:02:20 +00:00
|
|
|
class PublicKeyEditBox(BaseEditBox):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(PublicKeyEditBox, self).__init__(driver)
|
|
|
|
self.locator = \
|
|
|
|
self.Locator.xpath_selector("//android.widget.EditText[@NAF='true']")
|
|
|
|
|
|
|
|
|
|
|
|
class ConfirmPublicKeyButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ConfirmPublicKeyButton, self).__init__(driver)
|
|
|
|
self.locator = \
|
2017-09-11 10:43:42 +00:00
|
|
|
self.Locator.accessibility_id('toolbar-action')
|
2017-08-28 10:02:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ChatMessageInput(BaseEditBox):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ChatMessageInput, self).__init__(driver)
|
2017-09-11 10:43:42 +00:00
|
|
|
self.locator = self.Locator.accessibility_id('chat-message-input')
|
2017-08-28 10:02:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SendMessageButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(SendMessageButton, self).__init__(driver)
|
2017-09-11 10:43:42 +00:00
|
|
|
self.locator = self.Locator.accessibility_id("send-message-button")
|
2017-08-28 10:02:20 +00:00
|
|
|
|
2017-09-21 17:01:04 +00:00
|
|
|
def click(self):
|
|
|
|
self.find_element().click()
|
|
|
|
logging.info('Tap on %s' % self.name)
|
|
|
|
|
2017-08-28 10:02:20 +00:00
|
|
|
|
2017-10-30 11:11:58 +00:00
|
|
|
class AddToContacts(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(AddToContacts, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='Add to contacts']")
|
|
|
|
|
|
|
|
|
2017-08-31 13:39:41 +00:00
|
|
|
class UserNameText(BaseText):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(UserNameText, self).__init__(driver)
|
|
|
|
self.locator = \
|
|
|
|
self.Locator.xpath_selector("//android.widget.ScrollView//android.widget.TextView")
|
|
|
|
|
|
|
|
|
2017-09-21 17:01:04 +00:00
|
|
|
class SendFundsButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(SendFundsButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='/send']")
|
|
|
|
|
|
|
|
class FirstRecipient(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(SendFundsButton.FirstRecipient, self).__init__(driver)
|
2017-10-05 19:41:17 +00:00
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='Choose recipient']/.."
|
|
|
|
"//android.widget.ImageView[@content-desc='chat-icon']")
|
2017-09-21 17:01:04 +00:00
|
|
|
|
2017-10-05 19:41:17 +00:00
|
|
|
class SignTransactionButton(BaseButton):
|
2017-09-21 17:01:04 +00:00
|
|
|
|
|
|
|
def __init__(self, driver):
|
2017-10-05 19:41:17 +00:00
|
|
|
super(SendFundsButton.SignTransactionButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='SIGN TRANSACTION']")
|
2017-09-21 17:01:04 +00:00
|
|
|
|
2017-10-19 13:49:20 +00:00
|
|
|
class SignLaterButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(SendFundsButton.SignLaterButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='SIGN LATER']")
|
|
|
|
|
2017-09-21 17:01:04 +00:00
|
|
|
class PasswordInput(BaseEditBox):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(SendFundsButton.PasswordInput, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='Password']")
|
|
|
|
|
2017-10-05 19:41:17 +00:00
|
|
|
class EnterPasswordInput(BaseEditBox):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(SendFundsButton.EnterPasswordInput, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.EditText[@NAF='true']")
|
|
|
|
|
2017-09-21 17:01:04 +00:00
|
|
|
class ConfirmButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(SendFundsButton.ConfirmButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='CONFIRM']")
|
|
|
|
|
|
|
|
class GotItButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(SendFundsButton.GotItButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='GOT IT']")
|
|
|
|
|
|
|
|
|
2017-08-28 10:02:20 +00:00
|
|
|
class ChatsViewObject(BaseViewObject):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ChatsViewObject, self).__init__(driver)
|
|
|
|
self.driver = driver
|
|
|
|
|
|
|
|
self.profile_button = ProfileButton(self.driver)
|
2017-10-30 11:11:58 +00:00
|
|
|
self.profile_icon = ProfileButton.ProfileIcon(self.driver)
|
|
|
|
self.switch_users_button = ProfileButton.SwitchUsersButton(self.driver)
|
2017-09-21 17:01:04 +00:00
|
|
|
|
2017-08-28 10:02:20 +00:00
|
|
|
self.plus_button = PlusButton(self.driver)
|
|
|
|
self.add_new_contact = AddNewContactButton(self.driver)
|
2017-09-21 17:01:04 +00:00
|
|
|
self.console_button = ConsoleButton(self.driver)
|
2017-08-31 13:39:41 +00:00
|
|
|
|
2017-08-28 10:02:20 +00:00
|
|
|
self.public_key_edit_box = PublicKeyEditBox(self.driver)
|
|
|
|
self.confirm_public_key_button = ConfirmPublicKeyButton(self.driver)
|
2017-08-31 13:39:41 +00:00
|
|
|
|
|
|
|
self.new_group_chat_button = NewGroupChatButton(self.driver)
|
|
|
|
self.next_button = NewGroupChatButton.NextButton(self.driver)
|
|
|
|
self.name_edit_box = NewGroupChatButton.NameEditBox(self.driver)
|
2017-09-13 14:34:42 +00:00
|
|
|
self.group_chat_options = NewGroupChatButton.GroupChatOptions(self.driver)
|
|
|
|
self.chat_settings = NewGroupChatButton.ChatSettings(self.driver)
|
|
|
|
self.user_options = NewGroupChatButton.UserOptions(self.driver)
|
|
|
|
self.remove_button = NewGroupChatButton.RemoveButton(self.driver)
|
2017-09-11 10:43:42 +00:00
|
|
|
|
|
|
|
self.chat_message_input = ChatMessageInput(self.driver)
|
|
|
|
self.send_message_button = SendMessageButton(self.driver)
|
2017-10-30 11:11:58 +00:00
|
|
|
self.add_to_contacts = AddToContacts(self.driver)
|
2017-09-11 10:43:42 +00:00
|
|
|
self.user_name_text = UserNameText(self.driver)
|
2017-09-21 17:01:04 +00:00
|
|
|
|
|
|
|
self.send_funds_button = SendFundsButton(self.driver)
|
2017-10-19 13:49:20 +00:00
|
|
|
|
2017-09-21 17:01:04 +00:00
|
|
|
self.first_recipient_button = SendFundsButton.FirstRecipient(self.driver)
|
2017-10-05 19:41:17 +00:00
|
|
|
self.sign_transaction_button = SendFundsButton.SignTransactionButton(self.driver)
|
2017-10-19 13:49:20 +00:00
|
|
|
self.sign_later_button = SendFundsButton.SignLaterButton(self.driver)
|
2017-09-21 17:01:04 +00:00
|
|
|
self.confirm_button = SendFundsButton.ConfirmButton(self.driver)
|
|
|
|
self.password_input = SendFundsButton.PasswordInput(self.driver)
|
2017-10-05 19:41:17 +00:00
|
|
|
self.enter_password_input = SendFundsButton.EnterPasswordInput(self.driver)
|
2017-09-21 17:01:04 +00:00
|
|
|
self.got_it_button = SendFundsButton.GotItButton(self.driver)
|
|
|
|
|
|
|
|
self.new_contact_button = NewContactButton(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
|