This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
new_message.py
145 lines (116 loc) · 6.16 KB
/
new_message.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from marionette_driver import expected, By, Wait
from gaiatest.apps.base import Base
from gaiatest.apps.contacts.app import Contacts
from gaiatest.apps.messages.app import Messages
class NewMessage(Messages):
_recipient_section_locator = (By.ID, 'messages-recipients-list')
_receiver_input_locator = (By.CSS_SELECTOR, '#messages-recipients-list span.recipient')
_add_recipient_button_locator = (By.ID, 'messages-contact-pick-button')
_message_field_locator = (By.ID, 'messages-input')
_send_message_button_locator = (By.ID, 'messages-send-button')
_attach_button_locator = (By.ID, 'messages-attach-button')
_options_button_locator = (By.ID, 'messages-options-button')
_message_sending_locator = (By.CSS_SELECTOR, "li.message.outgoing.sending")
_thread_messages_locator = (By.ID, 'thread-messages')
_message_resize_notice_locator = (By.ID, 'messages-resize-notice')
_subject_input_locator = (By.CSS_SELECTOR, '.subject-composer-input')
_image_attachment_locator = (By.CSS_SELECTOR, '.attachment-container.preview')
_recipients_locator = (By.CSS_SELECTOR, '#messages-recipients-list span')
def __init__(self, marionette):
Base.__init__(self, marionette)
Wait(self.marionette).until(lambda m: self.apps.displayed_app.name == self.name)
self.apps.switch_to_displayed_app()
section = self.marionette.find_element(*self._thread_messages_locator)
Wait(self.marionette).until(lambda m: section.location['x'] == 0)
def type_phone_number(self, value):
# tap on the parent element to activate editable
self.marionette.find_element(*self._recipient_section_locator).tap()
self.keyboard.send(value)
def type_message(self, value):
# change the focus to the message field to enable the send button
self.tap_message()
self.keyboard.send(value)
def tap_message(self):
message = Wait(self.marionette).until(
expected.element_present(*self._message_field_locator))
Wait(self.marionette).until(expected.element_displayed(message))
message.tap()
def tap_image_attachment(self):
self.marionette.find_element(*self._image_attachment_locator).tap()
from gaiatest.apps.messages.regions.attachment_options import AttachmentOptions
return AttachmentOptions(self.marionette)
def tap_send(self, timeout=120):
send = Wait(self.marionette).until(
expected.element_present(*self._send_message_button_locator))
Wait(self.marionette).until(expected.element_enabled(send))
send.tap()
self.wait_for_element_not_present(*self._message_sending_locator, timeout=timeout)
from gaiatest.apps.messages.regions.message_thread import MessageThread
return MessageThread(self.marionette)
def tap_attachment(self):
self.marionette.find_element(*self._attach_button_locator).tap()
from gaiatest.apps.system.regions.activities import Activities
return Activities(self.marionette)
def tap_add_recipient(self):
self.marionette.find_element(*self._add_recipient_button_locator).tap()
contacts_app = Contacts(self.marionette)
contacts_app.switch_to_contacts_frame()
return contacts_app
def tap_options(self):
self.marionette.find_element(*self._options_button_locator).tap()
from gaiatest.apps.messages.regions.activities import Activities
return Activities(self.marionette)
def wait_for_recipients_displayed(self):
Wait(self.marionette).until(expected.element_displayed(
Wait(self.marionette).until(expected.element_present(
*self._receiver_input_locator))))
def wait_for_resizing_to_finish(self):
self.wait_for_element_not_displayed(*self._message_resize_notice_locator)
def wait_for_subject_input_displayed(self):
Wait(self.marionette).until(expected.element_displayed(
Wait(self.marionette).until(expected.element_present(
*self._subject_input_locator))))
def wait_for_message_input_displayed(self):
Wait(self.marionette).until(expected.element_displayed(
Wait(self.marionette).until(expected.element_present(
*self._message_field_locator))))
@property
def first_recipient_name(self):
element = Wait(self.marionette).until(
expected.element_present(*self._receiver_input_locator))
Wait(self.marionette).until(expected.element_displayed(element))
return element.text
@property
def number_of_recipients(self):
# we need to subtract one as the last element is the current editable element
return len(self.marionette.find_elements(*self._receiver_input_locator)) - 1
@property
def recipient_css_class(self):
return self.marionette.find_element(*self._receiver_input_locator).get_attribute('class')
@property
def is_recipient_name_editable(self):
return self.marionette.find_element(*self._receiver_input_locator).get_attribute('contenteditable')
@property
def first_recipient_number_attribute(self):
return self.marionette.find_element(*self._receiver_input_locator).get_attribute('data-number')
def tap_recipient_section(self):
self.marionette.find_element(*self._recipient_section_locator).tap()
from gaiatest.apps.keyboard.app import Keyboard
return Keyboard(self.marionette)
@property
def is_send_button_enabled(self):
return self.marionette.find_element(*self._send_message_button_locator).is_enabled()
@property
def message(self):
return self.marionette.find_element(*self._message_field_locator).text
def tap_recipient_name(self):
self.marionette.find_element(*self._receiver_input_locator).tap()
@property
def recipients(self):
return self.marionette.find_elements(*self._recipients_locator)
@property
def has_attachment(self):
return self.is_element_displayed(*self._image_attachment_locator)