module Pincers::Extension::Actions

Public Instance Methods

set(_value=true, _options={}) click to toggle source
# File lib/pincers/extension/actions.rb, line 4
def set(_value=true, _options={})

  if _value.is_a? Hash
    _options = _value
    _value = true
  end

  case input_mode
  when :text
    wait :enabled
    set_text _value.to_s
  when :select
    wait :enabled
    return set_selected _value, _options
  when :checkbox, :radio
    wait :enabled
    return set_checked _value
  when :button
    wait :enabled
    click if _value
  else
    return false
  end
  true
end

Private Instance Methods

find_option_by_label(_label, _options) click to toggle source
# File lib/pincers/extension/actions.rb, line 51
def find_option_by_label(_label, _options)
  search(_options.merge(xpath: ".//option[contains(.,'#{_label}')]")).first
end
find_option_by_value(_value, _options) click to toggle source
# File lib/pincers/extension/actions.rb, line 55
def find_option_by_value(_value, _options)
  search(_options.merge(xpath: ".//option[@value='#{_value}']")).first
end
set_checked(_value) click to toggle source
# File lib/pincers/extension/actions.rb, line 45
def set_checked(_value)
  return false if _value == checked?
  click
  true
end
set_selected(_value, _options) click to toggle source
# File lib/pincers/extension/actions.rb, line 32
def set_selected(_value, _options)
  click
  option = if _options.key? :by_value then
    find_option_by_value _options.delete(:by_value), _options
  else
    find_option_by_label _value, _options
  end

  return false if option.nil? or option.selected?
  option.click
  true
end