Guest User

Untitled

a guest
Feb 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. #
  2. # Okay... here is a "page" from an application. This is only a small chunk of code...
  3. # our XML model is large and complex, for example. Note that fill_text_field() and
  4. # similar methods are our own "wrappers" around the watir methods that do the work.
  5. #
  6. # In our setup, each web page is a separate method (we took a state-machine approach).
  7. # To use fill_text_field as an example, it takes a string (which we use for logging,
  8. # then the id of the html element on the page, then a hash of options. :xml_method
  9. # for example is method in our xml model that returns a value.
  10. #
  11. # Because of the nature of this task, you will note that (especially on this
  12. # particular page), we are doing a lot more writing than reading. On a lot of pages,
  13. # we would have to examine the state of certain elements in order to determine what
  14. # to do next.
  15. #
  16.  
  17. def hq2_page( vars )
  18. page = 'hq2'
  19.  
  20. # Check for errors (displayed on same page after Continue
  21. # button is clicked).
  22. ###########################################################
  23. message = @ie.div(:id, 'ValidationSummary1')
  24. if message.text.length > 0
  25. log_message " #{message.text} -> CompanySiteError Exception"
  26. raise CompanySiteError.new( message.text )
  27. end
  28. ###########################################################
  29.  
  30. fill_text_field( 'First Name', 'FirstName', :xml_method => 'first_name' )
  31.  
  32. fill_text_field( 'Middle Name', 'MidleName', :xml_method => 'middle_name' )
  33.  
  34. fill_text_field( 'Last Name', 'LastName', :xml_method => 'last_name' )
  35.  
  36. # The fields "Prefix" (Mr., Mrs., etc.) and "Title"
  37. # (jr., sr., III) are optional.
  38.  
  39. if @xml_req.insured_is_married
  40. fill_text_field( 'Spouse/Secondary FirstName', 'SFirstName', :xml_method =>
  41. 'sec_first_name' )
  42.  
  43. fill_text_field( 'Spouse/Secondary MiddleName', 'SMidleName', :xml_method =>
  44. 'sec_middle_name' )
  45. fill_text_field( 'Spouse/Secondary LastName', 'SLastName', :xml_method =>
  46. 'sec_last_name' )
  47. end # if insured_is_married
  48.  
  49. result = @xml_req.phone_home
  50. # Change made to enter all 5s if we were not supplied
  51. # with a phone number.
  52. result = '(555) 555-5555' if ( params[:test] ) or ! result
  53. fill_text_field( 'Home Phone', 'phoneHome', :value => result )
  54.  
  55. # Work phone field (phoneWork) is optional
  56.  
  57. fill_text_field( 'Address 1', 'PropertyAddress_InputAddress_txtAddress1',
  58. :xml_method => 'property_address1' )
  59.  
  60. fill_text_field( 'Address 2', 'PropertyAddress_InputAddress_txtAddress2',
  61. :xml_method => 'property_address2' )
  62.  
  63. fill_text_field( 'City', 'PropertyAddress_InputAddress_txtCity',
  64. :xml_method => 'property_city' )
  65.  
  66. if result = @xml_req.property_state
  67. if 'Other' != result[0, 5]
  68. select_from_list( 'State', 'PropertyAddress_InputAddress_drpState',
  69. :value => result )
  70. else
  71. msg = 'ERROR: Either IBQ or Austin Mutual does not rate in this state.'
  72. log_message msg
  73. @xml_resp.add_error msg
  74. end
  75. end
  76.  
  77. fill_text_field( 'Zip Code', 'PropertyAddress_InputAddress_txtZipCode',
  78. :xml_method => 'property_zip_code' )
  79.  
  80. log_message ' *click* -> Continue(btnContinue)'
  81. element = @ie.button(:id, 'btnContinue')
  82. @wait_time += timer do
  83. element.click_no_wait
  84. popup_check
  85. end
  86. end # hq2
Add Comment
Please, Sign In to add comment