当前位置: 首页>>代码示例>>Python>>正文


Python Actions.perform方法代码示例

本文整理汇总了Python中marionette.Actions.perform方法的典型用法代码示例。如果您正苦于以下问题:Python Actions.perform方法的具体用法?Python Actions.perform怎么用?Python Actions.perform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在marionette.Actions的用法示例。


在下文中一共展示了Actions.perform方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: smooth_scroll

# 需要导入模块: from marionette import Actions [as 别名]
# 或者: from marionette.Actions import perform [as 别名]
def smooth_scroll(marionette_session, start_element, axis, direction, length, increments=None, wait_period=None, scroll_back=None):
    if axis not in ["x", "y"]:
        raise Exception("Axis must be either 'x' or 'y'")
    if direction not in [-1, 0]:
        raise Exception("Direction must either be -1 negative or 0 positive")
    increments = increments or 100
    wait_period = wait_period or 0.05
    scroll_back = scroll_back or False
    current = 0
    if axis is "x":
        if direction is -1:
            offset = [-increments, 0]
        else:
            offset = [increments, 0]
    else:
        if direction is -1:
            offset = [0, -increments]
        else:
            offset = [0, increments]
    action = Actions(marionette_session)
    action.press(start_element)
    while (current < length):
        current += increments
        action.move_by_offset(*offset).wait(wait_period)
    if scroll_back:
        offset = [-value for value in offset]
        while (current > 0):
            current -= increments
            action.move_by_offset(*offset).wait(wait_period)
    action.release()
    action.perform()
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:33,代码来源:gestures.py

示例2: addAppToHomescreen

# 需要导入模块: from marionette import Actions [as 别名]
# 或者: from marionette.Actions import perform [as 别名]
    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
开发者ID:carlosmartineztoral,项目名称:OWD_TEST_TOOLKIT,代码行数:37,代码来源:addAppToHomescreen.py

示例3: wait_with_value

# 需要导入模块: from marionette import Actions [as 别名]
# 或者: from marionette.Actions import perform [as 别名]
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;"))
开发者ID:JuannyWang,项目名称:gecko-dev,代码行数:10,代码来源:single_finger_functions.py

示例4: move_element_offset

# 需要导入模块: from marionette import Actions [as 别名]
# 或者: from marionette.Actions import perform [as 别名]
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;"))
开发者ID:JuannyWang,项目名称:gecko-dev,代码行数:11,代码来源:single_finger_functions.py

示例5: move_element

# 需要导入模块: from marionette import Actions [as 别名]
# 或者: from marionette.Actions import perform [as 别名]
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;")
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:12,代码来源:single_finger_functions.py

示例6: press_release

# 需要导入模块: from marionette import Actions [as 别名]
# 或者: from marionette.Actions import perform [as 别名]
def press_release(marionette, times, wait_for_condition, expected):
    testAction = marionette.absolute_url("testAction.html")
    marionette.navigate(testAction)
    action = Actions(marionette)
    button = marionette.find_element("id", "button1")
    action.press(button).release()
    # Insert wait between each press and release chain.
    for _ in range(times-1):
        action.wait(0.1)
        action.press(button).release()
    action.perform()
    wait_for_condition(lambda m: expected in m.execute_script("return document.getElementById('button1').innerHTML;"))
开发者ID:franzks,项目名称:gecko-dev,代码行数:14,代码来源:single_finger_functions.py

示例7: test_19231

# 需要导入模块: from marionette import Actions [as 别名]
# 或者: from marionette.Actions import perform [as 别名]
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)
开发者ID:RafaMarquez,项目名称:owd_test_cases,代码行数:55,代码来源:test_19231.py

示例8: long_press_without_contextmenu

# 需要导入模块: from marionette import Actions [as 别名]
# 或者: from marionette.Actions import perform [as 别名]
def long_press_without_contextmenu(marionette_session, element, time_in_seconds, x=None, y=None):
    """
        :param element: The element to press.
        :param time_in_seconds: Time in seconds to wait before releasing the press.
        #x: Optional, x-coordinate to tap, relative to the top-left corner of the element.
        #y: Optional, y-coordinate to tap, relative to the top-leftcorner of the element.
    """
    action = Actions(marionette_session)
    action.press(element, x, y)
    action.move_by_offset(0, 0)
    action.wait(time_in_seconds)
    action.release()
    action.perform()
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:15,代码来源:gestures.py

示例9: test_main

# 需要导入模块: from marionette import Actions [as 别名]
# 或者: from marionette.Actions import perform [as 别名]
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)
开发者ID:DSanchezV,项目名称:owd_test_cases,代码行数:52,代码来源:test_26773.py

示例10: smooth_scroll

# 需要导入模块: from marionette import Actions [as 别名]
# 或者: from marionette.Actions import perform [as 别名]
def smooth_scroll(
    marionette_session, start_element, axis, direction, length, increments=None, wait_period=None, scroll_back=None
):
    """
        :param axis:  y or x
        :param direction: 0 for positive, and -1 for negative
        :param length: total length of scroll scroll
        :param increments: Amount to be moved per scrolling
        :param wait_period: Seconds to wait between scrolling
        :param scroll_back: Scroll back to original view?
    """
    if axis not in ["x", "y"]:
        raise Exception("Axis must be either 'x' or 'y'")
    if direction not in [-1, 0]:
        raise Exception("Direction must either be -1 negative or 0 positive")
    increments = increments or 100
    wait_period = wait_period or 0.05
    scroll_back = scroll_back or False
    current = 0
    if axis is "x":
        if direction is -1:
            offset = [-increments, 0]
        else:
            offset = [increments, 0]
    else:
        if direction is -1:
            offset = [0, -increments]
        else:
            offset = [0, increments]
    action = Actions(marionette_session)
    action.press(start_element)
    while current < length:
        current += increments
        action.move_by_offset(*offset).wait(wait_period)
    if scroll_back:
        offset = [-value for value in offset]
        while current > 0:
            current -= increments
            action.move_by_offset(*offset).wait(wait_period)
    action.release()
    action.perform()
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:43,代码来源:gestures.py

示例11: AppEverythingMe

# 需要导入模块: from marionette import Actions [as 别名]
# 或者: from marionette.Actions import perform [as 别名]
class AppEverythingMe(GaiaTestCase):
    
    #
    # When you create your instance of this class, include the
    # "self" object so we can access the calling class' objects.
    #
    def __init__(self, p_parent):
        self.apps       = p_parent.apps
        self.data_layer = p_parent.data_layer
        self.marionette = p_parent.marionette
        self.UTILS      = p_parent.UTILS
        self.actions    = Actions(self.marionette)
                


    def launch(self):
        #
        # Go to the homescreen.
        #
        self.UTILS.goHome()
        
        #
        # Scroll to the left to expose the 'everything.me' screen.
        #
        self.UTILS.scrollHomescreenLeft()
        self.UTILS.waitForElements(DOM.EME.groups, "EME groups", True, 30)

    def searchForApp(self, p_name):
        #
        # Uses the search field to find the app (waits for the
        # result to appear etc...).<br>
        # Returns the element for the icon (or False if it's not found).
        #
        self.UTILS.typeThis(DOM.EME.search_field, "Search field", p_name, p_no_keyboard=True)
        
        boolOK = True
        
        try:
            self.wait_for_element_displayed("xpath", 
                                            DOM.EME.search_result_icon_xpath % p_name,
                                            timeout=60)
        except:
            boolOK = False
            
        return boolOK

    def pickGroup(self, p_name):
        #
        # Pick a group from the main icons.
        #
        x = self.UTILS.getElements(DOM.EME.groups, "EME group list")
        boolOK = False
        for groupLink in x:
            if groupLink.get_attribute("data-query") == p_name:
                groupLink.tap()
                time.sleep(10)
                boolOK = True
                break
        
        #
        # At this point the geolocation sometimes wants to know
        # if it can remember our location.
        #
        self.UTILS.clearGeolocPermission()
        
        return boolOK
    
    def removeGroup(self, p_group):
        #
        # Removes a group from the EME group page.
        #
        x = self.UTILS.getElements(DOM.EME.groups, "Groups")
        boolOK  = False
        iconPos = -1
        counter = -1
        for i in x:
            counter = counter + 1
            if i.get_attribute("data-query") == p_group:
                boolOK = True
                
                #
                # Long press to activate edit mode.
                #
                self.actions.press(i).wait(2).release()
                self.actions.perform()
                
                iconPos = counter
                break
        
        #
        # If the group was present, remove it.
        #
        if boolOK:
            self.UTILS.logResult("info", "(Removing group '" + p_group + "'.)")
            x = self.UTILS.getElements(DOM.EME.groups, "Groups")[iconPos]
            y = x.find_element(*DOM.EME.remove_group_icon)
            y.tap()
            
            #
            # Disactivate edit mode  (just tap the search field).
#.........这里部分代码省略.........
开发者ID:RafaMarquez,项目名称:OWD_TEST_TOOLKIT,代码行数:103,代码来源:app_everythingMe.py


注:本文中的marionette.Actions.perform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。