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


Python ActionChains.drag_and_drop_by_offset方法代码示例

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


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

示例1: _drag_marker_on_map

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import drag_and_drop_by_offset [as 别名]
    def _drag_marker_on_map(self, endx, endy):
        actions = ActionChains(self.driver)
        marker = self.driver.find_elements_by_css_selector(
            '.leaflet-marker-pane img')[0]

        actions.drag_and_drop_by_offset(marker, endx, endy)
        actions.perform()
开发者ID:ahinz,项目名称:OpenTreeMap-cloud,代码行数:9,代码来源:__init__.py

示例2: test_if_captions_are_draggable

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import drag_and_drop_by_offset [as 别名]
    def test_if_captions_are_draggable(self):
        """
        Loads transcripts so that closed-captioning is available.
        Ensures they are draggable by checking start and dropped location.
        """
        self.assets.append('subs_3_yD_cEKoCk.srt.sjson')
        data = {'sub': '3_yD_cEKoCk'}

        self.metadata = self.metadata_for_mode('html5', additional_data=data)
        self.navigate_to_video()
        self.assertTrue(self.video.is_video_rendered('html5'))
        self.video.show_closed_captions()
        self.video.wait_for_closed_captions()
        self.assertTrue(self.video.is_closed_captions_visible)

        action = ActionChains(self.browser)
        captions = self.browser.find_element(By.CLASS_NAME, 'closed-captions')

        captions_start = captions.location
        action.drag_and_drop_by_offset(captions, 0, -15).perform()
        captions_end = captions.location
        self.assertEqual(
            captions_end.get('y') + 15,
            captions_start.get('y'),
            'Closed captions did not get dragged.'
        )
开发者ID:Akif-Vohra,项目名称:edx-platform,代码行数:28,代码来源:test_video_module.py

示例3: step_impl

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import drag_and_drop_by_offset [as 别名]
def step_impl(context):
        marker = context.browser.find_element_by_xpath("//body/div[@id='slider-range-max']/span")
        marker_location = marker.location
        start = marker_location.get('x')
        actions = ActionChains(context.browser)
        actions.drag_and_drop_by_offset(marker,(-start),0)
        actions.perform()
        time.sleep(1)
开发者ID:Ketochka,项目名称:Selenium_Behave_tests,代码行数:10,代码来源:Selenium_slider_fixed_max.py

示例4: drag_marker_on_map

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import drag_and_drop_by_offset [as 别名]
    def drag_marker_on_map(self, endx, endy):
        actions = ActionChains(self.driver)
        marker = self.find('.leaflet-marker-pane img')

        actions.drag_and_drop_by_offset(marker, endx, endy)
        actions.perform()

        self._click_add_tree_next_step(0)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:10,代码来源:__init__.py

示例5: step_impl

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import drag_and_drop_by_offset [as 别名]
def step_impl(context):
        resizable_element = context.browser.find_element_by_xpath("//div[@id='accordion-resizer']")
        x = resizable_element.size.get('width')
        time.sleep(1)
        dragging_point = context.browser.find_element_by_xpath("//div[contains(@class,'ui-icon-gripsmall-diagonal-se')]")
        actions = ActionChains(context.browser)
        actions.drag_and_drop_by_offset(dragging_point,-100,0).perform()
        time.sleep(1)
        new_x=resizable_element.size.get('width')
        assert((x-new_x)==100)
开发者ID:Ketochka,项目名称:Selenium_Behave_tests,代码行数:12,代码来源:Selenium_accordion_resizable.py

示例6: step_impl

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import drag_and_drop_by_offset [as 别名]
def step_impl(context):
        slider = context.browser.find_element_by_xpath("//body/div[@id='slider-range']")
        right_marker = context.browser.find_element_by_xpath("//body/div[@id='slider-range']/span[2]")
        width = slider.size['width']
        right_marker_location = right_marker.location
        r = right_marker_location.get('x')
        actions = ActionChains(context.browser)
        actions.drag_and_drop_by_offset(right_marker,(-r+width*86/500),0)
        actions.perform() 
        time.sleep(1)
开发者ID:Ketochka,项目名称:Selenium_Behave_tests,代码行数:12,代码来源:Selenium_slider_range.py

示例7: move_grading_range_by_offset

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import drag_and_drop_by_offset [as 别名]
 def move_grading_range_by_offset(self, letter, offset_x=0, offset_y=0):
     """
     Moves grading range by the offset
     """
     # First element is not removable, that's why we should subtract 1
     index = self._get_index_of('.letter-grade', letter) - 1
     draggable = self.q(css='.grade-range .ui-resizable-e').results[index]
     action = ActionChains(self.browser)
     action.drag_and_drop_by_offset(draggable, offset_x, offset_y).release().perform()
     self.click_save_button()
开发者ID:ariestiyansyah,项目名称:edx-platformX,代码行数:12,代码来源:settings_graders.py

示例8: drag_and_drop_grade

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import drag_and_drop_by_offset [as 别名]
 def drag_and_drop_grade(self):
     """
     Drag and drop grade range.
     """
     self.wait_for_element_visibility(self.grade_ranges, "Grades ranges are visible")
     # We have used jquery here to adjust the width of slider to
     # desired range because drag and drop has behaved very inconsistently.
     # This does not updates the text of range on the slider.
     # So as a work around, we have used drag_and_drop without any offset
     self.browser.execute_script('$(".ui-resizable").css("width","10")')
     action = ActionChains(self.browser)
     moveable_css = self.q(css='.ui-resizable-e').results[0]
     action.drag_and_drop_by_offset(moveable_css, 0, 0).perform()
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:15,代码来源:settings_graders.py

示例9: drag_and_drop_by_offset

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import drag_and_drop_by_offset [as 别名]
    def drag_and_drop_by_offset(self, source, xoffset, yoffset):
        """Drags element identified with `source` which is a locator.

        Element will be moved by xoffset and yoffset, each of which is a
        negative or positive number specify the offset.

        Examples:
        | Drag And Drop By Offset | myElem | 50 | -35 | # Move myElem 50px right and 35px down. |
        """
        src_elem = self.find_element(source)
        action = ActionChains(self.browser)
        action.drag_and_drop_by_offset(src_elem, xoffset, yoffset)
        action.perform()
开发者ID:ponkar,项目名称:robotframework-selenium2library,代码行数:15,代码来源:element.py

示例10: drag_and_drop

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import drag_and_drop_by_offset [as 别名]
    def drag_and_drop(self, x_offset=0, y_offset=0, element_class="gt_slider_knob"):
        """拖拽滑块

        :x_offset: 相对滑块x坐标偏移
        :y_offset: 相对滑块y坐标偏移
        :element_class: 滑块网页元素CSS类名

        """
        dragger = self.driver.find_element_by_class_name(element_class)
        action = ActionChains(self.driver)
        action.drag_and_drop_by_offset(dragger, x_offset, y_offset).perform()
        # 这个延时必须有,在滑动后等待回复原状
        time.sleep(8)
开发者ID:Chrisn2o,项目名称:Anti-Anti-Spider,代码行数:15,代码来源:geetest.py

示例11: step_impl

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import drag_and_drop_by_offset [as 别名]
def step_impl(context):
        section_1 = context.browser.find_element_by_id("ui-id-1")
        location1 = section_1.location
        y1=location1.get('y')
        section_1_inf = context.browser.find_element_by_id("ui-id-2")
        small_height = section_1.size.get('height')
        bigger_height = section_1_inf.size.get('height')
        section_4 = context.browser.find_element_by_id("ui-id-7")
        location4 = section_4.location
        y4=location4.get('y')
        actions = ActionChains(context.browser)
        actions.drag_and_drop_by_offset(section_4,0,-small_height*3-bigger_height-10).perform()        
        time.sleep(1)
开发者ID:Ketochka,项目名称:Selenium_Behave_tests,代码行数:15,代码来源:Selenium_accordion_sortable_panels.py

示例12: drag_and_drop_by_offset

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import drag_and_drop_by_offset [as 别名]
    def drag_and_drop_by_offset(self, locator, xoffset, yoffset):
        """Drags element identified with ``locator`` by ``xoffset/yoffset``.

        See the `Locating elements` section for details about the locator
        syntax.

        Element will be moved by ``xoffset`` and ``yoffset``, each of which
        is a negative or positive number specifying the offset.

        Example:
        | `Drag And Drop By Offset` | myElem | 50 | -35 | # Move myElem 50px right and 35px down |
        """
        element = self.find_element(locator)
        action = ActionChains(self.driver)
        action.drag_and_drop_by_offset(element, int(xoffset), int(yoffset))
        action.perform()
开发者ID:HelioGuilherme66,项目名称:robotframework-selenium2library,代码行数:18,代码来源:element.py

示例13: test_worker

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import drag_and_drop_by_offset [as 别名]
def test_worker():
    """
	Creates a worker to run experiment.
	"""
    rand_id = "_load_test_" + "".join(
        random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(id_len)
    )

    debug_url = "http://128.32.37.232:22362/ad?assignmentId=debugID0WYB&hitId=debugZFWL4D&workerId=debug{0}&mode=debug".format(
        rand_id
    )
    browser = webdriver.Firefox()
    # Visit URL
    browser.get(debug_url)
    time.sleep(sleep_len)

    # Click button to proceed to experiment
    browser.find_element_by_xpath('//*[@id="ad"]/div/div[2]/button').click()
    time.sleep(sleep_len)

    # Close landing window
    browser.close()
    browser.switch_to_window(browser.window_handles[0])

    # Click "I Agree"
    browser.find_element_by_xpath('//*[@id="consent"]/center/button[1]').click()

    # Click through instruction pages
    for i in range(5):
        browser.find_element_by_xpath('//*[@id="next"]').click()
        time.sleep(sleep_len)

        # Provide labels
    canvas = browser.find_element_by_xpath('//*[@id="canvas"]')
    time.sleep(sleep_len)
    actions = ActionChains(browser)
    for i in range(10):
        offset = 100
        actions.drag_and_drop_by_offset(canvas, i * offset, i * offset)
        actions.perform()

    time.sleep(final_sleep_len)
    browser.close()
开发者ID:mdlaskey,项目名称:SHIV_AMT,代码行数:45,代码来源:load_test.py

示例14: test_action_chains_drag

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import drag_and_drop_by_offset [as 别名]
 def test_action_chains_drag(self):
     driver = self.driver
     driver.get('https://jqueryui.com/draggable')
     frame=driver.find_element_by_tag_name('iframe')
     driver.switch_to_frame(frame)
     draggable_element = driver.find_element_by_xpath("//div[@id='draggable']")
     location1 = draggable_element.location
     print "Before Drag Position: ", location1
     x1 = location1.get('x')
     print x1
     actions = ActionChains(driver)
     actions.drag_and_drop_by_offset(draggable_element, 100, 0)
     actions.perform()
     time.sleep(5)
     location2 = draggable_element.location
     print "After Drag Postion: ", location2
     x2 = location2.get('x')
     print x2
     self.assertTrue(x2 - x1 == 100)
开发者ID:weifengli001,项目名称:autotesting,代码行数:21,代码来源:drag.py

示例15: drag_marker

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import drag_and_drop_by_offset [as 别名]
 def drag_marker(self, x_offset, y_offset, index=0):
     actions = ActionChains(self.driver)
     marker = self.driver.find_elements_by_css_selector(self.selectors['self'])[index]
     actions.drag_and_drop_by_offset(marker, x_offset, y_offset).perform()
开发者ID:2gis,项目名称:mapsapi,代码行数:6,代码来源:marker.py


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