本文整理汇总了Python中marionette_driver.marionette.Actions.long_press方法的典型用法代码示例。如果您正苦于以下问题:Python Actions.long_press方法的具体用法?Python Actions.long_press怎么用?Python Actions.long_press使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marionette_driver.marionette.Actions
的用法示例。
在下文中一共展示了Actions.long_press方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: long_press_action
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import long_press [as 别名]
def long_press_action(marionette, wait_for_condition, expected):
testAction = marionette.absolute_url("testAction.html")
marionette.navigate(testAction)
button = marionette.find_element(By.ID, "button1")
action = Actions(marionette)
action.long_press(button, 5).perform()
wait_for_condition_else_raise(marionette, wait_for_condition, expected, "return document.getElementById('button1').innerHTML;")
示例2: long_press_on_xy_action
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import long_press [as 别名]
def long_press_on_xy_action(marionette, wait_for_condition, expected):
testAction = marionette.absolute_url("testAction.html")
marionette.navigate(testAction)
html = marionette.find_element(By.TAG_NAME, "html")
button = marionette.find_element(By.ID, "button1")
action = Actions(marionette)
# Press the center of the button with respect to html.
x = button.rect['x'] + button.rect['width'] / 2.0
y = button.rect['y'] + button.rect['height'] / 2.0
action.long_press(html, 5, x, y).perform()
wait_for_condition_else_raise(marionette, wait_for_condition, expected, "return document.getElementById('button1').innerHTML;")
示例3: test_main
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import long_press [as 别名]
class test_main(GaiaTestCase):
def setUp(self):
# Set up child objects...
GaiaTestCase.setUp(self)
self.UTILS = UTILS(self)
self.messages = Messages(self)
self.actions = Actions(self.marionette)
# Establish which phone number to use.
self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom")
self.incoming_sms_num = self.UTILS.general.get_config_variable("sms_platform_numbers", "common").split(',')
self.UTILS.reporting.logComment("Sending sms to telephone number " + self.phone_number)
self.data_layer.delete_all_sms()
def tearDown(self):
self.UTILS.reporting.reportResults()
GaiaTestCase.tearDown(self)
def test_run(self):
self.UTILS.statusbar.clearAllStatusBarNotifs()
timestamp = " {}".format(time.time())
sms_message = "0123456789" * 5 + timestamp
self.UTILS.reporting.logComment("Message length sent: {}".format((len(sms_message))))
self.UTILS.messages.create_incoming_sms(self.phone_number, sms_message)
self.UTILS.statusbar.wait_for_notification_toaster_detail(timestamp, timeout=120)
title = self.UTILS.statusbar.wait_for_notification_toaster_with_titles(self.incoming_sms_num, timeout=5)
self.UTILS.statusbar.click_on_notification_title(title, DOM.Messages.frame_locator)
# Open sms option with longtap on it
self.UTILS.reporting.logResult("info", "Open sms option with longtap on it")
sms = self.messages.last_message_in_this_thread()
body = self.marionette.find_element(*DOM.Messages.last_message_body, id=sms.id)
self.actions.long_press(body, 2).perform()
# Press cancel button
self.UTILS.reporting.logResult("info", "Clicking cancel button")
time.sleep(2)
cancel_btn = self.UTILS.element.getElement(DOM.Messages.cancel_btn_msg_opt, "Cancel button is displayed")
self.UTILS.reporting.debug("*** Cancel button: {} text: {}".format(cancel_btn, cancel_btn.text))
self.UTILS.element.simulateClick(cancel_btn)
示例4: test_main
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import long_press [as 别名]
class test_main(GaiaTestCase):
def setUp(self):
# Set up child objects...
GaiaTestCase.setUp(self)
self.UTILS = UTILS(self)
self.messages = Messages(self)
self.contacts = Contacts(self)
self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom")
self.emailAddy = self.UTILS.general.get_config_variable("gmail_1_email", "common")
self.test_msg = "Hello {} old bean at {}.".format(self.emailAddy, time.time())
def tearDown(self):
self.UTILS.reporting.reportResults()
GaiaTestCase.tearDown(self)
def test_run(self):
# Launch messages app.
self.messages.launch()
# Create and send a new test message.
self.messages.create_and_send_sms([self.phone_number], self.test_msg)
send_time = self.messages.last_sent_message_timestamp()
msg = self.messages.wait_for_message(send_time=send_time)
self.messages.check_last_message_contents(self.test_msg)
# Tap on edit mode.
edit_btn = self.UTILS.element.getElement(DOM.Messages.edit_messages_icon, "Edit button")
edit_btn.tap()
select_btn = self.UTILS.element.getElement(DOM.Messages.edit_msgs_select_btn, "Select button")
select_btn.tap()
# Long press the email link.
_link = msg.find_element("tag name", "a")
self.actions = Actions(self.marionette)
self.actions.long_press(_link, 2).perform()
# Check the email address is not a link in edit mode.
self.UTILS.element.waitForNotElements(DOM.Messages.header_create_new_contact_btn, "Create new contact button")
示例5: test_main
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import long_press [as 别名]
class test_main(GaiaTestCase):
def __init__(self, *args, **kwargs):
kwargs['restart'] = True
super(test_main, self).__init__(*args, **kwargs)
def setUp(self):
# Set up child objects...
GaiaTestCase.setUp(self)
self.UTILS = UTILS(self)
self.settings = Settings(self)
self.EME = EverythingMe(self)
self.actions = Actions(self.marionette)
try:
self.apps.set_permission('Homescreen', 'geolocation', 'deny')
self.apps.set_permission('Smart Collections', 'geolocation', 'deny')
except:
self.UTILS.reporting.logComment("Unable to automatically set geolocation permission.")
def tearDown(self):
# Restart device to restore collections
self.device.restart_b2g()
GaiaTestCase.setUp(self)
self.UTILS.reporting.reportResults()
GaiaTestCase.tearDown(self)
def test_run(self):
self.UTILS.iframe.switchToFrame(*DOM.Home.frame_locator)
categories = self.UTILS.element.getElements(DOM.EME.all_collections, "All collections")
for cat in categories:
name = self.marionette.find_element('css selector', 'span.title', cat.id).text
self.UTILS.reporting.debug("** Removing collection: {}".format(name))
self.actions.long_press(cat, 2).perform()
delete_btn = ("xpath", DOM.Home.app_delete_icon_xpath.format(name))
delete_button = self.UTILS.element.getElement(delete_btn, "Delete button", False, 30, True)
delete_button.tap()
delete = self.UTILS.element.getElement(DOM.Home.app_confirm_delete, "Confirm app delete button")
delete.tap()
self.UTILS.element.waitForNotElements(DOM.EME.all_collections, "All collections", timeout=10)
示例6: EverythingMe
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import long_press [as 别名]
class EverythingMe(object):
def __init__(self, p_parent):
self.apps = p_parent.apps
self.data_layer = p_parent.data_layer
self.parent = p_parent
self.marionette = p_parent.marionette
self.UTILS = p_parent.UTILS
self.actions = Actions(self.marionette)
def launch(self):
self.apps.kill_all()
# If EME has already been launched, then the DOM has changed.
self.UTILS.reporting.logResult("info", "Launching Everything ME.")
boolOK = False
try:
self.parent.wait_for_element_displayed(*DOM.EME.start_eme_icon, timeout=1)
x = self.marionette.find_element(*DOM.EME.start_eme_icon)
x.tap()
boolOK = True
except:
self.UTILS.reporting.logResult("info", "Everything ME is already 'running', so just waking it up ...")
self._relaunch()
try:
self.parent.wait_for_element_displayed(*DOM.EME.groups, timeout=3)
except:
self._relaunch()
boolOK = True
self.UTILS.test.test(boolOK, "EME Starting up ...")
def _relaunch(self):
"""
Private function to re-launch.
This gets complicated:
1. el.tap() and el.click() only work *sometimes*, so use the keyboard to relaunch.
2. Sometimes the messges app randomly launches instead of evme!
"""
x = self.marionette.find_element(*DOM.EME.search_field)
x.send_keys("waking up evme")
x = self.marionette.find_element(*DOM.EME.search_clear)
x.tap()
def add_app_to_homescreen(self, name):
"""
Pick an app from the apps listed in this group.
"""
x = self.UTILS.element.getElementByXpath(DOM.EME.app_to_install.format(name))
app_name = x.text
self.UTILS.reporting.logResult("debug", "icon displayed: {}".format(x.is_displayed()))
time.sleep(2)
self.UTILS.test.test(app_name == name, "" + app_name + "'is the correct app", True)
self.actions.long_press(x, 2).perform()
x = self.UTILS.element.getElement(DOM.EME.add_to_homescreen_btn, "Add app to homescreen button")
x.tap()
time.sleep(2)
return True
def add_group(self, group):
"""
Adds a group to EME (assumes you're already in the EME group screen).
"""
self.UTILS.reporting.logResult("info", "(Adding group '" + group + "'.)")
# Click the 'More' icon.
x = self.UTILS.element.getElement(DOM.EME.add_group_button, "'More' icon")
x.tap()
# Wait for the 'loading' spinner to go away (can take a while!).
self.UTILS.element.waitForNotElements(DOM.EME.loading_groups_message, "'Loading' message", True, 120)
# Chose an item from the groups list...
self.UTILS.general.selectFromSystemDialog(group)
# Verify the new group is in the groups list.
x = self.UTILS.element.getElements(DOM.EME.groups, "Groups")
boolOK = False
for i in x:
if i.get_attribute("data-query") == group:
boolOK = True
break
self.UTILS.test.test(boolOK, "New group '" + group + "' is now present in the EME groups.")
return boolOK
def add_multiple_groups(self, group_array=False):
"""
Adds multiple groups based on an array of numbers (defaults to all available groups).
<br><br>
For example: add_multiple_groups([0,1,2,3,8,11]) ... or just: add_multiple_groups()
"""
x = self.UTILS.element.getElement(DOM.EME.add_group_button, "'More' icon")
x.tap()
self.UTILS.element.waitForNotElements(DOM.EME.loading_groups_message, "'Loading' message", True, 120)
#.........这里部分代码省略.........
示例7: Dialer
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import long_press [as 别名]
#.........这里部分代码省略.........
self.open_call_log()
self.callLog_long_tap(entry)
self.callLog_long_tap_select_action(
DOM.Dialer.call_log_numtap_create_new, "Create new contact button", call_info=True)
self.UTILS.iframe.switchToFrame(*DOM.Contacts.frame_locator)
self.UTILS.element.waitForElements(DOM.Contacts.add_contact_header, "'Add contact' header")
def callLog_addToContact(self, phone_number, contact_name, p_open_call_log=True, cancel_process=False):
"""
Adds this number in the call log to an existing contact
(and returns you to the call log).
If p_open_call_log is set to False it will assume you are
already in the call log.
"""
if p_open_call_log:
self.open_call_log()
self.callLog_long_tap(phone_number)
time.sleep(1)
self.callLog_long_tap_select_action(
DOM.Dialer.call_log_numtap_add_to_existing, "Add to existing contact button", call_info=True)
if cancel_process:
self._cancel_addNumberToContact()
else:
self._complete_addNumberToContact(phone_number, contact_name)
def callLog_long_tap(self, phone_number):
entry = self.UTILS.element.getElement(("xpath", DOM.Dialer.call_log_number_xpath.format(phone_number)),
"The call log for number {}".format(phone_number))
self.actions.long_press(entry, 3).perform()
def callLog_long_tap_select_action(self, locator, msg="Option chosen", call_info=True):
if call_info:
call_info = self.UTILS.element.getElement(DOM.Dialer.call_log_numtap_call_info, "Call information button")
call_info.tap()
option = self.UTILS.element.getElement(locator, msg, True, 10)
option.tap()
def callLog_call(self, p_num):
own_num = self.UTILS.general.get_config_variable("phone_number", "custom")
# Calls a number from the call log.
try:
self.parent.wait_for_element_displayed(*DOM.Dialer.call_log_filter, timeout=1)
except:
self.open_call_log()
entry = self.UTILS.element.getElement(("xpath", DOM.Dialer.call_log_number_xpath.format(p_num)),
"The call log for number {}".format(p_num))
entry.tap()
if own_num == p_num:
time.sleep(2)
# self.marionette.switch_to_frame()
x = self.UTILS.element.getElement(DOM.Dialer.call_busy_button_ok, "OK button (callLog_call)")
x.tap()
else:
time.sleep(1)
self.UTILS.iframe.switchToFrame(*DOM.Dialer.frame_locator_calling)
self.UTILS.element.waitForElements(("xpath", DOM.Dialer.outgoing_call_numberXP.format(p_num)),
"Outgoing call found with number matching {}".format(p_num))
示例8: Messages
# 需要导入模块: from marionette_driver.marionette import Actions [as 别名]
# 或者: from marionette_driver.marionette.Actions import long_press [as 别名]
#.........这里部分代码省略.........
boolKBD, "Keyboard is displayed when 'To' field is clicked for the first time")
self.UTILS.iframe.switchToFrame(*DOM.Messages.frame_locator)
if n == 0:
self.UTILS.general.typeThis(DOM.Messages.target_numbers_empty,
"Target number field",
num,
p_no_keyboard=True,
p_validate=False,
p_clear=False,
p_enter=True)
else:
self.UTILS.general.typeThis(DOM.Messages.target_numbers_empty,
"Target number field",
num,
p_no_keyboard=True,
p_validate=False,
p_clear=False,
p_enter=False)
input_area = self.UTILS.element.getElement(DOM.Messages.input_message_area, "Target number field")
input_area.tap()
n += 1
def addContactToField(self, contact_name):
self._search_for_contact(contact_name)
# Now check the correct name is in the 'To' list.
self.checkIsInToField(contact_name)
def _select_forward_option_for(self, element):
self.actions.long_press(element, 2).perform()
self.UTILS.reporting.logResult("info", "Clicking on forward button")
forward_option = self.UTILS.element.getElement(DOM.Messages.forward_btn_msg_opt, "Forward button is displayed")
forward_option.tap()
def _search_for_contact(self, contact_name):
self.contacts = Contacts(self.parent)
self.selectAddContactButton()
self.UTILS.iframe.switchToFrame(*DOM.Contacts.frame_locator)
self.contacts.search(contact_name)
self.contacts.check_search_results(contact_name)
results = self.UTILS.element.getElements(DOM.Contacts.search_results_list, "Contacts search results")
for result in results:
if result.text == contact_name:
result.tap()
break
# Switch back to the sms iframe.
self.apps.switch_to_displayed_app()
def forwardMessage(self, msg_type, target_telNum):
"""
Forwards the last message of the thread to a number
"""
self.UTILS.reporting.logResult('info', "The message type to forward is: {}".format(msg_type))
if msg_type == "sms" or msg_type == "mms":
self.UTILS.reporting.logResult("info", "Open {} option with longtap on it".format(msg_type))
last = self.last_message_in_this_thread()
body = self.marionette.find_element(*DOM.Messages.last_message_body, id=last.id)