RSpec Code Examples

 

 

Page class with face definitions
has face method as singleton
face class method defines method
face accepts args used by method body
when optional args not supplied provide default arg in method
Page faces included in rspec
face defines a watir element access
faces with arguments
Page doc provides access to frame in frameset browser
face defines a watir element access
faces with arguments
setting and getting values for individual checkboxes with value attributes in face definitions
semantic name accesses individual CheckBox
set individual checkbox does not set other checkboxes sharing the same name
browser checkbox_group accesses a group of checkboxes sharing the same name on a page
browser responds to checkbox_group
access by name as default returns CheckboxGroup
size retuns checkboxes as items count in a group
values returns array of value attributes for each checkbox in a group
checkbox_group values when no checkbox is checked in a group
selected should return nil
selected_value should return nil
selected_values should return empty array
set? should return false when no checkbox is checked in a group
checkbox_group values when set string selecs one item only
selected should return the string used to select it
selected_value should return the string when one item is selected
selected values returns array with one element
set? should return truee when 1 checkbox is checked in a group
checkbox_group set array of strings selects multiple values in a group
selected returns array of strings when multiple values are selected
selected_value returns the same array of strings by position in a group
selected_values returns the same array of strings by position in a group
set? should return truee when more than 1 checkbox is checked in a group
checkbox_group set by numberical position
set Fixnum checks checkbox by position in a group. Position is 1 based.
set array of Fixnums checks each checkbox by position
Class client mixing interfaces from other modules
spray and scrape example
Person Page interfaces defined by def wrappers and class definitions
calling face when there is wrapper method
calling interface when there is definition and no method
spray method by convetion has keys correspondig to interface names for watir elements
RadioGroup class access in watir browser
browser responds to radio_group
radio group needs :what value with implicit :how=name
RadioGroup class interface in watirloo
container radio_group method returns RadioGroup class
size or count returns how many radios in a group
values returns value attributes text items as an array
selected_value returns internal option value for selected radio item in a group
set selects radio by position in a group
set selects radio by value in a group. selected returns value
set position throws exception if number not within the range of group size
set value throws exception if value not found in options
set throws exception if sybmol is used. it should accept Fixnum or String element only
SelectList selections
selected returns preselected item in single select
selected returns preselected value in single select
selected returns nil for none selected items in multi select
selected returns nil for none selected values in multi select
set item text and find selected item and text for multiselect
set value and find selected item and value for multiselect
set and query option by text for single select
set and query option by value for single select
set by text multple items for multiselect selects each item
set by value multple items for multiselect selects each item
set items array for single select selects each in turn. selected is the last item in array
set item after multiple items were set returns all values selected for multiselect
set using position for multiselect
set using position and item for multiselect
set using position for single select
clear removes selected attribute for all selected items in multiselect
clear removes selected attribute for item in single select list
set_value selects value atribute text
set_value for multiselect returns selected and selected_values
SelectList options as visible items and values as hidden to the user attributes
values of options by facename method
options with no value attribute
items method returns visible contents as array of text items
items returns visible text items as array
add faces text fields page objects
face returns a watir element text_field
face name method and value returns current text
face name method and set enters value into field
spray method matches keys as facenames and sets values to fields
scrape keys updates keys with values and returns datamap