本文整理汇总了Python中marionette.Actions类的典型用法代码示例。如果您正苦于以下问题:Python Actions类的具体用法?Python Actions怎么用?Python Actions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Actions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: double_tap
def double_tap(marionette, wait_for_condition, expected):
testAction = marionette.absolute_url("testAction.html")
marionette.navigate(testAction)
button = marionette.find_element("id", "button1")
action = Actions(marionette)
action.double_tap(button).perform()
wait_for_condition(lambda m: expected in m.execute_script("return document.getElementById('button1').innerHTML;"))
示例2: long_press_action
def long_press_action(marionette, wait_for_condition, expected):
testAction = marionette.absolute_url("testAction.html")
marionette.navigate(testAction)
button = marionette.find_element("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;")
示例3: addAppToHomescreen
def addAppToHomescreen(self, p_name):
#
# Pick an app from the apps listed in this group.
#
x = self.UTILS.getElements(DOM.EME.apps, "Apps list", True, 30)
for appLink in x:
if appLink.get_attribute("data-name") == p_name:
from marionette import Actions
actions = Actions(self.marionette)
actions.press(appLink).wait(2).release()
actions.perform()
self.marionette.switch_to_frame()
x = self.UTILS.getElement(DOM.EME.add_app_to_homescreen, "Add app to homescreen button")
x.tap()
#
# Might need to do this again for Geoloc. ...
#
try:
x = self.marionette.find_element(*DOM.EME.add_app_to_homescreen)
x.tap()
except:
pass
# This isn't obvious, but you need to scroll the screen right
# to reset the position for finding the app later, so I'm
# doing it here.
time.sleep(2)
self.UTILS.goHome()
self.UTILS.scrollHomescreenRight()
return True
return False
示例4: scroll
def scroll(self):
action = Actions(self.marionette)
for page in self.marionette.find_elements(By.CSS_SELECTOR,
'#icongrid > div')[:-1]:
self.logger.debug('Swiping to next page of apps')
action.flick(
page,
page.size['width'] / 100 * 90,
page.size['width'] / 2,
page.size['width'] / 100 * 10,
page.size['width'] / 2, 200).perform()
MarionetteWait(self.marionette, 30).until(
lambda m: page.get_attribute('aria-hidden') or
not page.is_displayed())
for page in reversed(self.marionette.find_elements(
By.CSS_SELECTOR, '#icongrid > div')[1:]):
MarionetteWait(self.marionette, 30).until_not(
lambda m: page.get_attribute('aria-hidden') or
not page.is_displayed())
self.logger.debug('Swiping to previous page of apps')
action.flick(
page,
page.size['width'] / 100 * 10,
page.size['width'] / 2,
page.size['width'] / 100 * 90,
page.size['width'] / 2, 200).perform()
示例5: scroll
def scroll(self):
action = Actions(self.marionette)
for page in self.marionette.find_elements(By.CSS_SELECTOR, "#icongrid > div")[:-1]:
self.logger.debug("Swiping to next page of apps")
action.flick(
page,
page.size["width"] / 100 * 90,
page.size["width"] / 2,
page.size["width"] / 100 * 10,
page.size["width"] / 2,
200,
).perform()
Wait(self.marionette, timeout=30).until(
lambda m: page.get_attribute("aria-hidden") or not page.is_displayed()
)
for page in reversed(self.marionette.find_elements(By.CSS_SELECTOR, "#icongrid > div")[1:]):
Wait(self.marionette, timeout=30).until(
lambda m: page.is_displayed() or not page.get_attribute("aria-hidden")
)
self.logger.debug("Swiping to previous page of apps")
action.flick(
page,
page.size["width"] / 100 * 10,
page.size["width"] / 2,
page.size["width"] / 100 * 90,
page.size["width"] / 2,
200,
).perform()
示例6: wait_with_value
def wait_with_value(marionette, wait_for_condition, expected):
testAction = marionette.absolute_url("testAction.html")
marionette.navigate(testAction)
button = marionette.find_element("id", "button1")
action = Actions(marionette)
action.press(button).wait(0.01).release()
action.perform()
wait_for_condition(lambda m: expected in m.execute_script("return document.getElementById('button1').innerHTML;"))
示例7: chain_flick
def chain_flick(marionette, wait_for_condition, expected1, expected2):
testAction = marionette.absolute_url("testAction.html")
marionette.navigate(testAction)
button = marionette.find_element("id", "button1")
action = Actions(marionette)
action.flick(button, 0, 0, 0, 200).perform()
wait_for_condition(lambda m: expected1 in m.execute_script("return document.getElementById('button1').innerHTML;"))
wait_for_condition(lambda m: expected2 in m.execute_script("return document.getElementById('buttonFlick').innerHTML;"))
示例8: move_element_offset
def move_element_offset(marionette, wait_for_condition, expected1, expected2):
testAction = marionette.absolute_url("testAction.html")
marionette.navigate(testAction)
ele = marionette.find_element("id", "button1")
action = Actions(marionette)
action.press(ele).move_by_offset(0,150).move_by_offset(0, 150).release()
action.perform()
wait_for_condition(lambda m: expected1 in m.execute_script("return document.getElementById('button1').innerHTML;"))
wait_for_condition(lambda m: expected2 in m.execute_script("return document.getElementById('button2').innerHTML;"))
示例9: context_menu
def context_menu(marionette, wait_for_condition, expected1, expected2):
testAction = marionette.absolute_url("testAction.html")
marionette.navigate(testAction)
button = marionette.find_element("id", "button1")
action = Actions(marionette)
action.press(button).wait(5).perform()
wait_for_condition_else_raise(marionette, wait_for_condition, expected1, "return document.getElementById('button1').innerHTML;")
action.release().perform()
wait_for_condition_else_raise(marionette, wait_for_condition, expected2, "return document.getElementById('button1').innerHTML;")
示例10: move_element
def move_element(marionette, wait_for_condition, expected1, expected2):
testAction = marionette.absolute_url("testAction.html")
marionette.navigate(testAction)
ele = marionette.find_element("id", "button1")
drop = marionette.find_element("id", "button2")
action = Actions(marionette)
action.press(ele).move(drop).release()
action.perform()
wait_for_condition_else_raise(marionette, wait_for_condition, expected1, "return document.getElementById('button1').innerHTML;")
wait_for_condition_else_raise(marionette, wait_for_condition, expected2, "return document.getElementById('button2').innerHTML;")
示例11: chain
def chain(marionette, wait_for_condition, expected1, expected2):
testAction = marionette.absolute_url("testAction.html")
marionette.navigate(testAction)
marionette.set_search_timeout(15000)
action = Actions(marionette)
button1 = marionette.find_element("id", "button1")
action.press(button1).perform()
button2 = marionette.find_element("id", "delayed")
wait_for_condition(lambda m: expected1 in m.execute_script("return document.getElementById('button1').innerHTML;"))
action.move(button2).release().perform()
wait_for_condition(lambda m: expected2 in m.execute_script("return document.getElementById('delayed').innerHTML;"))
示例12: long_press_on_xy_action
def long_press_on_xy_action(marionette, wait_for_condition, expected):
testAction = marionette.absolute_url("testAction.html")
marionette.navigate(testAction)
html = marionette.find_element("tag name", "html")
button = marionette.find_element("id", "button1")
action = Actions(marionette)
# Press the center of the button with respect to html.
x = button.location['x'] + button.size['width'] / 2.0
y = button.location['y'] + button.size['height'] / 2.0
action.long_press(html, 5, x, y).perform()
wait_for_condition(lambda m: expected in m.execute_script("return document.getElementById('button1').innerHTML;"))
示例13: test_19231
class test_19231(GaiaTestCase):
_Description = "[HOME SCREEN] Verify that the user can uninstall a everything.me app through the grid edit mode."
_appName = "Wikipedia"
def setUp(self):
#
# Set up child objects...
#
GaiaTestCase.setUp(self)
self.UTILS = UTILS(self)
self.actions = Actions(self.marionette)
self.settings = AppSettings(self)
# self.market = AppMarket(self)
self.eme = AppEverythingMe(self)
#
#
def tearDown(self):
self.UTILS.reportResults()
def test_run(self):
#
# Get a conection.
#
self.UTILS.getNetworkConnection()
self.UTILS.uninstallApp(self._appName)
#
# Get the app.
#
self.eme.launch()
x = self.eme.searchForApp(self._appName)
self.UTILS.TEST(x, "Icon for " + self._appName + " is found.", True)
x = self.UTILS.getElement( ("xpath", DOM.EME.search_result_icon_xpath % self._appName),
self._appName + " icon")
self.actions.press(x).wait(2).release()
self.actions.perform()
self.marionette.switch_to_frame()
x = self.UTILS.getElement(DOM.GLOBAL.modal_ok_button, "OK button")
x.tap()
time.sleep(2)
self.UTILS.goHome()
self.UTILS.uninstallApp(self._appName)
示例14: test_main
class test_main(GaiaTestCase):
_appName = "Wikipedia"
def setUp(self):
#
# Set up child objects...
#
GaiaTestCase.setUp(self)
self.UTILS = UTILS(self)
self.actions = Actions(self.marionette)
self.settings = Settings(self)
self.eme = EverythingMe(self)
def tearDown(self):
self.UTILS.reportResults()
def test_run(self):
#
# Get a conection.
#
self.UTILS.getNetworkConnection()
self.UTILS.uninstallApp(self._appName)
#
# Get the app.
#
self.eme.launch()
x = self.eme.searchForApp(self._appName)
self.UTILS.TEST(x, "Icon for " + self._appName + " is found.", True)
#
# Long-press the app to install it to the homescreen.
#
x = self.UTILS.getElement( ("xpath", DOM.EME.search_result_icon_xpath % self._appName),
self._appName + " icon")
self.actions.press(x).wait(2).release()
self.actions.perform()
self.marionette.switch_to_frame()
x = self.UTILS.getElement(DOM.GLOBAL.modal_ok_button1, "OK button")
x.tap()
time.sleep(2)
self.UTILS.goHome()
self.UTILS.uninstallApp(self._appName)
示例15: scroll_app
def scroll_app(self, app_name):
touch_duration = float(200)
apps = gaiatest.GaiaApps(self.marionette)
#wait up to 30secs for the elements we want to show up
self.marionette.set_search_timeout(30000)
if app_name == 'Homescreen':
action = Actions(self.marionette)
landing_page = self.marionette.find_element('id', 'landing-page')
action.flick(
landing_page,
landing_page.size['width'] / 100 * 90,
landing_page.size['width'] / 2,
landing_page.size['width'] / 100 * 10,
landing_page.size['width'] / 2, touch_duration).perform()
first_page = self.marionette.find_elements('css selector', '.page')[0]
action.flick(
first_page,
first_page.size['width'] / 100 * 10,
first_page.size['width'] / 2,
first_page.size['width'] / 100 * 90,
first_page.size['width'] / 2, touch_duration).perform()
elif app_name == 'Contacts':
name = self.marionette.find_element("css selector", ".contact-item p > strong")
MarionetteWait(self.marionette, 30).until(lambda m: name.is_displayed())
smooth_scroll(self.marionette, name, "y", -1, 5000, scroll_back=False)
elif app_name == 'Browser':
self.marionette.execute_script("return window.wrappedJSObject.Browser.navigate('http://taskjs.org/');", new_sandbox=False)
MarionetteWait(self.marionette, 30).until(lambda m: 'http://taskjs.org/' == m.execute_script('return window.wrappedJSObject.Browser.currentTab.url;', new_sandbox=False))
MarionetteWait(self.marionette, 30).until(lambda m: not m.execute_script('return window.wrappedJSObject.Browser.currentTab.loading;', new_sandbox=False))
# check when the tab's document is ready
tab_frame = self.marionette.execute_script("return window.wrappedJSObject.Browser.currentTab.dom;")
self.marionette.switch_to_frame(tab_frame)
MarionetteWait(self.marionette, 30).until(lambda m: m.execute_script('return window.document.readyState;', new_sandbox=False) == 'complete')
# we have to fire smooth_scroll from the browser app, so let's go back
self.marionette.switch_to_frame()
apps.launch(app_name) # since the app is launched, launch will switch us back to the app frame without relaunching
tab_dom = self.marionette.execute_script("return window.wrappedJSObject.Browser.currentTab.dom;", new_sandbox=False)
smooth_scroll(self.marionette, tab_dom, "y", -1, 5000, scroll_back=True)
elif app_name == 'Email':
email = self.marionette.find_element("class name", "msg-header-author")
MarionetteWait(self.marionette, 30).until(lambda m: email.is_displayed() or not email.get_attribute('hidden'))
emails = self.marionette.find_elements("class name", "msg-header-author")
#we're dynamically adding these elements from a template, and the first one found is blank.
MarionetteWait(self.marionette, 30).until(lambda m: emails[0].get_attribute('innerHTML'))
emails = self.marionette.find_elements("class name", "msg-header-author")
smooth_scroll(self.marionette, emails[0], "y", -1, 2000, scroll_back=True)