Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # Okay... here is a "page" from an application. This is only a small chunk of code...
- # our XML model is large and complex, for example. Note that fill_text_field() and
- # similar methods are our own "wrappers" around the watir methods that do the work.
- #
- # In our setup, each web page is a separate method (we took a state-machine approach).
- # To use fill_text_field as an example, it takes a string (which we use for logging,
- # then the id of the html element on the page, then a hash of options. :xml_method
- # for example is method in our xml model that returns a value.
- #
- # Because of the nature of this task, you will note that (especially on this
- # particular page), we are doing a lot more writing than reading. On a lot of pages,
- # we would have to examine the state of certain elements in order to determine what
- # to do next.
- #
- def hq2_page( vars )
- page = 'hq2'
- # Check for errors (displayed on same page after Continue
- # button is clicked).
- ###########################################################
- message = @ie.div(:id, 'ValidationSummary1')
- if message.text.length > 0
- log_message " #{message.text} -> CompanySiteError Exception"
- raise CompanySiteError.new( message.text )
- end
- ###########################################################
- fill_text_field( 'First Name', 'FirstName', :xml_method => 'first_name' )
- fill_text_field( 'Middle Name', 'MidleName', :xml_method => 'middle_name' )
- fill_text_field( 'Last Name', 'LastName', :xml_method => 'last_name' )
- # The fields "Prefix" (Mr., Mrs., etc.) and "Title"
- # (jr., sr., III) are optional.
- if @xml_req.insured_is_married
- fill_text_field( 'Spouse/Secondary FirstName', 'SFirstName', :xml_method =>
- 'sec_first_name' )
- fill_text_field( 'Spouse/Secondary MiddleName', 'SMidleName', :xml_method =>
- 'sec_middle_name' )
- fill_text_field( 'Spouse/Secondary LastName', 'SLastName', :xml_method =>
- 'sec_last_name' )
- end # if insured_is_married
- result = @xml_req.phone_home
- # Change made to enter all 5s if we were not supplied
- # with a phone number.
- result = '(555) 555-5555' if ( params[:test] ) or ! result
- fill_text_field( 'Home Phone', 'phoneHome', :value => result )
- # Work phone field (phoneWork) is optional
- fill_text_field( 'Address 1', 'PropertyAddress_InputAddress_txtAddress1',
- :xml_method => 'property_address1' )
- fill_text_field( 'Address 2', 'PropertyAddress_InputAddress_txtAddress2',
- :xml_method => 'property_address2' )
- fill_text_field( 'City', 'PropertyAddress_InputAddress_txtCity',
- :xml_method => 'property_city' )
- if result = @xml_req.property_state
- if 'Other' != result[0, 5]
- select_from_list( 'State', 'PropertyAddress_InputAddress_drpState',
- :value => result )
- else
- msg = 'ERROR: Either IBQ or Austin Mutual does not rate in this state.'
- log_message msg
- @xml_resp.add_error msg
- end
- end
- fill_text_field( 'Zip Code', 'PropertyAddress_InputAddress_txtZipCode',
- :xml_method => 'property_zip_code' )
- log_message ' *click* -> Continue(btnContinue)'
- element = @ie.button(:id, 'btnContinue')
- @wait_time += timer do
- element.click_no_wait
- popup_check
- end
- end # hq2
Add Comment
Please, Sign In to add comment