Code Monkey home page Code Monkey logo

Comments (8)

fsouza avatar fsouza commented on July 17, 2024

Check this Gist out: https://gist.github.com/1047207

from splinter.

gabriellima avatar gabriellima commented on July 17, 2024

It seems that it'd be something like this:

from selenium.webdriver import ActionChains

def drag_and_drop(self, source, target):
    element = driver.find_element_by_name(source)
    target = driver.find_element_by_name(target)

    action_chains = ActionChains(self.driver)
    action_chains.drag_and_drop(element, target)

I wish I'd have my notebook now and time to commit this. @FranciscoSouza , can you help me on this?
Maybe I'll have on weekend.

from splinter.

fsouza avatar fsouza commented on July 17, 2024

I'd prefer a method on Element:

browser.find_by_id('item').first.drag_to(target)

What do you think?

from splinter.

gabriellima avatar gabriellima commented on July 17, 2024

Down the ramp, I wonder this as follows:

from selenium.webdriver import ActionChains

class BaseWebDriver(DriverAPI):
    ....
    def __init__(self, wait_time=2):
        self.wait_time = wait_time
        self.capabilities = ActionChains(self.driver)

(this, given that BaseWebDriver is only used for inheritance and the super method is only called at the end of __init__ method)

And then, when you want some capability, just do (for example):

....
browser.capabilities.drag_and_drop(source, target)

What you all think?

from splinter.

andrewsmedina avatar andrewsmedina commented on July 17, 2024

I think that element should be responsible for drag yourself. Then, I like the syntax below for this:

element.drag_and_drop_to(target)

What you all think?

from splinter.

fsouza avatar fsouza commented on July 17, 2024

+1

from splinter.

gabriellima avatar gabriellima commented on July 17, 2024

+1, and kind of work even with what @FranciscoSouza put. Both are nice approaches, as the drag_and_drop_to would be present also on the element returned from browser.find_by_id('item').first. Congratulations.

from splinter.

fsouza avatar fsouza commented on July 17, 2024

For this, we're going to use ActionChains, and Firefox doesn't support ActionChains yet (on Mac OS).

from splinter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.