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


Python ActionChains.drag_and_drop_by_offset方法代码示例

本文整理汇总了Python中selenium.webdriver.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.ActionChains的用法示例。


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

示例1: drag_element_by_offset_class_name

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import drag_and_drop_by_offset [as 别名]
def drag_element_by_offset_class_name(browser, className, index, rightOrLeft, offset):
    elements = find_elements_by_class(browser, className)
    action_chains = ActionChains(browser)
    if str(rightOrLeft) == "left":
        action_chains.drag_and_drop_by_offset(elements[int(index) - 1], -int(offset), 0).perform()
    else:
        action_chains.drag_and_drop_by_offset(elements[int(index) - 1], int(offset), 0).perform()
开发者ID:my-js-tools,项目名称:ember-table-addon-demo-app,代码行数:9,代码来源:steps.py

示例2: test_can_move_block_from_one_container_to_another

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import drag_and_drop_by_offset [as 别名]
def test_can_move_block_from_one_container_to_another(live_server, browser,
                                                      admin_user):
    page = factories.FancyPageFactory(node__name='Home')
    main_container = page.containers.all()[0]

    layout = factories.TwoColumnLayoutBlockFactory(container=main_container)
    browser.visit(live_server.url + page.get_absolute_url())

    right = layout.containers.get(name='right-container')
    left = layout.containers.get(name='left-container')

    moving_block = factories.TextBlockFactory(container=right)
    factories.TextBlockFactory(container=right)
    factories.TextBlockFactory(container=left)

    browser.visit(live_server.url + page.get_absolute_url())
    browser.find_by_css('#editor-handle').first.click()

    source = browser.find_by_css(
        '#block-{} div.move'.format(moving_block.uuid)).first

    chain = ActionChains(browser.driver)
    chain.drag_and_drop_by_offset(source._element, -600, 200).perform()

    time.sleep(5)

    assert right.blocks.count() == left.blocks.count() == 1
    assert main_container.blocks.count() == 2

    main_block_ids = [b.uuid for b in main_container.blocks.all()]
    assert main_block_ids == [layout.uuid, moving_block.uuid]
开发者ID:aibon,项目名称:django-fancypages,代码行数:33,代码来源:test_moving_blocks.py

示例3: test_search_in_python_org

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import drag_and_drop_by_offset [as 别名]
    def test_search_in_python_org(self):
        driver = self.driver
        driver.implicitly_wait(10)
        actions = ActionChains(driver)
        driver.get("http://localhost:8080")


        ens = driver.find_element_by_class_name('ens')
        ens.click()

        menu = driver.find_element_by_id('VIZ_popup_menu')
        buttons = driver.find_elements_by_css_selector('#VIZ_popup_menu button')
        for button in buttons:
            text = button.get_attribute('textContent')
            if text == 'Value':
                button.click()
                break

        graph = driver.find_element_by_css_selector(".graph")
        actions.drag_and_drop_by_offset(graph, xoffset=-15, yoffset=15).perform()

        play_button = driver.find_element_by_id('VIZ.SimControl.play_button')
        play_button.click()

        time.sleep(3)
        line = driver.find_element_by_css_selector("path.line:nth-child(1)")
        
        data = line.rect 
        print data       
        test_val = data['height'] + data['width']
        assert test_val != 0

        block = driver.find_element_by_id("BlockTestCompletion")
开发者ID:Seanny123,项目名称:gui_test,代码行数:35,代码来源:line_visible_test.py

示例4: resize_column

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import drag_and_drop_by_offset [as 别名]
def resize_column(browser, column_name, left_or_right, offsetx):
    action_chains = ActionChains(browser)
    element = browser.execute_script(
        "return $('.ember-table-header-container .ember-table-content:contains(" + column_name + ")').parent().parent().children()[1]")
    if left_or_right == "left":
        action_chains.drag_and_drop_by_offset(element, -int(offsetx), 0).release().perform()
    else:
        action_chains.drag_and_drop_by_offset(element, int(offsetx), 0).release().perform()
开发者ID:cyjia,项目名称:ember-table-addon-demo-app,代码行数:10,代码来源:basic_opr_module.py

示例5: test_search_in_python_org

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import drag_and_drop_by_offset [as 别名]
 def test_search_in_python_org(self):
     driver = self.driver
     driver.get("http://localhost:8000")
     assert "nengo" in driver.page_source
     assert "default.py" in driver.page_source
     element = driver.find_element_by_id("ensemble")
     action_chains = ActionChains(driver)
     action_chains.drag_and_drop_by_offset(element, xoffset=100, yoffset=200).perform()
开发者ID:Seanny123,项目名称:gui_test,代码行数:10,代码来源:layout_move_test.py

示例6: test_search_in_python_org

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import drag_and_drop_by_offset [as 别名]
    def test_search_in_python_org(self):
        driver = self.driver
        action_chains = ActionChains(driver)
        driver.get("http://localhost:8080")

        graph_elements = driver.find_elements_by_class_name("graph")
        for e in graph_elements:
            action_chains.drag_and_drop_by_offset(e, xoffset=2, yoffset=2).perform()
开发者ID:Seanny123,项目名称:gui_test,代码行数:10,代码来源:graph_move_test.py

示例7: drag_and_drop_grade

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.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:cmscom,项目名称:edx-platform,代码行数:15,代码来源:settings_graders.py

示例8: get_column_cursor

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import drag_and_drop_by_offset [as 别名]
def get_column_cursor(step, column_name):
    with AssertContextManager(step):
        cursor_css = "body.ember-application"

        action_chains = ActionChains(world.browser)
        element = world.browser.execute_script(
            "return $('.ember-table-header-container .ember-table-content:contains(" + column_name + ")').parent().parent().children()[1]")
        action_chains.drag_and_drop_by_offset(element, 10, 0).release().perform()

        cursor = find_elements_by_css(world.browser, cursor_css)
        style = cursor[0].get_attribute("style")
        assert_true(step, ("auto" in style) or ("resize" in style) or ("pointer" in style))
        action_chains.release()
        world.browser.refresh()
开发者ID:cyjia,项目名称:ember-table-addon-demo-app,代码行数:16,代码来源:steps.py

示例9: test_search_in_python_org

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import drag_and_drop_by_offset [as 别名]
    def test_search_in_python_org(self):
        driver = self.driver
        driver.implicitly_wait(5)
        actions = ActionChains(driver)

        driver.get("http://localhost:8080")
        elem1 = driver.find_element_by_css_selector('div.graph:nth-child(4) > button:nth-child(2)')
        actions.drag_and_drop_by_offset(elem1, xoffset=0, yoffset=-25).perform()
       
        elem2 = driver.find_element_by_css_selector('button.btn:nth-child(3)')
        actions.drag_and_drop_by_offset(elem2, xoffset=0, yoffset=25).perform()

        text1 = elem1.get_attribute('textContent')
        assert text1 != "0.00"

        text2 = elem2.get_attribute('textContent')
        assert text2 != "0.00"
开发者ID:Seanny123,项目名称:gui_test,代码行数:19,代码来源:slider_move_test.py

示例10: test_search_in_python_org

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import drag_and_drop_by_offset [as 别名]
    def test_search_in_python_org(self):
        driver = self.driver
        driver.implicitly_wait(5)
        actions = ActionChains(driver)
        driver.get("http://localhost:8080")

        button = driver.find_element_by_css_selector('.play-pause-button')
        actions.click(on_element=button)
        actions.perform()

        time = driver.find_element_by_id("VIZ.SimControl.ticks_div")
        time_val = time.get_attribute('textContent')

        assert time_val != 0.00

        actions.click(on_element=button)
        actions.perform()

        window = driver.find_element_by_id('VIZ.SimControl.shown_div')
        actions.drag_and_drop_by_offset(window, xoffset=-100, yoffset=0).perform()
开发者ID:Seanny123,项目名称:gui_test,代码行数:22,代码来源:run_test.py

示例11: TmallLogin

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import drag_and_drop_by_offset [as 别名]
class TmallLogin(object):
    def __init__(self):
        self.driver = webdriver.PhantomJS(service_args=['--load-images=no'])
        self.action = ActionChains(self.driver)

    def sendinfo(self):
        self.driver.find_element_by_id('TPL_username_1').send_keys('[email protected]')
        self.driver.find_element_by_id('TPL_password_1').send_keys('codeismath11')
        self.driver.find_element_by_id('J_SubmitStatic').click()

    def checkslipper(self):  # 验证滑块部分
        slipper = self.driver.find_element_by_css_selector('.nc-lang-cnt')
        h_position = slipper.location
        logger.info('-' * 30 + str(h_position))
        self.action.drag_and_drop_by_offset(slipper, h_position['x'] + 300, h_position['y']).perform()

    def login(self):
        logger.info("Login Tmall")
        self.driver.get("https://login.tmall.com/")
        login_iframe = self.driver.find_element_by_id("J_loginIframe")
        if not login_iframe:
            logger.warning('Not found tmall login iframe!')
            return
        self.driver.switch_to.frame(login_iframe)
        if self.driver.find_element_by_id('J_Quick2Static').is_displayed():
            self.driver.find_element_by_id('J_Quick2Static').click()
        time.sleep(0.5)
        slipper = self.driver.find_element_by_css_selector('.nc-lang-cnt')
        if slipper:  # 如果有滑块
            self.checkslipper()
        self.sendinfo()
        time.sleep(uniform(8, 12))
        self.driver.get_screenshot_as_file('pic/success.png')

    def wait_for_clickable(self, selector, timeout=10):
        WebDriverWait(self.driver, timeout).until(
            EC.element_to_be_clickable((By.CSS_SELECTOR, selector))
        )

    def wait_after_click(self, click, wait, timeout=10):
        comm_ele = self.driver.find_element_by_css_selector(click)
        comm_ele.click()
        WebDriverWait(self.driver, timeout).until(
            EC.visibility_of_element_located((By.CSS_SELECTOR, wait))
        )

    def determine(self, element):  # 如果找到元素名,返回真,如果找不到,返回假
        try:
            self.driver.find_element_by_class_name(element)
            return True
        except BaseException:
            return False

    def choose_selector(self):  # 选择器分类
        dot_element = 'rate-page-break'
        result = self.determine(dot_element)
        print '--'*20
        print result
        print '--'*20
        if result is True:  # 如果有点点点的选择器
            next_page_selector = '.rate-page .rate-paginator .rate-page-break + a[data-page]'
            return next_page_selector
        else:
            next_page_selector = '.rate-page .rate-paginator a[data-page]'
            results = self.driver.find_elements_by_css_selector(next_page_selector)
            if len(results) == 1 and results[0].text == u'下一页>>':
                return next_page_selector
            elif len(results) == 2:  # 在中间的页码,有上一页和下一页时,有待检验
                return '.rate-page .rate-paginator a[data-page]:nth-child(5)'
            elif len(results) == 1 and results[0].text == u'<<上一页':
                pass  # 说明没有下一页了,不用再返回选择器了

    def crawler(self):
        # url = 'https://detail.tmall.com/item.htm?spm=a220m.1000858.1000725.10.5suWJ0&id=527680541344&skuId=3150349001482&areaId=320100&cat_id=2&rn=5d8121f40e659a29a6ed8dfce87ffcbd&user_id=2786278078&is_b=1'
        url = 'https://detail.tmall.com/item.htm?spm=a1z10.15-b.w4011-7524477099.99.XU8KX2&id=39578745679&rn=f879610ca3b5a66a8cd08f19a0cc2de2&abbucket=8'
        logger.info(url)
        logger.info('the url for collecting info!')
        self.driver.get(url)
        time.sleep(uniform(6, 8))
        self.driver.save_screenshot('pic/1.png')
        self.wait_for_clickable('.tm-selected')  # 等累计评论可以点击了
        self.driver.save_screenshot('pic/2.png')
        self.wait_after_click('.tm-selected', '.rate-grid')  # 点击(前面的)累计评价,等(后面的)评论区域出现
        wait = ui.WebDriverWait(self.driver, 10)
        wait.until(lambda driver: self.driver.find_element_by_id('footer'))
        self.driver.save_screenshot('pic/3.png')
        page_queue.put({'url': url, 'page': '1', 'html': self.driver.page_source})  # 将第一页的评论内容放入队列中
        time.sleep(uniform(2, 3))
        for page in xrange(2, 4):
            time.sleep(uniform(10, 20))
            logger.info(page)
            print '**'*20
            selector = self.choose_selector()
            print selector
            print '**'*20
            try:
                self.wait_for_clickable(selector)  # 等下一页的选择器出现
                self.driver.save_screenshot('pic/turnpage_1.png')
            except Exception, err:
                logger.info(err)
#.........这里部分代码省略.........
开发者ID:vv1010,项目名称:TMall,代码行数:103,代码来源:login.py

示例12: width

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import drag_and_drop_by_offset [as 别名]
 def width(self, value):
     offset = value - self.width
     action = ActionChains(self.driver)
     action.drag_and_drop_by_offset(self._resize_handler, offset, 0)
     action.perform()
开发者ID:indigo-dc,项目名称:onedata,代码行数:7,代码来源:sidebar.py

示例13: action_with_items

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import drag_and_drop_by_offset [as 别名]
def action_with_items(self, element_menu, element_item, drag_off):
    action = ActionChains(self.driver)
    action.move_to_element(element_menu).click()
    action.drag_and_drop_by_offset(element_item, 0, drag_off)
    action.perform()
开发者ID:slav1k,项目名称:demoqa_com_python,代码行数:7,代码来源:DemoqaComDraggable.py

示例14: action_with_element

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import drag_and_drop_by_offset [as 别名]
def action_with_element(self, element_menu, drag):
    action = ActionChains(self.driver)
    action.move_to_element(element_menu).click()
    action.drag_and_drop_by_offset(drag, 45, 45)
    action.perform()
开发者ID:slav1k,项目名称:demoqa_com_python,代码行数:7,代码来源:DemoqaComDraggable.py

示例15: move_left_slider

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import drag_and_drop_by_offset [as 别名]
 def move_left_slider(self, offset):
     action_chain = ActionChains(self.driver)
     action_chain.drag_and_drop_by_offset(self.left_slider, offset, 0).perform()
开发者ID:MaxMyalkin,项目名称:tech-testing-ha2,代码行数:5,代码来源:components.py


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