Class: JQueryUIWidgets::Slider
- Inherits:
-
PageObject::Elements::Div
- Object
- PageObject::Elements::Div
- JQueryUIWidgets::Slider
- Defined in:
- lib/jqueryui_widgets/slider.rb
Overview
Slider Class will serve as a wrapper for the JQuery UI Slider widget, allowing the user to interact with the slider, setting it to a specific position within the length of the slider, between 0% and 100%.
The user will pass in the variable they wish to set with the addition of the % symbol.
NOTE: The code for the Slider widget will be kept as basic as possible in order to allow the user to tailor the class to suit their own needs in case customization of the slider has been exercised.
Class Method Summary collapse
-
.accessor_methods(accessor, name) ⇒ Object
Generates two methods.
Class Method Details
.accessor_methods(accessor, name) ⇒ Object
Generates two methods.
The NAME method picks up the current position of the slider, grabbing the % and returning it.
The NAME= method will allow the user to set the position of the slider by passing in a percentage.
@example
the_slider=('15%')
Will set the slider to 15%.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/jqueryui_widgets/slider.rb', line 31 def self.accessor_methods(accessor, name) accessor.send :define_method, "#{name}" do = self.send "#{name}_element" = .link_element(:class => 'ui-slider-handle ui-state-default ui-corner-all') .html[/\d+%/] end accessor.send :define_method, "#{name}=" do |value| browser.execute_script("document.getElementsByClassName('ui-slider-handle')[0].style.left=\"#{value}\";") end end |