drag_and_drop_by now called on driver in webdriver-2.0

20 views
Skip to first unread message

Richard Paul

unread,
Jul 12, 2011, 10:07:41 AM7/12/11
to selenium-ruby
I have some webdriver-0.2 code that acts as test helpers for
manipulating custom widgets:

class SliderWidget
def initialize(element)
@element = element
end

def drag_to(percentage)
position = calculate_position_in_pixels(percentage)
@element.drag_and_drop_by(position - current_position, vertical=0)
end
...
end

I'm attempting to port this over to webdriver-2.0 but
element.drag_and_drop_to has been removed and replaced with action
builder. ActionBuilder requires the driver as the base element, e.g.

driver.action.drag_and_drop_to(@element, position - current_position,
vertical=0)

However my SliderWidget shouldn't need to know about the entire
driver, just the element it wants to interact with (Law of Demeter).
Does anyone know of an elegant solution to this in selenium-
webdriver-2.0? Or will I have to pass the driver in each time I
instantiate a draggable widget helper.
Reply all
Reply to author
Forward
0 new messages