class FileUploadElement

Public Class Methods

new(bot, target, value, element) click to toggle source
Calls superclass method MechanizeElement::new
# File lib/web_minion/bots/elements/file_upload_element.rb, line 4
def initialize(bot, target, value, element)
  super(bot, target, value, element)
end

Public Instance Methods

set_file() click to toggle source
# File lib/web_minion/bots/elements/file_upload_element.rb, line 8
def set_file
  case @target_type
  when :index
    index_set
  when :string_path
    string_set
  when :first_last
    first_last_set
  else
    raise(InvalidTargetType, "#{@target_type} is not valid!")
  end
end

Private Instance Methods

first_last_set() click to toggle source
# File lib/web_minion/bots/elements/file_upload_element.rb, line 31
def first_last_set
  if @target == "first"
    @element.file_uploads.first.file_name = @value
  elsif @target == "last"
    @element.file_uploads.last.file_name = @value
  else
    raise(InvalidTargetType, "#{@target} is not first or last!")
  end
end
index_set() click to toggle source
# File lib/web_minion/bots/elements/file_upload_element.rb, line 23
def index_set
  @element.file_uploads[@target].file_name = @value
end
string_set() click to toggle source
# File lib/web_minion/bots/elements/file_upload_element.rb, line 27
def string_set
  @element.file_upload_with(@target).file_name = @value
end