2018-01-26 11:07:09 +00:00
|
|
|
import time
|
2018-07-03 18:50:18 +00:00
|
|
|
from selenium.common.exceptions import TimeoutException, NoSuchElementException
|
2021-12-16 16:25:42 +00:00
|
|
|
from views.base_element import Button, Text, BaseElement, SilentButton, CheckBox
|
2018-01-14 17:43:36 +00:00
|
|
|
from views.base_view import BaseView
|
2019-10-18 13:23:36 +00:00
|
|
|
from tests import test_dapp_url
|
2018-01-14 17:43:36 +00:00
|
|
|
|
2021-07-20 08:34:10 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class ChatButton(Button):
|
|
|
|
def __init__(self, driver, **kwargs):
|
|
|
|
super().__init__(driver, **kwargs)
|
2019-04-05 13:05:23 +00:00
|
|
|
|
2018-01-14 17:43:36 +00:00
|
|
|
def navigate(self):
|
2021-01-25 16:35:40 +00:00
|
|
|
from views.chat_view import ChatView
|
|
|
|
return ChatView(self.driver)
|
2019-11-20 16:27:29 +00:00
|
|
|
|
2021-11-18 15:16:48 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class ChatElement(SilentButton):
|
2021-07-13 12:51:32 +00:00
|
|
|
def __init__(self, driver, username_part, community=False):
|
2018-06-28 18:46:51 +00:00
|
|
|
self.username = username_part
|
2021-07-08 08:32:08 +00:00
|
|
|
self.community = community
|
2021-11-18 15:16:48 +00:00
|
|
|
super().__init__(driver,
|
|
|
|
xpath="//*[@content-desc='chat-name-text'][starts-with(@text,'%s')]/.." % username_part)
|
2018-01-14 17:43:36 +00:00
|
|
|
|
|
|
|
def navigate(self):
|
2021-07-08 08:32:08 +00:00
|
|
|
if self.community:
|
|
|
|
from views.chat_view import CommunityView
|
|
|
|
return CommunityView(self.driver)
|
|
|
|
else:
|
|
|
|
from views.chat_view import ChatView
|
|
|
|
return ChatView(self.driver)
|
2018-01-14 17:43:36 +00:00
|
|
|
|
2018-05-25 17:29:07 +00:00
|
|
|
def click(self):
|
2021-07-08 08:32:08 +00:00
|
|
|
if self.community:
|
|
|
|
from views.chat_view import CommunityView
|
|
|
|
desired_element = CommunityView(self.driver).community_options_button
|
|
|
|
else:
|
|
|
|
from views.chat_view import ChatView
|
|
|
|
desired_element = ChatView(self.driver).chat_message_input
|
2018-05-25 17:29:07 +00:00
|
|
|
self.click_until_presence_of_element(desired_element=desired_element)
|
2021-07-08 08:32:08 +00:00
|
|
|
|
2018-05-25 17:29:07 +00:00
|
|
|
return self.navigate()
|
|
|
|
|
2018-07-03 18:50:18 +00:00
|
|
|
def find_element(self):
|
2018-07-13 10:56:36 +00:00
|
|
|
for i in range(2):
|
2018-07-03 18:50:18 +00:00
|
|
|
try:
|
|
|
|
return super(ChatElement, self).find_element()
|
2018-07-13 10:56:36 +00:00
|
|
|
except NoSuchElementException as e:
|
|
|
|
if i == 0:
|
2021-02-16 14:57:20 +00:00
|
|
|
self.wait_for_visibility_of_element(20)
|
2018-07-13 10:56:36 +00:00
|
|
|
else:
|
2021-02-16 14:57:20 +00:00
|
|
|
e.msg = 'Device %s: Unable to find chat with name %s' % (self.driver.number, self.username)
|
2018-07-13 10:56:36 +00:00
|
|
|
raise e
|
2018-07-03 18:50:18 +00:00
|
|
|
|
2018-07-19 09:57:45 +00:00
|
|
|
@property
|
|
|
|
def new_messages_counter(self):
|
2021-01-25 16:35:40 +00:00
|
|
|
class UnreadMessagesCountText(Text):
|
2018-07-19 09:57:45 +00:00
|
|
|
def __init__(self, driver, parent_locator: str):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, xpath="(%s//android.widget.TextView)[last()]" % parent_locator)
|
2019-11-07 13:38:14 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
return UnreadMessagesCountText(self.driver, self.locator)
|
2018-07-19 09:57:45 +00:00
|
|
|
|
2021-04-30 09:31:39 +00:00
|
|
|
@property
|
|
|
|
def chat_preview(self):
|
|
|
|
class PreveiewMessageText(Text):
|
|
|
|
def __init__(self, driver, parent_locator: str):
|
|
|
|
super().__init__(driver, xpath="%s//*[@content-desc='chat-message-text']" % parent_locator)
|
|
|
|
|
2021-11-26 14:15:26 +00:00
|
|
|
return PreveiewMessageText(self.driver, self.locator)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def no_message_preview(self):
|
|
|
|
class NoMessageText(Text):
|
|
|
|
def __init__(self, driver, parent_locator: str):
|
|
|
|
super().__init__(driver, xpath="%s//*[@content-desc='no-messages-text']" % parent_locator)
|
|
|
|
return NoMessageText(self.driver, self.locator)
|
2021-04-30 09:31:39 +00:00
|
|
|
|
2020-03-03 12:06:55 +00:00
|
|
|
@property
|
|
|
|
def new_messages_public_chat(self):
|
|
|
|
class UnreadMessagesPublicChat(BaseElement):
|
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, accessibility_id="unviewed-messages-public")
|
2020-03-03 12:06:55 +00:00
|
|
|
|
|
|
|
return UnreadMessagesPublicChat(self.driver)
|
|
|
|
|
2021-03-04 09:35:48 +00:00
|
|
|
@property
|
|
|
|
def chat_image(self):
|
|
|
|
class ChatImage(BaseElement):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super().__init__(driver, xpath="//*[@content-desc='chat-icon']")
|
|
|
|
|
|
|
|
return ChatImage(self.driver)
|
|
|
|
|
2021-11-18 15:16:48 +00:00
|
|
|
|
2021-08-23 15:22:36 +00:00
|
|
|
class ActivityCenterChatElement(SilentButton):
|
|
|
|
def __init__(self, driver, chat_name):
|
|
|
|
self.chat_name = chat_name
|
2021-11-18 15:16:48 +00:00
|
|
|
super().__init__(driver,
|
|
|
|
xpath="//*[@content-desc='chat-name-or-sender-text'][starts-with(@text,'%s')]/../.." % chat_name)
|
2021-08-23 15:22:36 +00:00
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
from views.chat_view import ChatView
|
|
|
|
return ChatView(self.driver)
|
|
|
|
|
|
|
|
def click(self):
|
|
|
|
from views.chat_view import ChatView
|
|
|
|
desired_element = ChatView(self.driver).chat_message_input
|
|
|
|
self.click_until_presence_of_element(desired_element=desired_element)
|
|
|
|
|
|
|
|
return self.navigate()
|
|
|
|
|
|
|
|
@property
|
|
|
|
def chat_image(self):
|
|
|
|
class ChatImage(BaseElement):
|
|
|
|
def __init__(self, driver, parent_locator: str):
|
|
|
|
super().__init__(driver, xpath="%s//*[@content-desc='current-account-photo']" % parent_locator)
|
|
|
|
|
|
|
|
return ChatImage(self.driver, self.locator)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def chat_message_preview(self):
|
|
|
|
class ChatMessagePreview(BaseElement):
|
|
|
|
def __init__(self, driver, parent_locator: str):
|
|
|
|
super().__init__(driver, xpath="%s//*[@content-desc='chat-message-text']" % parent_locator)
|
|
|
|
|
|
|
|
return ChatMessagePreview(self.driver, self.locator).text
|
|
|
|
|
|
|
|
@property
|
|
|
|
def chat_name_indicator_text(self):
|
|
|
|
class ChatNameIndicatorText(BaseElement):
|
|
|
|
def __init__(self, driver, parent_locator: str):
|
2021-11-18 15:16:48 +00:00
|
|
|
super().__init__(driver,
|
|
|
|
xpath="(%s//*[@content-desc='chat-name-container']//android.widget.TextView)[last()]" % parent_locator)
|
|
|
|
|
2021-08-23 15:22:36 +00:00
|
|
|
try:
|
|
|
|
return ChatNameIndicatorText(self.driver, self.locator).text
|
|
|
|
except NoSuchElementException:
|
|
|
|
return ''
|
2021-07-05 19:28:55 +00:00
|
|
|
|
2022-06-28 15:54:14 +00:00
|
|
|
def accept_contact_request(self):
|
|
|
|
try:
|
|
|
|
accept_element = Button(self.driver, xpath=self.locator + '/*[@content-desc="accept-cr"]').find_element()
|
|
|
|
except NoSuchElementException:
|
|
|
|
return ''
|
|
|
|
if accept_element:
|
|
|
|
accept_element.click()
|
|
|
|
|
|
|
|
def decline_contact_request(self):
|
|
|
|
try:
|
|
|
|
decline_element = Button(self.driver, xpath=self.locator + '/*[@content-desc="decline-cr"]').find_element()
|
|
|
|
except NoSuchElementException:
|
|
|
|
return ''
|
|
|
|
if decline_element:
|
|
|
|
decline_element.click()
|
|
|
|
|
2021-11-18 15:16:48 +00:00
|
|
|
|
2021-10-22 17:23:27 +00:00
|
|
|
class PushNotificationElement(SilentButton):
|
|
|
|
def __init__(self, driver, pn_text):
|
|
|
|
self.pn_text = pn_text
|
|
|
|
super().__init__(driver, xpath="//*[@text='%s']" % pn_text)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def icon(self):
|
|
|
|
class PnIconElement(BaseElement):
|
|
|
|
def __init__(self, driver, parent_locator):
|
|
|
|
super().__init__(driver,
|
|
|
|
xpath="%s/../../../../*/*[@resource-id='android:id/message_icon']" % parent_locator)
|
|
|
|
|
|
|
|
return PnIconElement(self.driver, self.locator)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def username(self):
|
|
|
|
class PnUsername(BaseElement):
|
|
|
|
def __init__(self, driver, parent_locator):
|
|
|
|
super().__init__(driver,
|
|
|
|
xpath="%s/../../*[@resource-id='android:id/message_name']" % parent_locator)
|
|
|
|
|
|
|
|
return PnUsername(self.driver, self.locator).text
|
|
|
|
|
|
|
|
@property
|
|
|
|
def group_chat_icon(self):
|
|
|
|
class GroupChatIconElement(BaseElement):
|
|
|
|
def __init__(self, driver, parent_locator):
|
2021-11-18 15:16:48 +00:00
|
|
|
super().__init__(driver,
|
2021-12-06 16:55:33 +00:00
|
|
|
xpath="%s/../../../../*[@resource-id='android:id/right_icon_container']" % parent_locator)
|
2021-10-22 17:23:27 +00:00
|
|
|
|
|
|
|
return GroupChatIconElement(self.driver, self.locator)
|
|
|
|
|
|
|
|
|
2018-01-14 17:43:36 +00:00
|
|
|
class HomeView(BaseView):
|
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver)
|
2018-01-14 17:43:36 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
self.plus_button = Button(self.driver, accessibility_id="new-chat-button")
|
|
|
|
self.chat_name_text = Text(self.driver, accessibility_id="chat-name-text")
|
|
|
|
self.start_new_chat_button = ChatButton(self.driver, accessibility_id="start-1-1-chat-button")
|
|
|
|
self.new_group_chat_button = ChatButton(self.driver, accessibility_id="start-group-chat-button")
|
|
|
|
self.join_public_chat_button = ChatButton(self.driver, accessibility_id="join-public-chat-button")
|
|
|
|
self.universal_qr_scanner_button = Button(self.driver, accessibility_id="universal-qr-scanner")
|
|
|
|
self.invite_friends_button = Button(self.driver, accessibility_id="invite-friends-button")
|
|
|
|
self.stop_status_service_button = Button(self.driver, accessibility_id="STOP")
|
2021-11-18 15:16:48 +00:00
|
|
|
self.my_profile_on_start_new_chat_button = Button(self.driver,
|
|
|
|
xpath="//*[@content-desc='current-account-photo']")
|
2021-07-08 08:32:08 +00:00
|
|
|
self.communities_button = ChatButton(self.driver, accessibility_id="communities-button")
|
2021-01-25 16:35:40 +00:00
|
|
|
|
2021-04-19 08:37:46 +00:00
|
|
|
# Notification centre
|
|
|
|
self.notifications_button = Button(self.driver, accessibility_id="notifications-button")
|
|
|
|
self.notifications_unread_badge = Button(self.driver, accessibility_id="notifications-unread-badge")
|
2021-05-07 09:19:05 +00:00
|
|
|
self.notifications_select_button = Button(self.driver, translation_id="select")
|
|
|
|
self.notifications_reject_and_delete_button = Button(self.driver, accessibility_id="reject-and-delete"
|
|
|
|
"-activity-center")
|
2021-11-18 15:16:48 +00:00
|
|
|
self.notifications_accept_and_add_button = Button(self.driver,
|
|
|
|
accessibility_id="accept-and-add-activity-center")
|
2021-05-07 09:19:05 +00:00
|
|
|
self.notifications_select_all = Button(self.driver, xpath="(//android.widget.CheckBox["
|
2021-12-21 13:57:13 +00:00
|
|
|
"@content-desc='checkbox-off'])[1]")
|
2021-08-23 15:22:36 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
# Options on long tap
|
|
|
|
self.chats_menu_invite_friends_button = Button(self.driver, accessibility_id="chats-menu-invite-friends-button")
|
|
|
|
self.delete_chat_button = Button(self.driver, accessibility_id="delete-chat-button")
|
|
|
|
self.clear_history_button = Button(self.driver, accessibility_id="clear-history-button")
|
|
|
|
self.mark_all_messages_as_read_button = Button(self.driver, accessibility_id="mark-all-read-button")
|
2019-04-05 13:05:23 +00:00
|
|
|
|
2021-02-16 14:57:20 +00:00
|
|
|
# Connection icons
|
|
|
|
self.mobile_connection_off_icon = Button(self.driver, accessibility_id="conn-button-mobile-sync-off")
|
|
|
|
self.mobile_connection_on_icon = Button(self.driver, accessibility_id="conn-button-mobile-sync")
|
|
|
|
self.connection_offline_icon = Button(self.driver, accessibility_id="conn-button-offline")
|
|
|
|
|
|
|
|
# Sync using mobile data bottom sheet
|
|
|
|
self.continue_syncing_button = Button(self.driver, accessibility_id="mobile-network-continue-syncing")
|
|
|
|
self.stop_syncing_button = Button(self.driver, accessibility_id="mobile-network-stop-syncing")
|
2021-12-16 16:25:42 +00:00
|
|
|
self.remember_my_choice_checkbox = CheckBox(self.driver, accessibility_id=":checkbox-on")
|
2021-02-16 14:57:20 +00:00
|
|
|
|
|
|
|
# Connection status bottom sheet
|
|
|
|
self.connected_to_n_peers_text = Text(self.driver, accessibility_id="connected-to-n-peers")
|
2021-11-18 15:16:48 +00:00
|
|
|
self.connected_to_node_text = Text(self.driver, accessibility_id="connected-to-mailserver")
|
2021-02-16 14:57:20 +00:00
|
|
|
self.waiting_for_wi_fi = Text(self.driver, accessibility_id="waiting-wi-fi")
|
|
|
|
self.use_mobile_data_switch = Button(self.driver, accessibility_id="mobile-network-use-mobile")
|
2021-11-18 15:16:48 +00:00
|
|
|
self.connection_settings_button = Button(self.driver, accessibility_id="settings")
|
2021-02-16 14:57:20 +00:00
|
|
|
self.not_connected_to_node_text = Text(self.driver, accessibility_id="not-connected-nodes")
|
|
|
|
self.not_connected_to_peers_text = Text(self.driver, accessibility_id="not-connected-to-peers")
|
|
|
|
|
2018-01-14 17:43:36 +00:00
|
|
|
def wait_for_syncing_complete(self):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info('Waiting for syncing to complete')
|
2018-01-14 17:43:36 +00:00
|
|
|
while True:
|
|
|
|
try:
|
2021-02-01 16:09:04 +00:00
|
|
|
sync = self.element_by_text_part('Syncing').wait_for_element(10)
|
2018-08-15 12:51:52 +00:00
|
|
|
self.driver.info(sync.text)
|
2018-01-14 17:43:36 +00:00
|
|
|
except TimeoutException:
|
|
|
|
break
|
|
|
|
|
2022-05-23 15:30:24 +00:00
|
|
|
def get_chat(self, username, community=False, wait_time=30):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Looking for chat: '%s'" % username)
|
2021-07-08 08:32:08 +00:00
|
|
|
chat_element = ChatElement(self.driver, username[:25], community=community)
|
2022-01-14 16:51:54 +00:00
|
|
|
if not chat_element.is_element_displayed(10):
|
2021-12-21 13:57:13 +00:00
|
|
|
self.notifications_unread_badge.wait_and_click(wait_time)
|
2021-08-23 15:22:36 +00:00
|
|
|
chat_in_ac = ActivityCenterChatElement(self.driver, username[:25])
|
2021-07-05 19:28:55 +00:00
|
|
|
chat_in_ac.wait_for_element(20)
|
|
|
|
chat_in_ac.click()
|
2021-04-19 08:37:46 +00:00
|
|
|
return chat_element
|
|
|
|
|
|
|
|
def get_chat_from_home_view(self, username):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Looking for chat: '%s'" % username)
|
2021-04-19 08:37:46 +00:00
|
|
|
chat_element = ChatElement(self.driver, username[:25])
|
|
|
|
return chat_element
|
2018-01-26 11:07:09 +00:00
|
|
|
|
2021-08-23 15:22:36 +00:00
|
|
|
def get_chat_from_activity_center_view(self, chat_name):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Looking for chat: '%s'" % chat_name)
|
2021-08-23 15:22:36 +00:00
|
|
|
chat_element = ActivityCenterChatElement(self.driver, chat_name[:25])
|
|
|
|
return chat_element
|
|
|
|
|
2022-06-28 15:54:14 +00:00
|
|
|
def handle_contact_request(self, username: str, accept=True):
|
|
|
|
self.notifications_unread_badge.wait_and_click()
|
|
|
|
chat_element = ActivityCenterChatElement(self.driver, username[:25])
|
|
|
|
if accept:
|
|
|
|
self.driver.info("Accepting contact request for %s" % username)
|
|
|
|
chat_element.accept_contact_request()
|
|
|
|
chat_element.click()
|
|
|
|
else:
|
|
|
|
self.driver.info("Rejecting contact request for %s" % username)
|
|
|
|
chat_element.decline_contact_request()
|
|
|
|
|
2020-03-19 16:34:20 +00:00
|
|
|
def get_username_below_start_new_chat_button(self, username_part):
|
2021-11-18 15:16:48 +00:00
|
|
|
return Text(self.driver,
|
|
|
|
xpath="//*[@content-desc='enter-contact-code-input']/../..//*[starts-with(@text,'%s')]" % username_part)
|
2020-03-19 16:34:20 +00:00
|
|
|
|
2020-11-02 15:21:33 +00:00
|
|
|
def add_contact(self, public_key, add_in_contacts=True, nickname=''):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("## Starting 1-1 chat, add in contacts:%s" % str(add_in_contacts), device=False)
|
2019-07-29 23:32:29 +00:00
|
|
|
self.plus_button.click_until_presence_of_element(self.start_new_chat_button)
|
2021-02-04 12:51:01 +00:00
|
|
|
chat = self.start_new_chat_button.click()
|
|
|
|
chat.public_key_edit_box.click()
|
|
|
|
chat.public_key_edit_box.send_keys(public_key)
|
2018-03-15 20:01:08 +00:00
|
|
|
one_to_one_chat = self.get_chat_view()
|
2021-02-04 12:51:01 +00:00
|
|
|
chat.confirm_until_presence_of_element(one_to_one_chat.chat_message_input)
|
2021-10-27 12:29:13 +00:00
|
|
|
if add_in_contacts and one_to_one_chat.add_to_contacts.is_element_displayed():
|
2019-10-23 17:17:54 +00:00
|
|
|
one_to_one_chat.add_to_contacts.click()
|
2020-11-02 15:21:33 +00:00
|
|
|
if nickname:
|
|
|
|
one_to_one_chat.chat_options.click()
|
|
|
|
one_to_one_chat.view_profile_button.click()
|
|
|
|
one_to_one_chat.set_nickname(nickname)
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("## 1-1 chat is created successfully!", device=False)
|
2018-06-21 16:40:27 +00:00
|
|
|
return one_to_one_chat
|
2018-01-26 11:07:09 +00:00
|
|
|
|
|
|
|
def create_group_chat(self, user_names_to_add: list, group_chat_name: str = 'new_group_chat'):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("## Creating group chat '%s'" % group_chat_name, device=False)
|
2019-04-05 13:05:23 +00:00
|
|
|
self.plus_button.click()
|
2021-01-25 16:35:40 +00:00
|
|
|
chat_view = self.new_group_chat_button.click()
|
2020-11-03 16:15:14 +00:00
|
|
|
if user_names_to_add:
|
|
|
|
for user_name in user_names_to_add:
|
|
|
|
if len(user_names_to_add) > 5:
|
2022-03-09 16:38:29 +00:00
|
|
|
chat_view.search_by_keyword(user_name[:5])
|
2021-01-25 16:35:40 +00:00
|
|
|
chat_view.get_username_checkbox(user_name).click()
|
|
|
|
chat_view.search_input.clear()
|
2020-11-03 16:15:14 +00:00
|
|
|
else:
|
2021-01-25 16:35:40 +00:00
|
|
|
chat_view.get_username_checkbox(user_name).click()
|
|
|
|
chat_view.next_button.click()
|
|
|
|
chat_view.chat_name_editbox.send_keys(group_chat_name)
|
|
|
|
chat_view.create_button.click()
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("## Group chat %s is created successfully!" % group_chat_name, device=False)
|
2021-01-25 16:35:40 +00:00
|
|
|
return chat_view
|
2018-01-26 11:07:09 +00:00
|
|
|
|
2022-02-16 12:35:33 +00:00
|
|
|
def create_community(self, name: str, description="some_description", set_image=False, file_name='sauce_logo.png', require_approval=True):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("## Creating community '%s', set image is set to '%s'" % (name, str(set_image)), device=False)
|
2021-07-08 08:32:08 +00:00
|
|
|
self.plus_button.click()
|
|
|
|
chat_view = self.communities_button.click()
|
|
|
|
chat_view.create_community_button.click()
|
|
|
|
chat_view.community_name_edit_box.set_value(name)
|
|
|
|
chat_view.community_description_edit_box.set_value(description)
|
|
|
|
if set_image:
|
|
|
|
from views.profile_view import ProfileView
|
|
|
|
set_picture_view = ProfileView(self.driver)
|
2021-08-09 11:16:02 +00:00
|
|
|
set_picture_view.element_by_translation_id("community-thumbnail-upload").scroll_and_click()
|
|
|
|
set_picture_view.element_by_translation_id("community-image-pick").scroll_and_click()
|
2021-07-08 08:32:08 +00:00
|
|
|
set_picture_view.select_photo_from_gallery(file_name)
|
|
|
|
set_picture_view.crop_photo_button.click()
|
2022-02-16 12:35:33 +00:00
|
|
|
if require_approval:
|
|
|
|
self.element_by_translation_id("membership-title").scroll_and_click()
|
|
|
|
self.element_by_translation_id("membership-approval").click()
|
|
|
|
self.done_button.click()
|
2021-07-08 08:32:08 +00:00
|
|
|
|
2022-02-16 12:35:33 +00:00
|
|
|
chat_view.confirm_create_in_community_button.wait_and_click()
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("## Community is created successfully!", device=False)
|
2021-07-08 08:32:08 +00:00
|
|
|
return chat_view.get_community_by_name(name)
|
|
|
|
|
2018-02-14 13:48:18 +00:00
|
|
|
def join_public_chat(self, chat_name: str):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("## Creating public chat %s" % chat_name, device=False)
|
2019-07-23 23:10:55 +00:00
|
|
|
self.plus_button.click_until_presence_of_element(self.join_public_chat_button, attempts=5)
|
2019-07-01 18:10:11 +00:00
|
|
|
self.join_public_chat_button.wait_for_visibility_of_element(5)
|
2021-01-25 16:35:40 +00:00
|
|
|
chat_view = self.join_public_chat_button.click()
|
2021-12-06 16:55:33 +00:00
|
|
|
chat_view.chat_name_editbox.wait_for_visibility_of_element(20)
|
2021-01-25 16:35:40 +00:00
|
|
|
chat_view.chat_name_editbox.click()
|
|
|
|
chat_view.chat_name_editbox.send_keys(chat_name)
|
2018-05-23 13:02:45 +00:00
|
|
|
time.sleep(2)
|
2019-04-05 13:05:23 +00:00
|
|
|
self.confirm_until_presence_of_element(chat_view.chat_message_input)
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("## Public chat '%s' is created successfully!" % chat_name, device=False)
|
2021-08-23 15:22:36 +00:00
|
|
|
return self.get_chat_view()
|
2018-10-07 15:12:21 +00:00
|
|
|
|
2020-10-14 09:34:53 +00:00
|
|
|
def open_status_test_dapp(self, url=test_dapp_url, allow_all=True):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Opening dapp '%s', allow all:'%s'" % (test_dapp_url, str(allow_all)))
|
2019-03-19 12:35:15 +00:00
|
|
|
dapp_view = self.dapp_tab_button.click()
|
2020-10-14 09:34:53 +00:00
|
|
|
dapp_view.open_url(url)
|
2019-03-19 12:35:15 +00:00
|
|
|
status_test_dapp = dapp_view.get_status_test_dapp_view()
|
2019-11-21 10:26:53 +00:00
|
|
|
if allow_all:
|
2022-05-31 15:38:36 +00:00
|
|
|
if status_test_dapp.allow_button.is_element_displayed(20):
|
|
|
|
status_test_dapp.allow_button.click_until_absense_of_element(status_test_dapp.allow_button)
|
2019-11-21 10:26:53 +00:00
|
|
|
else:
|
|
|
|
status_test_dapp.deny_button.click_until_absense_of_element(status_test_dapp.deny_button)
|
2018-10-07 15:12:21 +00:00
|
|
|
return status_test_dapp
|
2019-05-20 12:16:15 +00:00
|
|
|
|
|
|
|
def delete_chat_long_press(self, username):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Deleting chat '%s' by long press" % username)
|
2020-03-17 17:27:10 +00:00
|
|
|
self.get_chat(username).long_press_element()
|
2019-05-20 12:16:15 +00:00
|
|
|
self.delete_chat_button.click()
|
|
|
|
self.delete_button.click()
|
2020-03-17 17:27:10 +00:00
|
|
|
|
2020-04-10 10:25:46 +00:00
|
|
|
def leave_chat_long_press(self, username):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Leaving chat '%s' by long press" % username)
|
2020-04-10 10:25:46 +00:00
|
|
|
self.get_chat(username).long_press_element()
|
2021-01-25 16:35:40 +00:00
|
|
|
from views.chat_view import ChatView
|
|
|
|
ChatView(self.driver).leave_chat_button.click()
|
|
|
|
ChatView(self.driver).leave_button.click()
|
2020-04-10 10:25:46 +00:00
|
|
|
|
2020-03-17 17:27:10 +00:00
|
|
|
def clear_chat_long_press(self, username):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Clearing history in chat '%s' by long press" % username)
|
2020-03-17 17:27:10 +00:00
|
|
|
self.get_chat(username).long_press_element()
|
|
|
|
self.clear_history_button.click()
|
2021-01-25 16:35:40 +00:00
|
|
|
from views.chat_view import ChatView
|
2021-10-15 10:26:36 +00:00
|
|
|
ChatView(self.driver).clear_button.click()
|
|
|
|
|
2021-10-22 17:23:27 +00:00
|
|
|
def get_pn(self, pn_text: str):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Getting PN by '%s'" % pn_text)
|
2022-01-27 20:41:57 +00:00
|
|
|
expected_element = PushNotificationElement(self.driver, pn_text)
|
|
|
|
return expected_element if expected_element.is_element_displayed(60) else False
|