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


Python ActionChains.move_to_element_with_offset方法代码示例

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


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

示例1: drag

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element_with_offset [as 别名]
 def drag(self, x_offset, y_offset):
     center = self.driver.execute_script(GetScripts.getContainerCenter)
     actions = ActionChains(self.driver)
     actions.move_to_element_with_offset(self.element, int(center['x']), int(center['y']))
     actions.click_and_hold()
     actions.move_by_offset(x_offset, y_offset)
     actions.release().perform()
开发者ID:2gis,项目名称:mapsapi,代码行数:9,代码来源:map.py

示例2: put_element_on_grid

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element_with_offset [as 别名]
    def put_element_on_grid(self, type_str):
        '''find 'type_str' in the Library, drag and drop it onto the grid'''
        browser = self.browser

        grid = browser.find_element_by_xpath('//div[@id="-dataflow"]')

        for retry in range(3):
            try:
                objtype = self.find_library_button(type_str)
                chain = ActionChains(browser)
                chain.click_and_hold(objtype)
                chain.move_to_element_with_offset(grid, 10, 10).perform()
            except StaleElementReferenceException:
                if retry < 2:
                    logging.warning('put_element_on_grid %s:'
                                    ' StaleElementReferenceException', type_str)
                else:
                    raise
            else:
                break

        self.check_highlighting(grid, True, "Grid")
        self.release(chain)

        # deal with the modal dialog
        name = NameInstanceDialog(self).create_and_dismiss()

        # make sure it is on the grid
        self.ensure_names_in_workspace([name],
            "Dragging '" + type_str +
            "' to grid did not produce a new element on page")

        return name
开发者ID:Daiyu506,项目名称:OpenMDAO-Framework,代码行数:35,代码来源:workspace.py

示例3: click_img

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element_with_offset [as 别名]
    def click_img(self, answer, height, identify_img_xpath1=None,
                  identify_button_xpath=None):
        """
        根据打码返回的坐标进行点击操作
        仅适用与点击型验证码

        :param answer: 打码返回结果
        :param height: 答案高度
        :param identify_img_xpath1: 题目xpath
        :param identify_button_xpath: 验证按钮
        :return:
        """
        actions = ActionChains(self.driver)
        img = self.driver.find_element_by_xpath(identify_img_xpath1)
        points = answer.split('|')
        for point in points:
            x, y = eval(point)
            actions.move_to_element_with_offset(
                img, x, y - int((height / self.device_pixel_ratio)))
            actions.click()
        actions.perform()
        time.sleep(2)
        if not identify_button_xpath:
            return
        self.driver.find_element_by_xpath(identify_button_xpath).click()
开发者ID:wuyue92tree,项目名称:crwy,代码行数:27,代码来源:selenium_api.py

示例4: like_post

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element_with_offset [as 别名]
 def like_post(self):
     no_likes_title = self.driver.find_elements_by_xpath(NO_LIKES_TITLE)
     # Check if post have some likes
     if len(no_likes_title) < 1:
         likes_counter = self.driver.find_element_by_xpath(LIKES_COUNTER)
         likes_counter.click()
         print('Post likes amount - %s' % likes_counter.text)
         liked_counter_value = int(likes_counter.text) + 1
         action = ActionChains(self.driver)
         action.move_to_element_with_offset(likes_counter, 0, -20).click().perform()
         print('User taps on like button')
         print('Checking if likes counter is updated...')
         print('Post new likes amount - %s' % likes_counter.text)
         self.assertIn(str(liked_counter_value), likes_counter.text)
     else:
         no_likes_text = self.driver.find_element_by_xpath(NO_LIKES_TITLE)
         no_likes_view = self.driver.find_element_by_xpath(NO_LIKES_VIEW)
         print('Nobody likes this post')
         print(no_likes_text.text)
         no_likes_view.click()
         print('User scrolls to likes block')
         action = ActionChains(self.driver)
         print('User taps on like button')
         action.move_to_element_with_offset(no_likes_text, -10, 0).click().perform()
         print('Checking if likes counter is updated...')
         self.driver.implicitly_wait(5)
         likes_counter = self.driver.find_element_by_xpath(LIKES_COUNTER)
         print('Post new likes amount - %s' % likes_counter.text)
开发者ID:RomanBegun,项目名称:bkstg_mobile,代码行数:30,代码来源:card_page.py

示例5: add_library_item_to_dataflow

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element_with_offset [as 别名]
    def add_library_item_to_dataflow(self, item_name, instance_name, check=True, offset=None, prefix=None):
        """ Add component `item_name`, with name `instance_name`. """
        library_item = self.get_library_item(item_name)

        target = WebDriverWait(self.browser, TMO).until(
            lambda browser: browser.find_element_by_xpath("//*[@id='-dataflow']")
        )

        offset = offset or (90, 90)
        chain = ActionChains(self.browser)
        if False:
            chain.drag_and_drop(library_item, target)
        else:
            chain.click_and_hold(library_item)
            chain.move_to_element_with_offset(target, offset[0], offset[1])
            chain.release(None)
        chain.perform()

        page = ValuePrompt(self.browser, self.port)
        page.set_value(instance_name)
        # Check that the prompt is gone so we can distinguish a prompt problem
        # from a dataflow update problem.
        time.sleep(0.25)
        self.browser.implicitly_wait(1)  # We don't expect to find anything.
        try:
            eq(len(self.browser.find_elements(*page("prompt")._locator)), 0)
        finally:
            self.browser.implicitly_wait(TMO)

        retval = None
        if check:  # Check that it's been added.
            retval = WebDriverWait(self.browser, TMO).until(
                lambda browser: self.get_dataflow_figure(instance_name, prefix)
            )
        return retval
开发者ID:RacerXFD,项目名称:OpenMDAO-Framework,代码行数:37,代码来源:workspace.py

示例6: clear

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element_with_offset [as 别名]
 def clear(self):
     """ Clear the workflow. """
     chain = ActionChains(self.browser)
     chain.move_to_element_with_offset(self.flow, 5, 5)
     chain.context_click(None)
     chain.perform()
     time.sleep(0.5)
     self('clear_button').click()
开发者ID:akhi28,项目名称:OpenMDAO-Framework,代码行数:10,代码来源:workflow.py

示例7: close_slider

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element_with_offset [as 别名]
 def close_slider(self, by_area=0):
     if by_area:
         btn_close = self.driver.find_element_by_class_name(self.CLOSE_AREA)
         actions = ActionChains(self.driver)
         actions.move_to_element_with_offset(btn_close, 0, 0).click().perform()
     else:
         btn_close = self.driver.find_element_by_class_name(self.CLOSE_CLASS)
         btn_close.click()
开发者ID:AlexandraSmirnova,项目名称:homework-4,代码行数:10,代码来源:pages.py

示例8: flip

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element_with_offset [as 别名]
 def flip(self):
     """ Flip the workflow from horizontal to vertical or vice versa. """
     chain = ActionChains(self.browser)
     chain.move_to_element_with_offset(self.flow, 5, 5)
     chain.context_click(None)
     chain.perform()
     time.sleep(0.5)
     self('flip_button').click()
开发者ID:akhi28,项目名称:OpenMDAO-Framework,代码行数:10,代码来源:workflow.py

示例9: show_connected_variables

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element_with_offset [as 别名]
 def show_connected_variables(self):
     """ Show only the connected variables. """
     chain = ActionChains(self.browser)
     chain.move_to_element_with_offset(self.connections_pane, 5, 5)
     chain.context_click(None)
     chain.perform()
     time.sleep(0.5)
     self('show_connected_button').click()
开发者ID:FashtimeDotCom,项目名称:OpenMDAO-Framework,代码行数:10,代码来源:connections.py

示例10: clicketi_click_list_row

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element_with_offset [as 别名]
def clicketi_click_list_row(context, item):
    """
    This is a special clicketi click for list items that might not be clickable
    in the middle.
    """
    action_chain = ActionChains(context.browser)
    action_chain.move_to_element_with_offset(item, item.size['width'] / 4, item.size['height'] / 2)
    action_chain.click()
    action_chain.perform()
开发者ID:mistio,项目名称:mist.tests,代码行数:11,代码来源:buttons.py

示例11: zoom_selection

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element_with_offset [as 别名]
 def zoom_selection(self):
     center = self.driver.execute_script(GetScripts.getContainerCenter)
     actions = ActionChains(self.driver)
     actions.move_to_element_with_offset(self.element, int(center['x']), int(center['y']))
     actions.key_down(Keys.SHIFT)
     actions.click_and_hold()
     actions.move_by_offset(300, 300)
     actions.release()
     actions.perform()
开发者ID:2gis,项目名称:mapsapi,代码行数:11,代码来源:map.py

示例12: evaluate

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element_with_offset [as 别名]
 def evaluate(self):
     """ Evaluate this component. (only available for ImplicitComponent) """
     rect = self.root.find_element_by_css_selector('rect')
     chain = ActionChains(self.browser)
     chain.move_to_element_with_offset(rect, 15, 15)
     chain.context_click(None)
     chain.perform()
     time.sleep(0.5)
     self('evaluate_button').click()
开发者ID:Daiyu506,项目名称:OpenMDAO-Framework,代码行数:11,代码来源:workflow.py

示例13: run

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element_with_offset [as 别名]
 def run(self):
     """ Run this component. """
     rect = self.root.find_element_by_css_selector('rect')
     chain = ActionChains(self.browser)
     chain.move_to_element_with_offset(rect, 15, 15)
     chain.context_click(None)
     chain.perform()
     time.sleep(0.5)
     self('run_button').click()
开发者ID:akhi28,项目名称:OpenMDAO-Framework,代码行数:11,代码来源:workflow.py

示例14: _context_click

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element_with_offset [as 别名]
 def _context_click(self, name):
     """ Display context menu. """
     chain = ActionChains(self.browser)
     # Default is centered which causes problems in some contexts.
     # Offset is apparently limited, (20, 20) had problems.
     chain.move_to_element_with_offset(self.root, 15, 15)
     chain.context_click(None)
     chain.perform()
     time.sleep(0.5)
     self(name).click()
开发者ID:Kenneth-T-Moore,项目名称:OpenMDAO-Framework,代码行数:12,代码来源:dataflow.py

示例15: add_library_item_to_dataflow

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element_with_offset [as 别名]
    def add_library_item_to_dataflow(self, item_name, instance_name,
                                     check=True, offset=None, prefix=None,
                                     args=None):
        """ Add component `item_name`, with name `instance_name`. """
        offset = offset or (90, 90)
        xpath = "//*[@id='-dataflow']"
        library_item = self.get_library_item(item_name)
        target = WebDriverWait(self.browser, TMO).until(
                           lambda browser: browser.find_element_by_xpath(xpath))

        for retry in range(3):
            try:
                chain = ActionChains(self.browser)
                if False:
                    chain.drag_and_drop(library_item, target)
                else:
                    chain.click_and_hold(library_item)
                    chain.move_to_element_with_offset(target,
                                                      offset[0], offset[1])
                    chain.release(None)
                chain.perform()
            except StaleElementReferenceException:
                if retry < 2:
                    logging.warning('add_library_item_to_dataflow:'
                                    ' StaleElementReferenceException')
                    library_item = self.get_library_item(item_name)
                    target = WebDriverWait(self.browser, TMO).until(
                           lambda browser: browser.find_element_by_xpath(xpath))
                else:
                    raise
            else:
                break

        page = ArgsPrompt(self.browser, self.port)
        page.set_name(instance_name)
        if args is not None:
            for i, arg in enumerate(args):
                page.set_argument(i, arg)
            page.click_ok()

        # Check that the prompt is gone so we can distinguish a prompt problem
        # from a dataflow update problem.
        time.sleep(0.25)
        self.browser.implicitly_wait(1)  # We don't expect to find anything.
        try:
            eq(len(self.browser.find_elements(*page('prompt')._locator)), 0)
        finally:
            self.browser.implicitly_wait(TMO)

        retval = None
        if check:  # Check that it's been added.
            retval = WebDriverWait(self.browser, TMO).until(
                        lambda browser: self.get_dataflow_figure(instance_name,
                                                                 prefix))
        return retval
开发者ID:akhi28,项目名称:OpenMDAO-Framework,代码行数:57,代码来源:workspace.py


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