Class: WebMinion::Step
- Inherits:
-
Object
- Object
- WebMinion::Step
- Defined in:
- lib/web_minion/step.rb
Overview
A Step represents the individual operation that the bot will perform. This often includes grabbing an element from the DOM tree, or performing some operation on an element that has already been found.
Constant Summary collapse
- VALID_METHODS =
{ select: [ :field, :radio_button, :first_radio_button, :checkbox ], main_methods: [ :set_file_upload, :get_field, :get_form, :go, :select, :click, :click_button_in_form, :submit, :fill_in_input, :url_equals, :value_equals, :body_includes, :save_page_html, :save_value ] }.freeze
Instance Attribute Summary collapse
-
#is_validator ⇒ Object
Returns the value of attribute is_validator.
-
#method ⇒ Object
Returns the value of attribute method.
-
#name ⇒ Object
Returns the value of attribute name.
-
#retain_element ⇒ Object
Returns the value of attribute retain_element.
-
#saved_values ⇒ Object
readonly
Returns the value of attribute saved_values.
-
#skippable ⇒ Object
Returns the value of attribute skippable.
-
#target ⇒ Object
Returns the value of attribute target.
-
#value ⇒ Object
Returns the value of attribute value.
-
#vars ⇒ Object
Returns the value of attribute vars.
Instance Method Summary collapse
-
#initialize(fields = {}) ⇒ Step
constructor
A new instance of Step.
- #perform(bot, element = nil, saved_values) ⇒ Object
- #retain? ⇒ Boolean
- #valid_method?(method) ⇒ Boolean
- #validator? ⇒ Boolean
Constructor Details
#initialize(fields = {}) ⇒ Step
Returns a new instance of Step.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/web_minion/step.rb', line 36 def initialize(fields = {}) fields.each_pair do |k, v| if valid_method?(k.to_sym) send("method=", k) @target = v else send("#{k}=", v) end end replace_all_variables end |
Instance Attribute Details
#is_validator ⇒ Object
Returns the value of attribute is_validator.
8 9 10 |
# File 'lib/web_minion/step.rb', line 8 def is_validator @is_validator end |
#method ⇒ Object
Returns the value of attribute method.
8 9 10 |
# File 'lib/web_minion/step.rb', line 8 def method @method end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/web_minion/step.rb', line 8 def name @name end |
#retain_element ⇒ Object
Returns the value of attribute retain_element.
8 9 10 |
# File 'lib/web_minion/step.rb', line 8 def retain_element @retain_element end |
#saved_values ⇒ Object (readonly)
Returns the value of attribute saved_values.
9 10 11 |
# File 'lib/web_minion/step.rb', line 9 def saved_values @saved_values end |
#skippable ⇒ Object
Returns the value of attribute skippable.
8 9 10 |
# File 'lib/web_minion/step.rb', line 8 def skippable @skippable end |
#target ⇒ Object
Returns the value of attribute target.
8 9 10 |
# File 'lib/web_minion/step.rb', line 8 def target @target end |
#value ⇒ Object
Returns the value of attribute value.
8 9 10 |
# File 'lib/web_minion/step.rb', line 8 def value @value end |
#vars ⇒ Object
Returns the value of attribute vars.
9 10 11 |
# File 'lib/web_minion/step.rb', line 9 def vars @vars end |
Instance Method Details
#perform(bot, element = nil, saved_values) ⇒ Object
53 54 55 |
# File 'lib/web_minion/step.rb', line 53 def perform(bot, element = nil, saved_values) bot.execute_step(@method, @target, @value, element, saved_values) end |
#retain? ⇒ Boolean
63 64 65 |
# File 'lib/web_minion/step.rb', line 63 def retain? retain_element end |
#valid_method?(method) ⇒ Boolean
71 72 73 74 75 76 77 |
# File 'lib/web_minion/step.rb', line 71 def valid_method?(method) split = method.to_s.split("/").map(&:to_sym) if split.count > 1 return true if VALID_METHODS[split[0]].include?(split[1]) end VALID_METHODS[:main_methods].include?(method) end |
#validator? ⇒ Boolean
67 68 69 |
# File 'lib/web_minion/step.rb', line 67 def validator? is_validator end |