Module: Bewildr::ControlPatterns::ValuePattern

Defined in:
lib/bewildr/control_patterns/value_pattern.rb

Instance Method Summary collapse

Instance Method Details

#password_field?Boolean

Returns true if the element is a password field, false if it’s not

Returns:

  • (Boolean)


7
8
9
# File 'lib/bewildr/control_patterns/value_pattern.rb', line 7

def password_field?
  @automation_element.current.class_name.to_s == "PasswordBox" ? true : false
end

#textObject

Returns the element’s text



12
13
14
15
# File 'lib/bewildr/control_patterns/value_pattern.rb', line 12

def text
  raise Bewildr::PasswordFieldReadAttempt, "You can't get the text of a password field" if password_field?
  @automation_element.get_current_pattern(System::Windows::Automation::ValuePattern.pattern).current.value.to_s
end

#text=(input) ⇒ Object

Sets the element’s text



18
19
20
21
# File 'lib/bewildr/control_patterns/value_pattern.rb', line 18

def text=(input)
  raise Bewildr::ElementNotEnabled unless enabled?
  @automation_element.get_current_pattern(System::Windows::Automation::ValuePattern.pattern).set_value(input)
end