2018-02-14 13:48:18 +00:00
|
|
|
import time
|
2018-06-21 23:57:54 +00:00
|
|
|
|
2018-07-03 18:50:18 +00:00
|
|
|
from selenium.common.exceptions import TimeoutException, NoSuchElementException
|
2018-09-17 08:50:01 +00:00
|
|
|
|
|
|
|
from tests import common_password
|
2018-11-21 10:44:30 +00:00
|
|
|
from views.base_element import BaseButton, BaseEditBox, BaseText, BaseElement
|
2018-07-23 11:38:47 +00:00
|
|
|
from views.base_view import BaseView, ProgressBar
|
2018-10-02 11:33:51 +00:00
|
|
|
from views.profile_view import ProfilePictureElement, ProfileAddressText
|
2018-01-03 09:34:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ChatMessageInput(BaseEditBox):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ChatMessageInput, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('chat-message-input')
|
|
|
|
|
|
|
|
|
|
|
|
class AddToContacts(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(AddToContacts, self).__init__(driver)
|
2018-03-28 10:21:39 +00:00
|
|
|
self.locator = self.Locator.accessibility_id('add-to-contacts-button')
|
2018-01-03 09:34:40 +00:00
|
|
|
|
2019-09-19 09:25:16 +00:00
|
|
|
class RemoveFromContactsButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(RemoveFromContactsButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('in-contacts-button')
|
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
|
2018-12-05 14:11:50 +00:00
|
|
|
class AddGroupChatMembersButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(AddGroupChatMembersButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='Add members']")
|
|
|
|
|
|
|
|
def navigate(self):
|
2019-04-05 13:05:23 +00:00
|
|
|
from views.contacts_view import ContactsView
|
|
|
|
return ContactsView(self.driver)
|
2018-12-05 14:11:50 +00:00
|
|
|
|
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
class UserNameText(BaseText):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(UserNameText, self).__init__(driver)
|
|
|
|
self.locator = \
|
2018-03-28 10:21:39 +00:00
|
|
|
self.Locator.accessibility_id('chat-name-text')
|
2018-01-03 09:34:40 +00:00
|
|
|
|
|
|
|
|
2018-02-09 15:16:07 +00:00
|
|
|
class TransactionPopupText(BaseText):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(TransactionPopupText, self).__init__(driver)
|
2018-02-19 11:51:53 +00:00
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='Specify amount']")
|
2018-02-09 15:16:07 +00:00
|
|
|
|
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
class SendCommand(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(SendCommand, self).__init__(driver)
|
2018-07-23 11:38:47 +00:00
|
|
|
self.locator = self.Locator.accessibility_id('send-button')
|
2018-01-03 09:34:40 +00:00
|
|
|
|
2018-08-29 14:04:12 +00:00
|
|
|
def click(self):
|
|
|
|
self.wait_for_element().click()
|
|
|
|
self.driver.info('Tap on %s' % self.name)
|
|
|
|
return self.navigate()
|
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
|
|
|
|
class RequestCommand(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(RequestCommand, self).__init__(driver)
|
2018-07-23 11:38:47 +00:00
|
|
|
self.locator = self.Locator.accessibility_id('request-button')
|
2018-01-03 09:34:40 +00:00
|
|
|
|
2018-08-29 14:04:12 +00:00
|
|
|
def click(self):
|
|
|
|
self.wait_for_element().click()
|
|
|
|
self.driver.info('Tap on %s' % self.name)
|
|
|
|
return self.navigate()
|
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
|
2018-07-03 18:50:18 +00:00
|
|
|
class AssetCommand(BaseButton):
|
|
|
|
def __init__(self, driver, asset):
|
|
|
|
super(AssetCommand, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.text_selector(asset)
|
2018-06-15 15:20:50 +00:00
|
|
|
|
|
|
|
|
2018-03-28 10:21:39 +00:00
|
|
|
class ChatMenuButton(BaseButton):
|
2018-01-03 09:34:40 +00:00
|
|
|
def __init__(self, driver):
|
2018-03-28 10:21:39 +00:00
|
|
|
super(ChatMenuButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('chat-menu-button')
|
2018-01-26 11:07:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
class MembersButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(MembersButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('(//android.view.ViewGroup[@content-desc="action"])[1]')
|
2018-01-03 09:34:40 +00:00
|
|
|
|
|
|
|
|
2018-02-14 13:48:18 +00:00
|
|
|
class DeleteChatButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(DeleteChatButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[@text="Delete chat"]')
|
|
|
|
|
|
|
|
|
2018-05-23 13:02:45 +00:00
|
|
|
class ClearHistoryButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ClearHistoryButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[@text="Clear history"]')
|
|
|
|
|
|
|
|
|
2018-12-05 14:11:50 +00:00
|
|
|
class GroupInfoButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(GroupInfoButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[@text="Group info"]')
|
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
return GroupChatInfoView(self.driver)
|
|
|
|
|
|
|
|
|
2018-05-23 13:02:45 +00:00
|
|
|
class LeaveChatButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(LeaveChatButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[@text="Leave public chat"]')
|
|
|
|
|
|
|
|
|
|
|
|
class ClearButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ClearButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[@text="CLEAR"]')
|
|
|
|
|
2019-04-19 15:29:35 +00:00
|
|
|
|
2019-07-11 15:44:12 +00:00
|
|
|
class BlockButton(BaseButton):
|
2019-04-19 15:29:35 +00:00
|
|
|
def __init__(self, driver):
|
|
|
|
super(BlockButton, self).__init__(driver)
|
2019-09-20 13:59:31 +00:00
|
|
|
self.locator = self.Locator.xpath_selector('(//*[@text="Block this user"])[2]')
|
2019-04-19 15:29:35 +00:00
|
|
|
|
2018-05-23 13:02:45 +00:00
|
|
|
|
|
|
|
class LeaveButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(LeaveButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[@text="LEAVE"]')
|
|
|
|
|
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
class ChatSettings(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ChatSettings, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Settings']")
|
|
|
|
|
|
|
|
|
|
|
|
class UserOptions(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(UserOptions, self).__init__(driver)
|
2018-03-28 10:21:39 +00:00
|
|
|
self.locator = self.Locator.accessibility_id('options')
|
2018-01-03 09:34:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
class RemoveButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(RemoveButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Remove']")
|
|
|
|
|
|
|
|
|
|
|
|
class FirstRecipient(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(FirstRecipient, self).__init__(driver)
|
2018-03-28 10:21:39 +00:00
|
|
|
self.locator = self.Locator.accessibility_id('contact-item')
|
2018-01-03 09:34:40 +00:00
|
|
|
|
|
|
|
|
2018-01-26 11:07:09 +00:00
|
|
|
class MoreUsersButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(MoreUsersButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[contains(@text, 'MORE')]")
|
|
|
|
|
|
|
|
|
2018-07-12 19:41:50 +00:00
|
|
|
class OpenInStatusButton(BaseButton):
|
2018-02-14 13:48:18 +00:00
|
|
|
def __init__(self, driver):
|
2018-07-12 19:41:50 +00:00
|
|
|
super(OpenInStatusButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='Open in Status']")
|
2018-02-14 13:48:18 +00:00
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
from views.web_views.base_web_view import BaseWebView
|
|
|
|
return BaseWebView(self.driver)
|
|
|
|
|
|
|
|
|
2018-02-19 11:51:53 +00:00
|
|
|
class CommandsButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(CommandsButton, self).__init__(driver)
|
2018-03-28 10:21:39 +00:00
|
|
|
self.locator = self.Locator.accessibility_id('chat-commands-button')
|
2018-02-19 11:51:53 +00:00
|
|
|
|
|
|
|
|
2019-03-12 12:18:03 +00:00
|
|
|
class ShowStickersButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ShowStickersButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('show-stickers-icon')
|
|
|
|
|
|
|
|
|
|
|
|
class GetStickers(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(GetStickers, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[contains(@text, "Get Stickers")]')
|
|
|
|
|
|
|
|
|
|
|
|
class StickerIcon(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(StickerIcon, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('sticker-icon')
|
|
|
|
|
|
|
|
|
2018-02-19 11:51:53 +00:00
|
|
|
class ViewProfileButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ViewProfileButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[@text="View profile"]')
|
|
|
|
|
|
|
|
|
2018-04-26 06:22:11 +00:00
|
|
|
class NoMessagesInChatText(BaseText):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(NoMessagesInChatText, self).__init__(driver)
|
2018-06-08 10:02:54 +00:00
|
|
|
self.locator = self.Locator.text_part_selector(
|
|
|
|
'Any messages you send here are encrypted and can only be read by you and')
|
2018-04-26 06:22:11 +00:00
|
|
|
|
|
|
|
|
2018-05-02 16:01:17 +00:00
|
|
|
class ProfileSendMessageButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ProfileSendMessageButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('start-conversation-button')
|
|
|
|
|
|
|
|
|
|
|
|
class ProfileSendTransactionButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ProfileSendTransactionButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('send-transaction-button')
|
|
|
|
|
2019-07-11 15:44:12 +00:00
|
|
|
|
2019-04-19 15:29:35 +00:00
|
|
|
class ProfileBlockContactButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ProfileBlockContactButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('block-contact')
|
2018-05-02 16:01:17 +00:00
|
|
|
|
2019-07-11 15:44:12 +00:00
|
|
|
|
2019-01-15 10:30:16 +00:00
|
|
|
class JoinChatButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(JoinChatButton, self).__init__(driver)
|
2019-03-14 19:51:54 +00:00
|
|
|
self.locator = self.Locator.text_part_selector('Join group')
|
2019-01-15 10:30:16 +00:00
|
|
|
|
2019-04-05 13:05:23 +00:00
|
|
|
|
2019-03-18 13:48:55 +00:00
|
|
|
class DeclineChatButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(DeclineChatButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.text_part_selector('Decline invitation')
|
|
|
|
|
2019-04-05 13:05:23 +00:00
|
|
|
|
2019-03-26 09:23:01 +00:00
|
|
|
class RemoveFromChatButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(RemoveFromChatButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[@text="Remove from chat"]')
|
|
|
|
|
2019-04-05 13:05:23 +00:00
|
|
|
|
2019-03-26 09:23:01 +00:00
|
|
|
class MakeAdminButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(MakeAdminButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[@text="Make admin"]')
|
2019-01-15 10:30:16 +00:00
|
|
|
|
2019-04-05 13:05:23 +00:00
|
|
|
|
2018-06-21 16:40:27 +00:00
|
|
|
class ChatElementByText(BaseText):
|
|
|
|
def __init__(self, driver, text):
|
|
|
|
super(ChatElementByText, self).__init__(driver)
|
2018-07-03 18:50:18 +00:00
|
|
|
self.message_text = text
|
2019-08-02 21:22:23 +00:00
|
|
|
self.message_locator = "//*[starts-with(@text,'%s')]" % text
|
2018-06-21 16:40:27 +00:00
|
|
|
self.locator = self.Locator.xpath_selector(
|
2019-08-02 21:22:23 +00:00
|
|
|
self.message_locator + "/ancestor::android.view.ViewGroup[@content-desc='chat-item']")
|
2018-06-21 16:40:27 +00:00
|
|
|
|
2018-07-03 18:50:18 +00:00
|
|
|
def find_element(self):
|
2018-08-15 12:51:52 +00:00
|
|
|
self.driver.info("Looking for message with text '%s'" % self.message_text)
|
2018-07-03 18:50:18 +00:00
|
|
|
for _ in range(2):
|
|
|
|
try:
|
|
|
|
return super(ChatElementByText, self).find_element()
|
|
|
|
except NoSuchElementException:
|
|
|
|
ChatView(self.driver).reconnect()
|
|
|
|
|
2018-06-21 16:40:27 +00:00
|
|
|
@property
|
|
|
|
def status(self):
|
|
|
|
class StatusText(BaseText):
|
|
|
|
def __init__(self, driver, parent_locator: str):
|
|
|
|
super(StatusText, self).__init__(driver)
|
2018-07-17 16:27:00 +00:00
|
|
|
text = "//android.widget.TextView[@text='Seen' or @text='Sent' or " \
|
|
|
|
"@text='Not sent. Tap for options' or @text='Network mismatch']"
|
2018-07-13 10:56:36 +00:00
|
|
|
self.locator = self.Locator.xpath_selector(parent_locator + text)
|
2018-06-21 16:40:27 +00:00
|
|
|
|
2019-07-11 15:44:12 +00:00
|
|
|
return StatusText(self.driver, self.locator.value).wait_for_element(10)
|
2018-06-21 16:40:27 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def progress_bar(self):
|
|
|
|
return ProgressBar(self.driver, self.locator.value)
|
|
|
|
|
2018-07-03 18:50:18 +00:00
|
|
|
@property
|
|
|
|
def member_photo(self):
|
|
|
|
class MemberPhoto(BaseButton):
|
|
|
|
def __init__(self, driver, parent_locator):
|
|
|
|
super(MemberPhoto, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector(parent_locator + "//*[@content-desc='member-photo']")
|
|
|
|
|
|
|
|
return MemberPhoto(self.driver, self.locator.value)
|
2018-06-21 16:40:27 +00:00
|
|
|
|
2018-06-28 18:46:51 +00:00
|
|
|
@property
|
|
|
|
def username(self):
|
|
|
|
class Username(BaseText):
|
|
|
|
def __init__(self, driver, parent_locator):
|
|
|
|
super(Username, self).__init__(driver)
|
2019-06-25 17:22:00 +00:00
|
|
|
self.locator = self.Locator.xpath_selector(parent_locator + "/*[1]/android.widget.TextView")
|
2018-06-28 18:46:51 +00:00
|
|
|
|
|
|
|
return Username(self.driver, self.locator.value)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def send_request_button(self):
|
|
|
|
class SendRequestButton(BaseButton):
|
|
|
|
def __init__(self, driver, parent_locator):
|
|
|
|
super(SendRequestButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector(parent_locator + '//*[@text="Send"]')
|
|
|
|
|
|
|
|
return SendRequestButton(self.driver, self.locator.value)
|
|
|
|
|
2018-07-13 10:56:36 +00:00
|
|
|
def contains_text(self, text, wait_time=5) -> bool:
|
2018-07-03 18:50:18 +00:00
|
|
|
element = BaseText(self.driver)
|
|
|
|
element.locator = element.Locator.xpath_selector(
|
|
|
|
self.locator.value + "//android.view.ViewGroup//android.widget.TextView[contains(@text,'%s')]" % text)
|
2018-07-13 10:56:36 +00:00
|
|
|
return element.is_element_displayed(wait_time)
|
2018-07-03 18:50:18 +00:00
|
|
|
|
2019-08-02 21:22:23 +00:00
|
|
|
@property
|
|
|
|
def replied_message_text(self):
|
|
|
|
class RepliedMessageText(BaseButton):
|
|
|
|
def __init__(self, driver, parent_locator):
|
|
|
|
super(RepliedMessageText, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector(
|
|
|
|
parent_locator + "/preceding-sibling::*[1]/android.widget.TextView[2]")
|
|
|
|
|
|
|
|
try:
|
|
|
|
return RepliedMessageText(self.driver, self.message_locator).text
|
|
|
|
except NoSuchElementException:
|
|
|
|
return ''
|
|
|
|
|
2018-06-21 16:40:27 +00:00
|
|
|
|
2018-11-21 10:44:30 +00:00
|
|
|
class EmptyPublicChatMessage(BaseText):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super().__init__(driver)
|
2019-04-10 09:48:14 +00:00
|
|
|
self.locator = self.Locator.text_part_selector("It's been quite here")
|
2018-11-21 10:44:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ChatItem(BaseElement):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super().__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[@content-desc="chat-item"]')
|
|
|
|
|
|
|
|
|
|
|
|
class HistoryTimeMarker(BaseText):
|
|
|
|
def __init__(self, driver, marker='Today'):
|
|
|
|
super().__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[@text="%s"]' % marker)
|
|
|
|
|
2019-04-05 13:05:23 +00:00
|
|
|
|
2019-03-26 09:23:01 +00:00
|
|
|
class UsernameOptions(BaseButton):
|
|
|
|
def __init__(self, driver, username):
|
|
|
|
super(UsernameOptions, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='%s']/..//*[@content-desc='options']" % username)
|
2018-11-21 10:44:30 +00:00
|
|
|
|
2019-04-05 13:05:23 +00:00
|
|
|
|
2018-12-05 14:11:50 +00:00
|
|
|
class GroupChatInfoView(BaseView):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(GroupChatInfoView, self).__init__(driver)
|
|
|
|
self.add_members = AddGroupChatMembersButton(self.driver)
|
|
|
|
|
2019-03-26 09:23:01 +00:00
|
|
|
def get_username_options(self, username: str):
|
|
|
|
return UsernameOptions(self.driver, username)
|
|
|
|
|
2018-12-05 14:11:50 +00:00
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
class ChatView(BaseView):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ChatView, self).__init__(driver)
|
|
|
|
|
|
|
|
self.chat_message_input = ChatMessageInput(self.driver)
|
|
|
|
self.add_to_contacts = AddToContacts(self.driver)
|
2019-09-19 09:25:16 +00:00
|
|
|
self.remove_from_contacts = RemoveFromContactsButton(self.driver)
|
2018-01-03 09:34:40 +00:00
|
|
|
self.user_name_text = UserNameText(self.driver)
|
2018-04-26 06:22:11 +00:00
|
|
|
self.no_messages_in_chat = NoMessagesInChatText(self.driver)
|
2018-11-21 10:44:30 +00:00
|
|
|
self.empty_public_chat_message = EmptyPublicChatMessage(self.driver)
|
|
|
|
self.chat_item = ChatItem(self.driver)
|
2018-01-03 09:34:40 +00:00
|
|
|
|
2018-02-19 11:51:53 +00:00
|
|
|
self.commands_button = CommandsButton(self.driver)
|
2018-01-03 09:34:40 +00:00
|
|
|
self.send_command = SendCommand(self.driver)
|
|
|
|
self.request_command = RequestCommand(self.driver)
|
2018-05-16 07:22:02 +00:00
|
|
|
|
2019-03-12 12:18:03 +00:00
|
|
|
self.show_stickers_button = ShowStickersButton(self.driver)
|
|
|
|
self.get_stickers = GetStickers(self.driver)
|
|
|
|
self.sticker_icon = StickerIcon(self.driver)
|
|
|
|
|
2018-03-28 10:21:39 +00:00
|
|
|
self.chat_options = ChatMenuButton(self.driver)
|
2018-01-26 11:07:09 +00:00
|
|
|
self.members_button = MembersButton(self.driver)
|
2018-02-14 13:48:18 +00:00
|
|
|
self.delete_chat_button = DeleteChatButton(self.driver)
|
2018-05-23 13:02:45 +00:00
|
|
|
self.clear_history_button = ClearHistoryButton(self.driver)
|
|
|
|
self.clear_button = ClearButton(self.driver)
|
2019-04-19 15:29:35 +00:00
|
|
|
self.block_button = BlockButton(self.driver)
|
2019-04-10 09:48:14 +00:00
|
|
|
|
|
|
|
# Group chats
|
|
|
|
self.group_info = GroupInfoButton(self.driver)
|
2018-05-23 13:02:45 +00:00
|
|
|
self.leave_chat_button = LeaveChatButton(self.driver)
|
|
|
|
self.leave_button = LeaveButton(self.driver)
|
2019-01-15 10:30:16 +00:00
|
|
|
self.join_chat_button = JoinChatButton(self.driver)
|
2019-03-18 13:48:55 +00:00
|
|
|
self.decline_invitation_button = DeclineChatButton(self.driver)
|
2019-03-26 09:23:01 +00:00
|
|
|
self.remove_user_button = RemoveFromChatButton(self.driver)
|
|
|
|
self.make_admin_button = MakeAdminButton(self.driver)
|
2018-01-26 11:07:09 +00:00
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
self.chat_settings = ChatSettings(self.driver)
|
2018-02-19 11:51:53 +00:00
|
|
|
self.view_profile_button = ViewProfileButton(self.driver)
|
2018-01-26 11:07:09 +00:00
|
|
|
self.more_users_button = MoreUsersButton(self.driver)
|
2018-01-03 09:34:40 +00:00
|
|
|
self.user_options = UserOptions(self.driver)
|
|
|
|
self.remove_button = RemoveButton(self.driver)
|
|
|
|
|
|
|
|
self.first_recipient_button = FirstRecipient(self.driver)
|
|
|
|
|
2018-07-12 19:41:50 +00:00
|
|
|
self.open_in_status_button = OpenInStatusButton(self.driver)
|
2018-02-13 17:22:41 +00:00
|
|
|
|
2018-05-02 16:01:17 +00:00
|
|
|
# Contact's profile
|
2018-05-16 19:59:36 +00:00
|
|
|
self.contact_profile_picture = ProfilePictureElement(self.driver)
|
2018-05-02 16:01:17 +00:00
|
|
|
self.profile_send_message = ProfileSendMessageButton(self.driver)
|
|
|
|
self.profile_send_transaction = ProfileSendTransactionButton(self.driver)
|
2018-10-02 11:33:51 +00:00
|
|
|
self.profile_address_text = ProfileAddressText(self.driver)
|
2019-04-19 15:29:35 +00:00
|
|
|
self.profile_block_contact = ProfileBlockContactButton(self.driver)
|
2018-05-02 16:01:17 +00:00
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
def wait_for_syncing_complete(self):
|
2018-08-15 12:51:52 +00:00
|
|
|
self.driver.info('Waiting for syncing complete:')
|
2018-01-03 09:34:40 +00:00
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
sync = self.find_text_part('Syncing', 10)
|
2018-08-15 12:51:52 +00:00
|
|
|
self.driver.info(sync.text)
|
2018-01-03 09:34:40 +00:00
|
|
|
except TimeoutException:
|
|
|
|
break
|
2018-01-26 11:07:09 +00:00
|
|
|
|
2018-05-16 19:59:36 +00:00
|
|
|
def wait_for_message_in_one_to_one_chat(self, expected_message: str, errors: list, wait_time: int = 20):
|
2018-02-14 13:48:18 +00:00
|
|
|
try:
|
2018-06-21 16:40:27 +00:00
|
|
|
element = ChatElementByText(self.driver, expected_message)
|
|
|
|
element.wait_for_element(wait_time)
|
2018-02-14 13:48:18 +00:00
|
|
|
except TimeoutException:
|
|
|
|
errors.append('Message with text "%s" was not received' % expected_message)
|
|
|
|
|
2018-03-15 20:01:08 +00:00
|
|
|
def wait_for_messages(self, username: str, expected_messages: list, errors: list, wait_time: int = 30):
|
|
|
|
expected_messages = expected_messages if type(expected_messages) == list else [expected_messages]
|
|
|
|
repeat = 0
|
|
|
|
received_messages = list()
|
|
|
|
while repeat <= wait_time:
|
|
|
|
for message in expected_messages:
|
2018-04-30 09:58:20 +00:00
|
|
|
if self.element_starts_with_text(message, 'text').is_element_present(1):
|
2018-03-15 20:01:08 +00:00
|
|
|
received_messages.append(message)
|
|
|
|
if not set(expected_messages) - set(received_messages):
|
|
|
|
break
|
|
|
|
time.sleep(3)
|
|
|
|
repeat += 3
|
|
|
|
if set(expected_messages) - set(received_messages):
|
2018-02-14 13:48:18 +00:00
|
|
|
errors.append('Not received messages from user %s: "%s"' % (username, ', '.join(
|
|
|
|
[i for i in list(set(expected_messages) - set(received_messages))])))
|
2018-02-09 15:16:07 +00:00
|
|
|
|
2018-09-17 08:50:01 +00:00
|
|
|
def send_funds_to_request(self, amount, sender_password=common_password, wallet_set_up=False):
|
2018-02-19 11:51:53 +00:00
|
|
|
gas_popup = self.element_by_text_part('Specify amount')
|
2018-06-28 18:46:51 +00:00
|
|
|
send_request_button = self.chat_element_by_text(amount).send_request_button
|
2018-06-18 13:10:34 +00:00
|
|
|
send_request_button.click_until_presence_of_element(gas_popup)
|
2018-02-09 15:16:07 +00:00
|
|
|
send_transaction = self.get_send_transaction_view()
|
2018-05-30 15:41:00 +00:00
|
|
|
if wallet_set_up:
|
|
|
|
wallet_view = self.get_wallet_view()
|
|
|
|
self.send_message_button.click_until_presence_of_element(wallet_view.sign_in_phrase)
|
|
|
|
wallet_view.done_button.click()
|
|
|
|
wallet_view.yes_button.click()
|
|
|
|
else:
|
2019-06-24 15:53:02 +00:00
|
|
|
self.send_message_button.click_until_presence_of_element(send_transaction.sign_with_password)
|
2018-02-09 15:16:07 +00:00
|
|
|
send_transaction.sign_transaction(sender_password)
|
2018-03-15 16:07:25 +00:00
|
|
|
|
2018-07-03 12:40:44 +00:00
|
|
|
def delete_chat(self):
|
2018-03-15 16:07:25 +00:00
|
|
|
self.chat_options.click()
|
|
|
|
self.delete_chat_button.click()
|
|
|
|
self.delete_button.click()
|
2018-04-26 06:22:11 +00:00
|
|
|
|
2018-06-30 12:17:38 +00:00
|
|
|
def clear_history(self):
|
|
|
|
self.chat_options.click()
|
|
|
|
self.clear_history_button.click()
|
|
|
|
self.clear_button.click()
|
|
|
|
|
2019-04-10 09:48:14 +00:00
|
|
|
def clear_history_via_group_info(self):
|
|
|
|
self.chat_options.click()
|
|
|
|
self.group_info.click()
|
|
|
|
self.clear_history_button.click()
|
|
|
|
self.clear_button.click()
|
|
|
|
self.back_button.click()
|
|
|
|
|
2018-11-26 14:06:34 +00:00
|
|
|
def send_transaction_in_1_1_chat(self, asset, amount, password=common_password, wallet_set_up=False, **kwargs):
|
2018-04-26 06:22:11 +00:00
|
|
|
self.commands_button.click()
|
|
|
|
self.send_command.click()
|
2018-07-03 18:50:18 +00:00
|
|
|
self.asset_by_name(asset).click()
|
2018-04-26 06:22:11 +00:00
|
|
|
self.send_as_keyevent(amount)
|
|
|
|
send_transaction_view = self.get_send_transaction_view()
|
2018-06-01 16:37:44 +00:00
|
|
|
if wallet_set_up:
|
|
|
|
wallet_view = self.get_wallet_view()
|
|
|
|
self.send_message_button.click_until_presence_of_element(wallet_view.sign_in_phrase)
|
|
|
|
wallet_view.done_button.click()
|
|
|
|
wallet_view.yes_button.click()
|
|
|
|
else:
|
2019-06-12 08:38:02 +00:00
|
|
|
self.send_message_button.click_until_presence_of_element(send_transaction_view.sign_with_password)
|
2018-11-26 14:06:34 +00:00
|
|
|
if kwargs.get('sign_transaction', True):
|
|
|
|
send_transaction_view.sign_transaction(password)
|
|
|
|
chat_elem = self.chat_element_by_text(amount)
|
|
|
|
chat_elem.wait_for_visibility_of_element()
|
|
|
|
chat_elem.progress_bar.wait_for_invisibility_of_element(20)
|
|
|
|
if chat_elem.status.text not in ('Sent', 'Delivered', 'Seen'):
|
|
|
|
self.driver.fail('Sent transaction message was not sent')
|
2018-04-26 06:22:11 +00:00
|
|
|
|
|
|
|
def send_transaction_in_group_chat(self, amount, password, recipient):
|
|
|
|
self.commands_button.click()
|
|
|
|
self.send_command.click()
|
|
|
|
self.find_full_text(recipient['username']).click()
|
|
|
|
self.send_as_keyevent(amount)
|
|
|
|
self.send_message_button.click()
|
|
|
|
|
|
|
|
send_transaction_view = self.get_send_transaction_view()
|
|
|
|
self.send_message_button.click_until_presence_of_element(send_transaction_view.sign_transaction_button)
|
|
|
|
send_transaction_view.sign_transaction(password)
|
|
|
|
send_transaction_view.find_full_text(amount)
|
|
|
|
self.find_full_text('to ' + recipient['username'], 10)
|
|
|
|
|
2018-12-05 14:11:50 +00:00
|
|
|
def add_members_to_group_chat(self, user_names_to_add: list):
|
|
|
|
self.chat_options.click()
|
|
|
|
group_info_view = self.group_info.click()
|
|
|
|
add_members_view = group_info_view.add_members.click()
|
|
|
|
for user_name in user_names_to_add:
|
|
|
|
user_contact = add_members_view.get_username_checkbox(user_name)
|
|
|
|
user_contact.scroll_to_element()
|
|
|
|
user_contact.click()
|
|
|
|
add_members_view.add_button.click()
|
|
|
|
|
2019-03-26 09:23:01 +00:00
|
|
|
def get_user_options(self, username: str):
|
|
|
|
self.chat_options.click()
|
|
|
|
group_info_view = self.group_info.click()
|
|
|
|
group_info_view.get_username_options(username).click()
|
|
|
|
return self
|
|
|
|
|
2018-07-03 18:50:18 +00:00
|
|
|
def request_transaction_in_1_1_chat(self, asset, amount):
|
2018-04-26 06:22:11 +00:00
|
|
|
self.commands_button.click()
|
|
|
|
self.request_command.click()
|
2018-07-03 18:50:18 +00:00
|
|
|
self.asset_by_name(asset).click()
|
2018-04-26 06:22:11 +00:00
|
|
|
self.send_as_keyevent(amount)
|
|
|
|
self.send_message_button.click()
|
2018-05-16 19:59:36 +00:00
|
|
|
|
|
|
|
def chat_element_by_text(self, text):
|
2018-08-15 12:51:52 +00:00
|
|
|
self.driver.info("Looking for a message by text: '%s'" % text)
|
2018-06-21 16:40:27 +00:00
|
|
|
return ChatElementByText(self.driver, text)
|
|
|
|
|
|
|
|
def verify_message_is_under_today_text(self, text, errors):
|
|
|
|
message_element = self.chat_element_by_text(text)
|
|
|
|
message_element.wait_for_visibility_of_element()
|
|
|
|
message_location = message_element.find_element().location['y']
|
|
|
|
today_text_element = self.element_by_text('Today').find_element()
|
|
|
|
today_location = today_text_element.location['y']
|
|
|
|
today_height = today_text_element.size['height']
|
|
|
|
if message_location < today_location + today_height:
|
2018-07-03 18:50:18 +00:00
|
|
|
errors.append("Message '%s' is not under 'Today' text" % text)
|
2018-11-21 10:44:30 +00:00
|
|
|
|
|
|
|
def send_message(self, message: str = 'test message'):
|
|
|
|
self.chat_message_input.send_keys(message)
|
|
|
|
self.send_message_button.click()
|
|
|
|
|
|
|
|
def move_to_messages_by_time_marker(self, marker='Today'):
|
|
|
|
self.driver.info("Moving to messages by time marker: '%s'" % marker)
|
|
|
|
HistoryTimeMarker(self.driver, marker).scroll_to_element(depth=50, direction='up')
|
2019-09-05 02:32:33 +00:00
|
|
|
|
|
|
|
def install_sticker_pack_by_name(self, pack_name: str):
|
|
|
|
element = BaseButton(self.driver)
|
|
|
|
element.locator = element.Locator.xpath_selector(
|
2019-10-10 09:29:22 +00:00
|
|
|
"//*[@content-desc='sticker-pack-name'][@text='%s']/..//*[@content-desc='sticker-pack-price']" % pack_name)
|
2019-09-13 15:32:12 +00:00
|
|
|
element.scroll_to_element()
|
2019-09-05 02:32:33 +00:00
|
|
|
element.click()
|
|
|
|
element.wait_for_invisibility_of_element()
|