#---
#This unit test checks the enquiry screen, we check things like security, that things appear
#and disapear on the screen correctly and all the fields are available etc.
#---
class Test_02_enquiry < Test::Unit::TestCase
  @@enquirytypes=["-Please select a value-",
                   "Adversarial removal of a meter",
                   "Alteration (relocation or reposition) of an existing meter",
                   "Change of capacity",
                   "Exchange of a Standard meter",
                   "Exchange of non-Standard meter",
                   "Installation of new Standard meter",
                   "Installation of new non-Standard meter",
                   "Other",
                   "Purchase of standard add-ons for an existing meter module",
                   "Removal of a Standard meter",
                   "Removal of non-Standard meter",
                   "Request for OFGEM Meter Accuracy Test (OFMAT)"]
  @@savedenquiryid = ''
  #Create a non-tripartite exclusion so we can test that the AMR option does not
  #appear
  def test_01_create_non_tripartite_exclusion
    @@ie.goto(TRIPARTITE)
    login(DEFAULT, DEFAULT_PWD)
    assert(@@ie.contains_text('Non-Tripartite Exclusion'),'Non-Tripartite Exclusion screen not found')
    assert(@@ie.select_list(:id,'P90_ENTY_CODE').exists?,'Could not find P90_ENTY_CODE select list')
    assert(@@ie.select_list(:id,'P90_REGI_CODE').exists?,'Could not find P90_REGI_CODE select list')
    assert(@@ie.select_list(:id,'P90_ADIT_CODE').exists?,'Could not find P90_ADIT_CODE select list')
    assert(@@ie.button(:value, 'Create').exists?,'Could not find a Save button')
    assert(@@ie.button(:value, 'Cancel').exists?,'Could not find a Cancel button')
    @@ie.select_list(:id,'P90_REGI_CODE').set'East of England'
    @@ie.select_list(:id,'P90_ADIT_CODE').set'Automatic Meter Reading'
    @@ie.button(:value, 'Create').click   
    @@ie.wait  
    assert(@@ie.contains_text('Exclusion saved.'),'Exclusion saved message not found')
  end  
  #
  #Test we can logon to the system using the webmip administrator user's login credentials
  #and create a new enquiry screen
  #
  def test_02_enquiry_screen_appears
    @@ie.goto(ENQUIRY)
    login(DEFAULT, DEFAULT_PWD)
    assert(@@ie.contains_text('Enquiry'),'The enquiry screen did not appear')
    #check the regions appear
    assert(@@ie.contains_text('Site Detail'),'Site Detail region not found')
    assert(@@ie.contains_text('Site Address'),'The Site Address region not found')
    assert(@@ie.contains_text('Contact Details'),'The Contact Details region not found')
    assert(@@ie.contains_text('Job Info'),'The Job Info region not found') 
    #check we've got the save and cancel buttons but not apply changes
    assert(@@ie.button(:class, 'save').exists?,'Could not find a Save button')
    assert(@@ie.button(:value, 'Cancel').exists?,'Could not find a Cancel button')
    assert_not_equal(@@ie.button(:class, 'update').exists?,true,'Found Save(update) button when it should have been hidden')
    #make sure that the ID field is not accessable (a form object)
    #assert_not_equal(@@ie.text_field(:name, 'P32_ID').exists?,true,'Found Apply Changes button when it should have been hidden')
    assert(@@ie.text_field(:id,'P32_ID').exists?,'Could not find P32_ID field')
    assert(@@ie.select_list(:id,'P32_MKTP_REF').exists?,'Could not find P32_MKTP_REF select list')
    assert_equal(false,@@ie.select_list(:id,'P32_MKTP_REF2').exists?,'Found P32_MKTP_REF2 field')
    assert(@@ie.select_list(:id,'P32_ALTY_CODE').exists?,'Could not find P32_ALTY_CODE select list')
    assert(@@ie.select_list(:id,'P32_CACA_CODE').exists?,'Could not find P32_CACA_CODE select list')
    assert(@@ie.select_list(:id,'P32_ASSET_LOCATION_NOTES').exists?,'Could not find P32_ASSET_LOCATION_NOTES select list')
    assert(@@ie.text_field(:id,'P32_ACCESS_PASSWORD').exists?,'Could not find P32_ACCESS_PASSWORD field')
    assert(@@ie.text_field(:id,'P32_ACCESS_ADDITIONAL').exists?,'Could not find P32_ACCESS_ADDITIONAL field')
    #assert(@@ie.text_field(:id,'P32_MPRN').exists?,'Could not find P32_MPRN field')
    #assert(@@ie.text_field(:id,'P32_MPRN_ALT').exists?,'Could not find P32_MPRN_ALT field')
    assert(@@ie.text_field(:id,'P32_TRANSACTION_REFERENCE').exists?,'Could not find P32_TRANSACTION_REFERENCE field')
    assert(@@ie.text_field(:id,'P32_FIRST_CONTACT_TITLE').exists?,'Could not find P32_FIRST_CONTACT_FAX field')
    assert(@@ie.text_field(:id,'P32_FIRST_CONTACT_INITIALS').exists?,'Could not find P32_FIRST_CONTACT_FAX field')
    assert(@@ie.text_field(:id,'P32_FIRST_CONTACT_NAME').exists?,'Could not find P32_FIRST_CONTACT_NAME field')
    assert(@@ie.text_field(:id,'P32_FIRST_CONTACT_TELEPHONE_1').exists?,'Could not find P32_FIRST_CONTACT_TELEPHONE_1 field')
    assert(@@ie.text_field(:id,'P32_FIRST_CONTACT_TELEPHONE_2').exists?,'Could not find P32_FIRST_CONTACT_TELEPHONE_2 field')    
    assert(@@ie.text_field(:id,'P32_FIRST_CONTACT_FAX').exists?,'Could not find P32_FIRST_CONTACT_FAX field')
    assert(@@ie.text_field(:id,'P32_FIRST_CONTACT_EMAIL').exists?,'Could not find P32_FIRST_CONTACT_FAX field')
    assert(@@ie.text_field(:id,'P32_INSTALL_SUB_BUILDING').exists?,'Could not find P32_INSTALL_SUB_BUILDING field')
    assert(@@ie.text_field(:id,'P32_INSTALL_BUILDING').exists?,'Could not find P32_INSTALL_BUILDING field')
    assert(@@ie.text_field(:id,'P32_INSTALL_STREET').exists?,'Could not find P32_INSTALL_STREET field')
    assert(@@ie.text_field(:id,'P32_INSTALL_CITY').exists?,'Could not find P32_INSTALL_CITY field')
    assert(@@ie.text_field(:id,'P32_INSTALL_POSTCODE').exists?,'Could not find P32_INSTALL_POSTCODE field')
    assert(@@ie.select_list(:id,'P32_INSTALL_ADDRESS').exists?,'Could not find P32_INSTALL_ADDRESS select list')
    assert(@@ie.select_list(:id,'P32_SECOND_CONTACT').exists?,'Could not find P32_SECOND_CONTACT select list')
    assert(@@ie.select_list(:id,'P32_ENTY_CODE').exists?,'Could not find P32_ENTY_CODE select list')
    assert_equal(@@enquirytypes,@@ie.select_list(:id,'P32_ENTY_CODE').getAllContents,'List of options for P32_ENTY_CODE did not match what was expected') 
    assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_METER_OWNER').exists?,'Found P32_EXISTING_METER_OWNER field')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_ASSET_PROVIDER').exists?,'Could not find P32_EXISTING_METER_ASSET_PROVIDER field')
    assert(@@ie.select_list(:id,'P32_INDICATIVE_TIME').exists?,'Could not find P32_INDICATIVE_TIME select list')
    assert_equal(false,@@ie.select_list(:id,'P32_REQUIRED_SVCP_CODE').exists?,'Found P32_REQUIRED_SVCP_CODE select list')
    assert_equal(false,@@ie.text_field(:id,'P32_ANNUAL_QUANTITY').exists?,'Found P32_ANNUAL_QUANTITY field')
    assert_equal(false,@@ie.text_field(:id,'P32_REQUIRED_METERING_PRESSURE').exists?,'Found P32_REQUIRED_METERING_PRESSURE field')
    assert_equal(false,@@ie.select_list(:id,'P32_DS_BOOSTER_OR_COMPRESS').exists?,'Found P32_DS_BOOSTER_OR_COMPRESS select list')
    assert(@@ie.text_field(:id,'P32_INDICATIVE_DATE').exists?,'Could not find P32_INDICATIVE_DATE field')
    assert(@@ie.text_field(:id,'P32_OTHER_PROJECT_REFERENCE').exists?,'Could not find P32_OTHER_PROJECT_REFERENCE field')
    assert_equal(false,@@ie.select_list(:id,'P32_HOUSING_REQUIRED').exists?,'Found P32_HOUSING_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_BASE_REQUIRED').exists?,'Found P32_BASE_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_CONVERTOR_REQUIRED').exists?,'Found P32_CONVERTOR_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_AMR_REQUIRED').exists?,'found P32_AMR_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_EMS_REQUIRED').exists?,'Found P32_EMS_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_BYPASS_REQUIRED').exists?,'Found P32_BYPASS_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_LOAD_CONTROL_TYPE').exists?,'Found P32_LOAD_CONTROL_TYPE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_TWIN_STREAM_REQUIRED').exists?,'Found P32_TWIN_STREAM_REQUIRED select list')
    assert(@@ie.text_field(:id,'P32_JOB_DESCRIPTION').exists?,'Could not find P32_JOB_DESCRIPTION field')
    assert(@@ie.text_field(:id,'P32_QMAX').exists?,'Could not find P32_QMAX field')
    assert(@@ie.text_field(:id,'P32_QMIN').exists?,'Could not find P32_QMIN field')
    assert_equal(false,@@ie.select_list(:id,'P32_REQUIRED_MESC_CODE').exists?,'Found P32_REQUIRED_MESC_CODE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_METY_CODE').exists?,'Found P32_METY_CODE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').exists?,'found P32_EXISTING_MESC_CODE select list')
    assert_equal(false,@@ie.text_field(:id,'P32_EXISTING_METER_SERIAL_NO').exists?,'Found P32_EXISTING_METER_SERIAL_NO field')
    assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_PRTY_ID').exists?,'Found P32_EXISTING_PRTY_ID field')
    assert(@@ie.select_list(:id,'P32_MARKET_SECTOR_CODE').exists?,'Could not find P32_MARKET_SECTOR_CODE select list')
    assert(@@ie.text_field(:id,'P32_OTHER_INFORMATION').exists?,'Could not find P32_OTHER_INFORMATION field')      
    assert_equal(false,@@ie.text_field(:id,'P32_EXISTING_LOGGER').exists?,'Found P32_EXISTING_LOGGER select list')
    assert_equal(false,@@ie.text_field(:id,'P32_EXISTING_CONVERTOR').exists?,'Found P32_EXISTING_CONVERTOR select list')
  end
  #
  #Ensure that the screen refreshes and displays the agents drop down list
  #when we choose a supplier
  #
  def test_03_check_agent_appears_when_supplier_selected
   listofagents=["-Please select a value-","Fred Smith","Joe Bloggs"]
   @@ie.select_list(:id,'P32_MKTP_REF').set "Northern Supplies"
   @@ie.wait
   assert(@@ie.select_list(:id,'P32_AGENT_ID').exists?,'Could not find P32_AGENT_ID select list')
   assert_equal(listofagents,@@ie.select_list(:id, 'P32_AGENT_ID').getAllContents ,'The expected list of agents was not found')    
  end
  #
  #Ensure that the screen refreshes and displays the agents contact mechanism drop down list
  #when we choose an agent
  #
  def test_04_check_contact_mechs_appear_when_agent_selected
   listofcontactmech=["-Please select a value-","Email","Fax","Mobile","Telephone"]
   @@ie.select_list(:id,'P32_AGENT_ID').set "Fred Smith"
   @@ie.wait
   assert(@@ie.select_list(:id,'P32_AGENT_COMT_CODE').exists?,'Could not find P32_AGENT_COMT_CODE(agent contact mechanisms) select list')
   assert_equal(listofcontactmech,@@ie.select_list(:id, 'P32_AGENT_COMT_CODE').getAllContents ,'The expected list of contact mechanisms was not found')    
  end
  #
  #Check that the contact value is displayed when the mechanism is selected
  #
  def test_05_check_contact_mech_value_appears_when_mechanism_selected
   @@ie.select_list(:id,'P32_AGENT_COMT_CODE').set "Email"
   @@ie.wait
   assert(@@ie.text_field(:id,'P32_AGENT_CONTACT_VALUE').exists?,'Could not find P32_AGENT_CONTACT_VALUE field')   
  end
  #
  #Check that the file upload is displayed when the mechanism
  #for delivering asset location notes is selected
  #
  def test_06_check_file_upload_appears_when_asset_location_mechanism_selected
  listofcontactmech=["-Please select a value-","Post","Fax","Email","Upload"]
   @@ie.select_list(:id,'P32_ASSET_LOCATION_NOTES').set "Upload"
   @@ie.wait
   assert_equal(listofcontactmech,@@ie.select_list(:id, 'P32_ASSET_LOCATION_NOTES').getAllContents ,'The expected list of asset location delivery mechanisms was not found')    
   assert(@@ie.file_field(:id,'P32_UPLOAD_ASSET_LOCATION_NOTES').exists?,'Could not find P32_UPLOAD_ASSET_LOCATION_NOTES file_field')   
  end
  #
  #Check that the contacts address appears if you select no (the contact
  #address is not the same as the site address)
  #
  def test_07_check_contact_address_fields_appear_when_no_is_selected
   listofoptions=["Yes","No"]
   @@ie.select_list(:id,'P32_INSTALL_ADDRESS').set "No"
   @@ie.wait
   assert_equal(listofoptions,@@ie.select_list(:id, 'P32_INSTALL_ADDRESS').getAllContents ,'The expected yes/no list for address same as site was not found')    
   assert(@@ie.text_field(:id,'P32_FIRST_CONTACT_NAME').exists?,'Could not find P32_FIRST_CONTACT_NAME field')
   assert(@@ie.text_field(:id,'P32_FIRST_ALT_SUB_BUILDING').exists?,'Could not find P32_FIRST_ALT_SUB_BUILDING field')
   assert(@@ie.text_field(:id,'P32_FIRST_ALT_BUILDING').exists?,'Could not find P32_FIRST_ALT_BUILDING field')
   assert(@@ie.text_field(:id,'P32_FIRST_ALT_STREET').exists?,'Could not find P32_FIRST_ALT_STREET field')
   assert(@@ie.text_field(:id,'P32_FIRST_ALT_CITY').exists?,'Could not find P32_FIRST_ALT_CITY field')
   assert(@@ie.text_field(:id,'P32_FIRST_ALT_POSTCODE').exists?,'Could not find P32_FIRST_ALT_POSTCODE field')
  end
  #
  #Check that the 2nd contacts address appears if you select yes (there
  # is a second contact address)
  #
  def test_08_check_second_contact_address_fields_appear_when_no_is_selected
    listofoptions=["Yes","No"]
    @@ie.select_list(:id,'P32_SECOND_CONTACT').set "Yes"
    @@ie.wait
    assert_equal(listofoptions,@@ie.select_list(:id, 'P32_SECOND_CONTACT').getAllContents ,'The expected yes/no list for 2nd contact was not found')    
    assert(@@ie.text_field(:id,'P32_SECOND_CONTACT_TITLE').exists?,'Could not find P32_FIRST_CONTACT_FAX field')
    assert(@@ie.text_field(:id,'P32_SECOND_CONTACT_INITIALS').exists?,'Could not find P32_FIRST_CONTACT_FAX field')
    assert(@@ie.text_field(:id,'P32_SECOND_CONTACT_NAME').exists?,'Could not find P32_FIRST_CONTACT_NAME field')
    assert(@@ie.text_field(:id,'P32_SECOND_CONTACT_TELEPHONE_1').exists?,'Could not find P32_FIRST_CONTACT_TELEPHONE_1 field')
    assert(@@ie.text_field(:id,'P32_SECOND_CONTACT_TELEPHONE_2').exists?,'Could not find P32_FIRST_CONTACT_TELEPHONE_2 field')    
    assert(@@ie.text_field(:id,'P32_SECOND_CONTACT_FAX').exists?,'Could not find P32_FIRST_CONTACT_FAX field')
    assert(@@ie.text_field(:id,'P32_SECOND_CONTACT_EMAIL').exists?,'Could not find P32_FIRST_CONTACT_FAX field')
    assert(@@ie.text_field(:id,'P32_SECOND_ALT_SUB_BUILDING').exists?,'Could not find P32_SECOND_ALT_SUB_BUILDING field')
    assert(@@ie.text_field(:id,'P32_SECOND_ALT_BUILDING').exists?,'Could not find P32_SECOND_ALT_BUILDING field')
    assert(@@ie.text_field(:id,'P32_SECOND_ALT_STREET').exists?,'Could not find P32_SECOND_ALT_STREET field')
    assert(@@ie.text_field(:id,'P32_SECOND_ALT_CITY').exists?,'Could not find P32_SECOND_ALT_CITY field')
    assert(@@ie.text_field(:id,'P32_SECOND_ALT_POSTCODE').exists?,'Could not find P32_SECOND_ALT_POSTCODE field')
  end
  #
  #Check all the correct fields are displayed when a non standard install job is selected
  #Note: AMR should not be visible as none of the data load parties is set to be 
  #a tripartite member
  #
  def test_09_install_selected_check_fields_appear_available
     #Set the postcode so that AMR should not appear for installs
     #
     @@ie.text_field(:id,'P32_INSTALL_POSTCODE').set 'LE11 3GR'
     @@ie.select_list(:id,'P32_ENTY_CODE').set @@enquirytypes[7]
     @@ie.wait
     assert_equal(@@enquirytypes,@@ie.select_list(:id, 'P32_ENTY_CODE').getAllContents ,'The expected list for job type was not found')    
     assert(@@ie.select_list(:id,'P32_EXISTING_METER_OWNER').exists?,'Could not find P32_EXISTING_METER_OWNER field')
     assert(@@ie.text_field(:id,'P32_EXISTING_METER_ASSET_PROVIDER').exists?,'Could not find P32_EXISTING_METER_ASSET_PROVIDER field')
     assert(@@ie.select_list(:id,'P32_INDICATIVE_TIME').exists?,'Could not find P32_INDICATIVE_TIME select list')
     assert(@@ie.select_list(:id,'P32_REQUIRED_SVCP_CODE').exists?,'Could not find P32_REQUIRED_SVCP_CODE select list')
     assert(@@ie.text_field(:id,'P32_ANNUAL_QUANTITY').exists?,'Could not find P32_ANNUAL_QUANTITY field')
     assert(@@ie.text_field(:id,'P32_REQUIRED_METERING_PRESSURE').exists?,'Could not find P32_REQUIRED_METERING_PRESSURE field')
     assert(@@ie.select_list(:id,'P32_DS_BOOSTER_OR_COMPRESS').exists?,'Could not find P32_DS_BOOSTER_OR_COMPRESS select list')
     assert(@@ie.text_field(:id,'P32_INDICATIVE_DATE').exists?,'Could not find P32_INDICATIVE_DATE field')
     assert(@@ie.text_field(:id,'P32_OTHER_PROJECT_REFERENCE').exists?,'Could not find P32_OTHER_PROJECT_REFERENCE field')
     assert(@@ie.select_list(:id,'P32_HOUSING_REQUIRED').exists?,'Could not find P32_HOUSING_REQUIRED select list')
     assert(@@ie.select_list(:id,'P32_BASE_REQUIRED').exists?,'Could not find P32_BASE_REQUIRED select list')
     assert(@@ie.select_list(:id,'P32_CONVERTOR_REQUIRED').exists?,'Could not find P32_CONVERTOR_REQUIRED select list')
     assert_equal(false,@@ie.select_list(:id,'P32_AMR_REQUIRED').exists?,'Found P32_AMR_REQUIRED select list')
     assert(@@ie.select_list(:id,'P32_EMS_REQUIRED').exists?,'Could not find P32_EMS_REQUIRED select list')
     assert(@@ie.select_list(:id,'P32_BYPASS_REQUIRED').exists?,'Could not find P32_BYPASS_REQUIRED select list')
     assert(@@ie.select_list(:id,'P32_LOAD_CONTROL_TYPE').exists?,'Could not find P32_LOAD_CONTROL_TYPE select list')
     assert(@@ie.select_list(:id,'P32_TWIN_STREAM_REQUIRED').exists?,'Could not find P32_TWIN_STREAM_REQUIRED select list')
     assert(@@ie.text_field(:id,'P32_JOB_DESCRIPTION').exists?,'Could not find P32_JOB_DESCRIPTION field')
     assert(@@ie.text_field(:id,'P32_QMAX').exists?,'Could not find P32_QMAX field')
     assert(@@ie.text_field(:id,'P32_QMIN').exists?,'Could not find P32_QMIN field')
     assert_equal(false,@@ie.select_list(:id,'P32_REQUIRED_MESC_CODE').exists?,'Found P32_REQUIRED_MESC_CODE select list')
     assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_METY_CODE').exists?,'Found P32_METY_CODE select list')
     assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').exists?,'Found P32_EXISTING_MESC_CODE select list')
     assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_SVCP_CODE').exists?,'Found P32_EXISTING_SVCP_CODE select list')
     assert_equal(false,@@ie.text_field(:id,'P32_EXISTING_METER_SERIAL_NO').exists?,'Found P32_EXISTING_METER_SERIAL_NO field')
     assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_METER_MODEL').exists?,'Found P32_EXISTING_METER_MODEL field')
     assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_PRTY_ID').exists?,'Found P32_EXISTING_PRTY_ID field') 
     assert(@@ie.select_list(:id,'P32_MARKET_SECTOR_CODE').exists?,'Could not find P32_MARKET_SECTOR_CODE select list')
     assert(@@ie.text_field(:id,'P32_OTHER_INFORMATION').exists?,'Could not find P32_OTHER_INFORMATION field')
     assert_equal(false,@@ie.text_field(:id,'P32_EXISTING_LOGGER').exists?,'Found P32_EXISTING_LOGGER select list')
     assert_equal(false,@@ie.text_field(:id,'P32_EXISTING_CONVERTOR').exists?,'Found P32_EXISTING_CONVERTOR select list')
     #Now need to test for the following fields after AH made fix for ticket #404
    assert(@@ie.select_list(:id,'P32_REQUIRED_SVCP_CODE').exists?,'Could not find P32_REQUIRED_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_REQUIRED_METERING_PRESSURE').exists?,'Could not find P32_REQUIRED_METERING_PRESSURE field')

  end
  #
  #Check all the correct fields are displayed when a standard job is selected
  #Note: AMR should not be visible as none of the data load parties is set to be 
  #a tripartite member
  def test_10_std_install_selected_check_fields_appear_available
     @@ie.select_list(:id,'P32_ENTY_CODE').set @@enquirytypes[6]
     @@ie.wait
     assert_equal(@@enquirytypes,@@ie.select_list(:id, 'P32_ENTY_CODE').getAllContents ,'The expected list for job type was not found')    
     assert(@@ie.select_list(:id,'P32_EXISTING_METER_OWNER').exists?,'Could not find P32_EXISTING_METER_OWNER field')
     assert(@@ie.text_field(:id,'P32_EXISTING_METER_ASSET_PROVIDER').exists?,'Could not find P32_EXISTING_METER_ASSET_PROVIDER field')
     assert(@@ie.select_list(:id,'P32_INDICATIVE_TIME').exists?,'Could not find P32_INDICATIVE_TIME select list')
     assert(@@ie.select_list(:id,'P32_REQUIRED_SVCP_CODE').exists?,'Could not find P32_REQUIRED_SVCP_CODE select list')
     assert(@@ie.text_field(:id,'P32_ANNUAL_QUANTITY').exists?,'Could not find P32_ANNUAL_QUANTITY field')
     assert(@@ie.text_field(:id,'P32_REQUIRED_METERING_PRESSURE').exists?,'Could not find P32_REQUIRED_METERING_PRESSURE field')
     assert(@@ie.select_list(:id,'P32_DS_BOOSTER_OR_COMPRESS').exists?,'Could not find P32_DS_BOOSTER_OR_COMPRESS select list')
     assert(@@ie.text_field(:id,'P32_INDICATIVE_DATE').exists?,'Could not find P32_INDICATIVE_DATE field')
     assert(@@ie.text_field(:id,'P32_OTHER_PROJECT_REFERENCE').exists?,'Could not find P32_OTHER_PROJECT_REFERENCE field')
     assert(@@ie.select_list(:id,'P32_HOUSING_REQUIRED').exists?,'Could not find P32_HOUSING_REQUIRED select list')
     assert(@@ie.select_list(:id,'P32_BASE_REQUIRED').exists?,'Could not find P32_BASE_REQUIRED select list')
     assert(@@ie.select_list(:id,'P32_CONVERTOR_REQUIRED').exists?,'Could not find P32_CONVERTOR_REQUIRED select list')
     assert_equal(false,@@ie.select_list(:id,'P32_AMR_REQUIRED').exists?,'Found P32_AMR_REQUIRED select list')
     assert(@@ie.select_list(:id,'P32_EMS_REQUIRED').exists?,'Could not find P32_EMS_REQUIRED select list')
     assert(@@ie.select_list(:id,'P32_BYPASS_REQUIRED').exists?,'Could not find P32_BYPASS_REQUIRED select list')
     assert(@@ie.select_list(:id,'P32_LOAD_CONTROL_TYPE').exists?,'Could not find P32_LOAD_CONTROL_TYPE select list')
     assert(@@ie.select_list(:id,'P32_TWIN_STREAM_REQUIRED').exists?,'Could not find P32_TWIN_STREAM_REQUIRED select list')
     assert(@@ie.text_field(:id,'P32_JOB_DESCRIPTION').exists?,'Could not find P32_JOB_DESCRIPTION field')
     assert(@@ie.text_field(:id,'P32_QMAX').exists?,'Could not find P32_QMAX field')
     assert(@@ie.text_field(:id,'P32_QMIN').exists?,'Could not find P32_QMIN field')
     assert(@@ie.select_list(:id,'P32_REQUIRED_MESC_CODE').exists?,'Could not find P32_REQUIRED_MESC_CODE select list')
     assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_METY_CODE').exists?,'Found P32_METY_CODE select list')
     assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').exists?,'Found P32_EXISTING_MESC_CODE select list')
     assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_SVCP_CODE').exists?,'Found P32_EXISTING_SVCP_CODE select list')
     assert_equal(false,@@ie.text_field(:id,'P32_EXISTING_METER_SERIAL_NO').exists?,'Found P32_EXISTING_METER_SERIAL_NO field')
     assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_METER_MODEL').exists?,'Found P32_EXISTING_METER_MODEL field')
     assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_PRTY_ID').exists?,'Found P32_EXISTING_PRTY_ID field')
     assert(@@ie.select_list(:id,'P32_MARKET_SECTOR_CODE').exists?,'Could not find P32_MARKET_SECTOR_CODE select list')
     assert(@@ie.text_field(:id,'P32_OTHER_INFORMATION').exists?,'Could not find P32_OTHER_INFORMATION field')
     assert_equal(false,@@ie.text_field(:id,'P32_EXISTING_LOGGER').exists?,'Found P32_EXISTING_LOGGER select list')
     assert_equal(false,@@ie.text_field(:id,'P32_EXISTING_CONVERTOR').exists?,'Found P32_EXISTING_CONVERTOR select list')
  end
  def test_11_ofmat_selected_check_fields_appear_available
    @@ie.select_list(:id,'P32_ENTY_CODE').set @@enquirytypes[12]
    @@ie.wait
    assert_equal(@@enquirytypes,@@ie.select_list(:id, 'P32_ENTY_CODE').getAllContents ,'The expected list for job type was not found')    
    assert(@@ie.select_list(:id,'P32_EXISTING_METER_OWNER').exists?,'Could not find P32_EXISTING_METER_OWNER field')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_ASSET_PROVIDER').exists?,'Could not find P32_EXISTING_METER_ASSET_PROVIDER field')
    assert(@@ie.select_list(:id,'P32_INDICATIVE_TIME').exists?,'Could not find P32_INDICATIVE_TIME select list')
    assert(@@ie.select_list(:id,'P32_REQUIRED_SVCP_CODE').exists?,'Could not find P32_REQUIRED_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_ANNUAL_QUANTITY').exists?,'Could not find P32_ANNUAL_QUANTITY field')
    assert(@@ie.text_field(:id,'P32_REQUIRED_METERING_PRESSURE').exists?,'Could not find P32_REQUIRED_METERING_PRESSURE field')
    assert(@@ie.select_list(:id,'P32_DS_BOOSTER_OR_COMPRESS').exists?,'Could not find P32_DS_BOOSTER_OR_COMPRESS select list')
    assert(@@ie.text_field(:id,'P32_INDICATIVE_DATE').exists?,'Could not find P32_INDICATIVE_DATE field')
    assert(@@ie.text_field(:id,'P32_OTHER_PROJECT_REFERENCE').exists?,'Could not find P32_OTHER_PROJECT_REFERENCE field')
    assert_equal(false,@@ie.select_list(:id,'P32_HOUSING_REQUIRED').exists?,'Found P32_HOUSING_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_BASE_REQUIRED').exists?,'Found P32_BASE_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_CONVERTOR_REQUIRED').exists?,'Found P32_CONVERTOR_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_AMR_REQUIRED').exists?,'Found P32_AMR_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_EMS_REQUIRED').exists?,'Found P32_EMS_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_BYPASS_REQUIRED').exists?,'Found P32_BYPASS_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_LOAD_CONTROL_TYPE').exists?,'Found P32_LOAD_CONTROL_TYPE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_TWIN_STREAM_REQUIRED').exists?,'Found P32_TWIN_STREAM_REQUIRED select list')
    assert(@@ie.text_field(:id,'P32_JOB_DESCRIPTION').exists?,'Could not find P32_JOB_DESCRIPTION field')
    assert(@@ie.text_field(:id,'P32_QMAX').exists?,'Could not find P32_QMAX field')
    assert(@@ie.text_field(:id,'P32_QMIN').exists?,'Could not find P32_QMIN field')
    assert_equal(false,@@ie.select_list(:id,'P32_REQUIRED_MESC_CODE').exists?,'Found P32_REQUIRED_MESC_CODE select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_METY_CODE').exists?,'Could not find P32_METY_CODE select list')
    #assert(@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').exists?,'Could not find P32_EXISTING_MESC_CODE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_SVCP_CODE').exists?,'Found P32_EXISTING_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_SERIAL_NO').exists?,'Could not find P32_EXISTING_METER_SERIAL_NO field')
    assert(@@ie.select_list(:id,'P32_EXISTING_METR_CODE').exists?,'Could not find P32_EXISTING_METR_CODE field')
    assert(@@ie.select_list(:id,'P32_EXISTING_PRTY_ID').exists?,'Could not find P32_EXISTING_PRTY_ID field')
    assert(@@ie.select_list(:id,'P32_MARKET_SECTOR_CODE').exists?,'Could not find P32_MARKET_SECTOR_CODE select list')
    assert(@@ie.text_field(:id,'P32_OTHER_INFORMATION').exists?,'Could not find P32_OTHER_INFORMATION field')
    assert_equal(false,@@ie.text_field(:id,'P32_EXISTING_LOGGER').exists?,'Found P32_EXISTING_LOGGER select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_CONVERTOR').exists?,'Could not Find P32_EXISTING_CONVERTOR select list')
  end
  def test_12_exchange_selected_check_fields_appear_available
    @@ie.select_list(:id,'P32_ENTY_CODE').set @@enquirytypes[5]
    @@ie.wait
    assert_equal(@@enquirytypes,@@ie.select_list(:id, 'P32_ENTY_CODE').getAllContents ,'The expected list for job type was not found')    
    assert(@@ie.select_list(:id,'P32_EXISTING_METER_OWNER').exists?,'Could not find P32_EXISTING_METER_OWNER field')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_ASSET_PROVIDER').exists?,'Could not find P32_EXISTING_METER_ASSET_PROVIDER field')
    assert(@@ie.select_list(:id,'P32_INDICATIVE_TIME').exists?,'Could not find P32_INDICATIVE_TIME select list')
    assert(@@ie.select_list(:id,'P32_REQUIRED_SVCP_CODE').exists?,'Could not find P32_REQUIRED_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_ANNUAL_QUANTITY').exists?,'Could not find P32_ANNUAL_QUANTITY field')
    assert(@@ie.text_field(:id,'P32_REQUIRED_METERING_PRESSURE').exists?,'Could not find P32_REQUIRED_METERING_PRESSURE field')
    assert(@@ie.select_list(:id,'P32_DS_BOOSTER_OR_COMPRESS').exists?,'Could not find P32_DS_BOOSTER_OR_COMPRESS select list')
    assert(@@ie.text_field(:id,'P32_INDICATIVE_DATE').exists?,'Could not find P32_INDICATIVE_DATE field')
    assert(@@ie.text_field(:id,'P32_OTHER_PROJECT_REFERENCE').exists?,'Could not find P32_OTHER_PROJECT_REFERENCE field')
    assert(@@ie.select_list(:id,'P32_HOUSING_REQUIRED').exists?,'Could not find P32_HOUSING_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_BASE_REQUIRED').exists?,'Could not find P32_BASE_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_CONVERTOR_REQUIRED').exists?,'Could not find P32_CONVERTOR_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_AMR_REQUIRED').exists?,'Found P32_AMR_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_EMS_REQUIRED').exists?,'Could not find P32_EMS_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_BYPASS_REQUIRED').exists?,'Could not find P32_BYPASS_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_LOAD_CONTROL_TYPE').exists?,'Could not find P32_LOAD_CONTROL_TYPE select list')
    assert(@@ie.select_list(:id,'P32_TWIN_STREAM_REQUIRED').exists?,'Could not find P32_TWIN_STREAM_REQUIRED select list')
    assert(@@ie.text_field(:id,'P32_JOB_DESCRIPTION').exists?,'Could not find P32_JOB_DESCRIPTION field')
    assert(@@ie.text_field(:id,'P32_QMAX').exists?,'Could not find P32_QMAX field')
    assert(@@ie.text_field(:id,'P32_QMIN').exists?,'Could not find P32_QMIN field')
    assert_equal(false,@@ie.select_list(:id,'P32_REQUIRED_MESC_CODE').exists?,'Found P32_REQUIRED_MESC_CODE select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_METY_CODE').exists?,'Could not find P32_EXISTING_METY_CODE select list')
    #assert(@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').exists?,'Could not find P32_EXISTING_MESC_CODE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_SVCP_CODE').exists?,'Found P32_EXISTING_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_SERIAL_NO').exists?,'Could not find P32_EXISTING_METER_SERIAL_NO field')
    assert(@@ie.select_list(:id,'P32_EXISTING_METR_CODE').exists?,'Could not find P32_EXISTING_METR_CODE field')
    assert(@@ie.select_list(:id,'P32_EXISTING_PRTY_ID').exists?,'Could not find P32_EXISTING_PRTY_ID field')
    assert(@@ie.select_list(:id,'P32_MARKET_SECTOR_CODE').exists?,'Could not find P32_MARKET_SECTOR_CODE select list')
    assert(@@ie.text_field(:id,'P32_OTHER_INFORMATION').exists?,'Could not find P32_OTHER_INFORMATION field')
    assert(@@ie.select_list(:id,'P32_EXISTING_LOGGER').exists?,'Could not find P32_EXISTING_LOGGER select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_CONVERTOR').exists?,'Could not find P32_EXISTING_CONVERTOR select list')
  end
  def test_13_std_exchange_selected_check_fields_appear_available
    @@ie.select_list(:id,'P32_ENTY_CODE').set @@enquirytypes[4]
    @@ie.wait
    assert_equal(@@enquirytypes,@@ie.select_list(:id, 'P32_ENTY_CODE').getAllContents ,'The expected list for job type was not found')    
    assert(@@ie.select_list(:id,'P32_EXISTING_METER_OWNER').exists?,'Could not find P32_EXISTING_METER_OWNER field')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_ASSET_PROVIDER').exists?,'Could not find P32_EXISTING_METER_ASSET_PROVIDER field')
    assert(@@ie.select_list(:id,'P32_INDICATIVE_TIME').exists?,'Could not find P32_INDICATIVE_TIME select list')
    assert(@@ie.select_list(:id,'P32_REQUIRED_SVCP_CODE').exists?,'Could not find P32_REQUIRED_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_ANNUAL_QUANTITY').exists?,'Could not find P32_ANNUAL_QUANTITY field')
    assert(@@ie.text_field(:id,'P32_REQUIRED_METERING_PRESSURE').exists?,'Could not find P32_REQUIRED_METERING_PRESSURE field')
    assert(@@ie.select_list(:id,'P32_DS_BOOSTER_OR_COMPRESS').exists?,'Could not find P32_DS_BOOSTER_OR_COMPRESS select list')
    assert(@@ie.text_field(:id,'P32_INDICATIVE_DATE').exists?,'Could not find P32_INDICATIVE_DATE field')
    assert(@@ie.text_field(:id,'P32_OTHER_PROJECT_REFERENCE').exists?,'Could not find P32_OTHER_PROJECT_REFERENCE field')
    assert(@@ie.select_list(:id,'P32_HOUSING_REQUIRED').exists?,'Could not find P32_HOUSING_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_BASE_REQUIRED').exists?,'Could not find P32_BASE_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_CONVERTOR_REQUIRED').exists?,'Could not find P32_CONVERTOR_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_AMR_REQUIRED').exists?,'Found P32_AMR_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_EMS_REQUIRED').exists?,'Could not find P32_EMS_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_BYPASS_REQUIRED').exists?,'Could not find P32_BYPASS_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_LOAD_CONTROL_TYPE').exists?,'Could not find P32_LOAD_CONTROL_TYPE select list')
    assert(@@ie.select_list(:id,'P32_TWIN_STREAM_REQUIRED').exists?,'Could not find P32_TWIN_STREAM_REQUIRED select list')
    assert(@@ie.text_field(:id,'P32_JOB_DESCRIPTION').exists?,'Could not find P32_JOB_DESCRIPTION field')
    assert(@@ie.text_field(:id,'P32_QMAX').exists?,'Could not find P32_QMAX field')
    assert(@@ie.text_field(:id,'P32_QMIN').exists?,'Could not find P32_QMIN field')
    assert(@@ie.select_list(:id,'P32_REQUIRED_MESC_CODE').exists?,'Could not find P32_REQUIRED_MESC_CODE select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_METY_CODE').exists?,'Could not find P32_EXISTING_METY_CODE select list')
    #assert(@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').exists?,'Could not find P32_EXISTING_MESC_CODE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_SVCP_CODE').exists?,'Found P32_EXISTING_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_SERIAL_NO').exists?,'Could not find P32_EXISTING_METER_SERIAL_NO field')
    assert(@@ie.select_list(:id,'P32_EXISTING_PRTY_ID').exists?,'Could not find P32_EXISTING_PRTY_ID field')
    assert(@@ie.select_list(:id,'P32_EXISTING_METR_CODE').exists?,'Could not find P32_EXISTING_METR_CODE field')
    assert(@@ie.select_list(:id,'P32_MARKET_SECTOR_CODE').exists?,'Could not find P32_MARKET_SECTOR_CODE select list')
    assert(@@ie.text_field(:id,'P32_OTHER_INFORMATION').exists?,'Could not find P32_OTHER_INFORMATION field')
    assert(@@ie.select_list(:id,'P32_EXISTING_LOGGER').exists?,'Could not find P32_EXISTING_LOGGER select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_CONVERTOR').exists?,'Could not find P32_EXISTING_CONVERTOR select list')
  end
  def test_14_remove_selected_check_fields_appear_available
    @@ie.select_list(:id,'P32_ENTY_CODE').set @@enquirytypes[11]
    @@ie.wait
    assert_equal(@@enquirytypes,@@ie.select_list(:id, 'P32_ENTY_CODE').getAllContents ,'The expected list for job type was not found')    
    assert(@@ie.select_list(:id,'P32_EXISTING_METER_OWNER').exists?,'Could not find P32_EXISTING_METER_OWNER field')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_ASSET_PROVIDER').exists?,'Could not find P32_EXISTING_METER_ASSET_PROVIDER field')
    assert(@@ie.select_list(:id,'P32_INDICATIVE_TIME').exists?,'Could not find P32_INDICATIVE_TIME select list')
    assert(@@ie.select_list(:id,'P32_REQUIRED_SVCP_CODE').exists?,'Could not find P32_REQUIRED_SVCP_CODE select list')
    assert_equal(false,@@ie.text_field(:id,'P32_ANNUAL_QUANTITY').exists?,'Found P32_ANNUAL_QUANTITY field')
    assert(@@ie.text_field(:id,'P32_REQUIRED_METERING_PRESSURE').exists?,'Could not find P32_REQUIRED_METERING_PRESSURE field')
    assert_equal(false,@@ie.select_list(:id,'P32_DS_BOOSTER_OR_COMPRESS').exists?,'Found P32_DS_BOOSTER_OR_COMPRESS select list')
    assert(@@ie.text_field(:id,'P32_INDICATIVE_DATE').exists?,'Could not find P32_INDICATIVE_DATE field')
    assert(@@ie.text_field(:id,'P32_OTHER_PROJECT_REFERENCE').exists?,'Could not find P32_OTHER_PROJECT_REFERENCE field')
    assert_equal(false,@@ie.select_list(:id,'P32_HOUSING_REQUIRED').exists?,'Found P32_HOUSING_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_BASE_REQUIRED').exists?,'Found P32_BASE_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_CONVERTOR_REQUIRED').exists?,'found P32_CONVERTOR_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_AMR_REQUIRED').exists?,'Found P32_AMR_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_EMS_REQUIRED').exists?,'Found P32_EMS_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_BYPASS_REQUIRED').exists?,'Found P32_BYPASS_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_LOAD_CONTROL_TYPE').exists?,'Found P32_LOAD_CONTROL_TYPE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_TWIN_STREAM_REQUIRED').exists?,'Found P32_TWIN_STREAM_REQUIRED select list')
    assert(@@ie.text_field(:id,'P32_JOB_DESCRIPTION').exists?,'Could not find P32_JOB_DESCRIPTION field')
    assert(@@ie.text_field(:id,'P32_QMAX').exists?,'Could not find P32_QMAX field')
    assert(@@ie.text_field(:id,'P32_QMIN').exists?,'Could not find P32_QMIN field')
    assert_equal(false,@@ie.select_list(:id,'P32_REQUIRED_MESC_CODE').exists?,'Found P32_REQUIRED_MESC_CODE select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_METY_CODE').exists?,'Could not find P32_METY_CODE select list')
    #assert(@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').exists?,'Could not find P32_EXISTING_MESC_CODE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_SVCP_CODE').exists?,'Found P32_EXISTING_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_SERIAL_NO').exists?,'Could not find P32_EXISTING_METER_SERIAL_NO field')
    assert(@@ie.select_list(:id,'P32_EXISTING_PRTY_ID').exists?,'Could not find P32_EXISTING_PRTY_ID field')
    assert(@@ie.select_list(:id,'P32_EXISTING_METR_CODE').exists?,'Could not find P32_EXISTING_METR_CODE field')
    assert(@@ie.select_list(:id,'P32_MARKET_SECTOR_CODE').exists?,'Could not find P32_MARKET_SECTOR_CODE select list')
    assert(@@ie.text_field(:id,'P32_OTHER_INFORMATION').exists?,'Could not find P32_OTHER_INFORMATION field')
    assert(@@ie.select_list(:id,'P32_EXISTING_LOGGER').exists?,'Could not find P32_EXISTING_LOGGER select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_CONVERTOR').exists?,'Could not find P32_EXISTING_CONVERTOR select list')
  end
  def test_15_std_remove_selected_check_fields_appear_available
    @@ie.select_list(:id,'P32_ENTY_CODE').set @@enquirytypes[10]
    @@ie.wait
    assert_equal(@@enquirytypes,@@ie.select_list(:id, 'P32_ENTY_CODE').getAllContents ,'The expected list for job type was not found')    
    assert(@@ie.select_list(:id,'P32_EXISTING_METER_OWNER').exists?,'Could not find P32_EXISTING_METER_OWNER field')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_ASSET_PROVIDER').exists?,'Could not find P32_EXISTING_METER_ASSET_PROVIDER field')
    assert(@@ie.select_list(:id,'P32_INDICATIVE_TIME').exists?,'Could not find P32_INDICATIVE_TIME select list')
    assert(@@ie.select_list(:id,'P32_REQUIRED_SVCP_CODE').exists?,'Could not find P32_REQUIRED_SVCP_CODE select list')
    assert_equal(false,@@ie.text_field(:id,'P32_ANNUAL_QUANTITY').exists?,'Found P32_ANNUAL_QUANTITY field')
    assert(@@ie.text_field(:id,'P32_REQUIRED_METERING_PRESSURE').exists?,'Could not find P32_REQUIRED_METERING_PRESSURE field')
    assert_equal(false,@@ie.select_list(:id,'P32_DS_BOOSTER_OR_COMPRESS').exists?,'Found P32_DS_BOOSTER_OR_COMPRESS select list')
    assert(@@ie.text_field(:id,'P32_INDICATIVE_DATE').exists?,'Could not find P32_INDICATIVE_DATE field')
    assert(@@ie.text_field(:id,'P32_OTHER_PROJECT_REFERENCE').exists?,'Could not find P32_OTHER_PROJECT_REFERENCE field')
    assert_equal(false,@@ie.select_list(:id,'P32_HOUSING_REQUIRED').exists?,'Found P32_HOUSING_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_BASE_REQUIRED').exists?,'Found P32_BASE_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_CONVERTOR_REQUIRED').exists?,'Found P32_CONVERTOR_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_AMR_REQUIRED').exists?,'Found P32_AMR_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_EMS_REQUIRED').exists?,'Found P32_EMS_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_BYPASS_REQUIRED').exists?,'Found P32_BYPASS_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_LOAD_CONTROL_TYPE').exists?,'Found P32_LOAD_CONTROL_TYPE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_TWIN_STREAM_REQUIRED').exists?,'Found P32_TWIN_STREAM_REQUIRED select list')
    assert(@@ie.text_field(:id,'P32_JOB_DESCRIPTION').exists?,'Could not find P32_JOB_DESCRIPTION field')
    assert(@@ie.text_field(:id,'P32_QMAX').exists?,'Could not find P32_QMAX field')
    assert(@@ie.text_field(:id,'P32_QMIN').exists?,'Could not find P32_QMIN field')
    assert_equal(false,@@ie.select_list(:id,'P32_REQUIRED_MESC_CODE').exists?,'Found P32_REQUIRED_MESC_CODE select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_METY_CODE').exists?,'Could not find P32_METY_CODE select list')
   # assert(@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').exists?,'Could not find P32_EXISTING_MESC_CODE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_SVCP_CODE').exists?,'Found P32_EXISTING_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_SERIAL_NO').exists?,'Could not find P32_EXISTING_METER_SERIAL_NO field')
    assert(@@ie.select_list(:id,'P32_EXISTING_PRTY_ID').exists?,'Could not find P32_EXISTING_PRTY_ID field')
    assert(@@ie.select_list(:id,'P32_EXISTING_METR_CODE').exists?,'Could not find P32_EXISTING_METR_CODE field')
    assert(@@ie.select_list(:id,'P32_MARKET_SECTOR_CODE').exists?,'Could not find P32_MARKET_SECTOR_CODE select list')
    assert(@@ie.text_field(:id,'P32_OTHER_INFORMATION').exists?,'Could not find P32_OTHER_INFORMATION field')
    assert(@@ie.select_list(:id,'P32_EXISTING_LOGGER').exists?,'Could not find P32_EXISTING_LOGGER select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_CONVERTOR').exists?,'Could not find P32_EXISTING_CONVERTOR select list')
  end
  def test_16_adversarial_selected_check_fields_appear_available
    @@ie.select_list(:id,'P32_ENTY_CODE').set @@enquirytypes[1]
    @@ie.wait
    assert_equal(@@enquirytypes,@@ie.select_list(:id, 'P32_ENTY_CODE').getAllContents ,'The expected list for job type was not found')    
    assert(@@ie.select_list(:id,'P32_EXISTING_METER_OWNER').exists?,'Could not find P32_EXISTING_METER_OWNER field')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_ASSET_PROVIDER').exists?,'Could not find P32_EXISTING_METER_ASSET_PROVIDER field')
    assert(@@ie.select_list(:id,'P32_INDICATIVE_TIME').exists?,'Could not find P32_INDICATIVE_TIME select list')
    assert(@@ie.select_list(:id,'P32_REQUIRED_SVCP_CODE').exists?,'Could not find P32_REQUIRED_SVCP_CODE select list')
    assert_equal(false,@@ie.text_field(:id,'P32_ANNUAL_QUANTITY').exists?,'Found P32_ANNUAL_QUANTITY field')
    assert(@@ie.text_field(:id,'P32_REQUIRED_METERING_PRESSURE').exists?,'Could not find P32_REQUIRED_METERING_PRESSURE field')
    assert_equal(false,@@ie.select_list(:id,'P32_DS_BOOSTER_OR_COMPRESS').exists?,'Found P32_DS_BOOSTER_OR_COMPRESS select list')
    assert(@@ie.text_field(:id,'P32_INDICATIVE_DATE').exists?,'Could not find P32_INDICATIVE_DATE field')
    assert(@@ie.text_field(:id,'P32_OTHER_PROJECT_REFERENCE').exists?,'Could not find P32_OTHER_PROJECT_REFERENCE field')
    assert_equal(false,@@ie.select_list(:id,'P32_HOUSING_REQUIRED').exists?,'Found P32_HOUSING_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_BASE_REQUIRED').exists?,'Found P32_BASE_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_CONVERTOR_REQUIRED').exists?,'Found P32_CONVERTOR_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_AMR_REQUIRED').exists?,'Found P32_AMR_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_EMS_REQUIRED').exists?,'Found P32_EMS_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_BYPASS_REQUIRED').exists?,'Found P32_BYPASS_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_LOAD_CONTROL_TYPE').exists?,'Found P32_LOAD_CONTROL_TYPE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_TWIN_STREAM_REQUIRED').exists?,'Found P32_TWIN_STREAM_REQUIRED select list')
    assert(@@ie.text_field(:id,'P32_JOB_DESCRIPTION').exists?,'Could not find P32_JOB_DESCRIPTION field')
    assert(@@ie.text_field(:id,'P32_QMAX').exists?,'Could not find P32_QMAX field')
    assert(@@ie.text_field(:id,'P32_QMIN').exists?,'Could not find P32_QMIN field')
    assert_equal(false,@@ie.select_list(:id,'P32_REQUIRED_MESC_CODE').exists?,'Found P32_REQUIRED_MESC_CODE select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_METY_CODE').exists?,'Could not find P32_METY_CODE select list')
  #  assert(@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').exists?,'Could not find P32_EXISTING_MESC_CODE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_SVCP_CODE').exists?,'Found P32_EXISTING_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_SERIAL_NO').exists?,'Could not find P32_EXISTING_METER_SERIAL_NO field')
    assert(@@ie.select_list(:id,'P32_EXISTING_PRTY_ID').exists?,'Could not find P32_EXISTING_PRTY_ID field')
    assert(@@ie.select_list(:id,'P32_EXISTING_METR_CODE').exists?,'Could not find P32_EXISTING_METR_CODE field')
    assert(@@ie.select_list(:id,'P32_MARKET_SECTOR_CODE').exists?,'Could not find P32_MARKET_SECTOR_CODE select list')
    assert(@@ie.text_field(:id,'P32_OTHER_INFORMATION').exists?,'Could not find P32_OTHER_INFORMATION field')
    assert(@@ie.select_list(:id,'P32_EXISTING_LOGGER').exists?,'Could not find P32_EXISTING_LOGGER select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_CONVERTOR').exists?,'Could not find P32_EXISTING_CONVERTOR select list')
  end
  def test_17_alteration_selected_check_fields_appear_available
    @@ie.select_list(:id,'P32_ENTY_CODE').set @@enquirytypes[2]
    @@ie.wait
    assert_equal(@@enquirytypes,@@ie.select_list(:id, 'P32_ENTY_CODE').getAllContents ,'The expected list for job type was not found')    
    assert(@@ie.select_list(:id,'P32_EXISTING_METER_OWNER').exists?,'Could not find P32_EXISTING_METER_OWNER field')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_ASSET_PROVIDER').exists?,'Could not find P32_EXISTING_METER_ASSET_PROVIDER field')
    assert(@@ie.select_list(:id,'P32_INDICATIVE_TIME').exists?,'Could not find P32_INDICATIVE_TIME select list')
    assert(@@ie.select_list(:id,'P32_REQUIRED_SVCP_CODE').exists?,'Could not find P32_REQUIRED_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_ANNUAL_QUANTITY').exists?,'Could not find P32_ANNUAL_QUANTITY field')
    assert(@@ie.text_field(:id,'P32_REQUIRED_METERING_PRESSURE').exists?,'Could not find P32_REQUIRED_METERING_PRESSURE field')
    assert(@@ie.select_list(:id,'P32_DS_BOOSTER_OR_COMPRESS').exists?,'Could not find P32_DS_BOOSTER_OR_COMPRESS select list')
    assert(@@ie.text_field(:id,'P32_INDICATIVE_DATE').exists?,'Could not find P32_INDICATIVE_DATE field')
    assert(@@ie.text_field(:id,'P32_OTHER_PROJECT_REFERENCE').exists?,'Could not find P32_OTHER_PROJECT_REFERENCE field')
    assert(@@ie.select_list(:id,'P32_HOUSING_REQUIRED').exists?,'Could not find P32_HOUSING_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_BASE_REQUIRED').exists?,'Could not find P32_BASE_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_CONVERTOR_REQUIRED').exists?,'Could not find P32_CONVERTOR_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_AMR_REQUIRED').exists?,'Found P32_AMR_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_EMS_REQUIRED').exists?,'Could not find P32_EMS_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_BYPASS_REQUIRED').exists?,'Could not find P32_BYPASS_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_LOAD_CONTROL_TYPE').exists?,'Could not find P32_LOAD_CONTROL_TYPE select list')
    assert(@@ie.select_list(:id,'P32_TWIN_STREAM_REQUIRED').exists?,'Could not find P32_TWIN_STREAM_REQUIRED select list')
    assert(@@ie.text_field(:id,'P32_JOB_DESCRIPTION').exists?,'Could not find P32_JOB_DESCRIPTION field')
    assert(@@ie.text_field(:id,'P32_QMAX').exists?,'Could not find P32_QMAX field')
    assert(@@ie.text_field(:id,'P32_QMIN').exists?,'Could not find P32_QMIN field')
    assert_equal(false,@@ie.select_list(:id,'P32_REQUIRED_MESC_CODE').exists?,'Found P32_REQUIRED_MESC_CODE select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_METY_CODE').exists?,'Could not find P32_EXISTING_METY_CODE select list')
  #  assert(@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').exists?,'Could not find P32_EXISTING_MESC_CODE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_SVCP_CODE').exists?,'Found P32_EXISTING_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_SERIAL_NO').exists?,'Could not find P32_EXISTING_METER_SERIAL_NO field')
    assert(@@ie.select_list(:id,'P32_EXISTING_PRTY_ID').exists?,'Could not find P32_EXISTING_PRTY_ID field')
    assert(@@ie.select_list(:id,'P32_EXISTING_METR_CODE').exists?,'Could not find P32_EXISTING_METR_CODE field')
    assert(@@ie.select_list(:id,'P32_MARKET_SECTOR_CODE').exists?,'Could not find P32_MARKET_SECTOR_CODE select list')
    assert(@@ie.text_field(:id,'P32_OTHER_INFORMATION').exists?,'Could not find P32_OTHER_INFORMATION field')
    assert(@@ie.select_list(:id,'P32_EXISTING_LOGGER').exists?,'Could not find P32_EXISTING_LOGGER select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_CONVERTOR').exists?,'Could not find P32_EXISTING_CONVERTOR select list')
  end
  def test_18_capacity_change_selected_check_fields_appear_available
    @@ie.select_list(:id,'P32_ENTY_CODE').set @@enquirytypes[3]
    @@ie.wait
    assert_equal(@@enquirytypes,@@ie.select_list(:id, 'P32_ENTY_CODE').getAllContents ,'The expected list for job type was not found')    
    assert(@@ie.select_list(:id,'P32_EXISTING_METER_OWNER').exists?,'Could not find P32_EXISTING_METER_OWNER field')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_ASSET_PROVIDER').exists?,'Could not find P32_EXISTING_METER_ASSET_PROVIDER field')
    assert(@@ie.select_list(:id,'P32_INDICATIVE_TIME').exists?,'Could not find P32_INDICATIVE_TIME select list')
    assert(@@ie.select_list(:id,'P32_REQUIRED_SVCP_CODE').exists?,'Could not find P32_REQUIRED_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_ANNUAL_QUANTITY').exists?,'Could not find P32_ANNUAL_QUANTITY field')
    assert(@@ie.text_field(:id,'P32_REQUIRED_METERING_PRESSURE').exists?,'Could not find P32_REQUIRED_METERING_PRESSURE field')
    assert(@@ie.select_list(:id,'P32_DS_BOOSTER_OR_COMPRESS').exists?,'Could not find P32_DS_BOOSTER_OR_COMPRESS select list')
    assert(@@ie.text_field(:id,'P32_INDICATIVE_DATE').exists?,'Could not find P32_INDICATIVE_DATE field')
    assert(@@ie.text_field(:id,'P32_OTHER_PROJECT_REFERENCE').exists?,'Could not find P32_OTHER_PROJECT_REFERENCE field')
    assert(@@ie.select_list(:id,'P32_HOUSING_REQUIRED').exists?,'Could not find P32_HOUSING_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_BASE_REQUIRED').exists?,'Could not find P32_BASE_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_CONVERTOR_REQUIRED').exists?,'Could not find P32_CONVERTOR_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_AMR_REQUIRED').exists?,'Found P32_AMR_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_EMS_REQUIRED').exists?,'Could not find P32_EMS_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_BYPASS_REQUIRED').exists?,'Could not find P32_BYPASS_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_LOAD_CONTROL_TYPE').exists?,'Could not find P32_LOAD_CONTROL_TYPE select list')
    assert(@@ie.select_list(:id,'P32_TWIN_STREAM_REQUIRED').exists?,'Could not find P32_TWIN_STREAM_REQUIRED select list')
    assert(@@ie.text_field(:id,'P32_JOB_DESCRIPTION').exists?,'Could not find P32_JOB_DESCRIPTION field')
    assert(@@ie.text_field(:id,'P32_QMAX').exists?,'Could not find P32_QMAX field')
    assert(@@ie.text_field(:id,'P32_QMIN').exists?,'Could not find P32_QMIN field')
    assert(@@ie.select_list(:id,'P32_REQUIRED_MESC_CODE').exists?,'Could not find P32_REQUIRED_MESC_CODE select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_METY_CODE').exists?,'Could not find P32_EXISTING_METY_CODE select list')
   # assert(@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').exists?,'Could not find P32_EXISTING_MESC_CODE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_SVCP_CODE').exists?,'Found P32_EXISTING_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_SERIAL_NO').exists?,'Could not find P32_EXISTING_METER_SERIAL_NO field')
    assert(@@ie.select_list(:id,'P32_EXISTING_PRTY_ID').exists?,'Could not find P32_EXISTING_PRTY_ID field')
    assert(@@ie.select_list(:id,'P32_EXISTING_METR_CODE').exists?,'Could not find P32_EXISTING_METR_CODE field')
    assert(@@ie.select_list(:id,'P32_MARKET_SECTOR_CODE').exists?,'Could not find P32_MARKET_SECTOR_CODE select list')
    assert(@@ie.text_field(:id,'P32_OTHER_INFORMATION').exists?,'Could not find P32_OTHER_INFORMATION field')
    assert(@@ie.select_list(:id,'P32_EXISTING_LOGGER').exists?,'Could not find P32_EXISTING_LOGGER select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_CONVERTOR').exists?,'Could not find P32_EXISTING_CONVERTOR select list')
  end  
  def test_19_addon_selected_check_fields_appear_available
    @@ie.select_list(:id,'P32_ENTY_CODE').set @@enquirytypes[9]
    @@ie.wait
    assert_equal(@@enquirytypes,@@ie.select_list(:id, 'P32_ENTY_CODE').getAllContents ,'The expected list for job type was not found')    
    assert(@@ie.select_list(:id,'P32_EXISTING_METER_OWNER').exists?,'Could not find P32_EXISTING_METER_OWNER field')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_ASSET_PROVIDER').exists?,'Could not find P32_EXISTING_METER_ASSET_PROVIDER field')
    assert(@@ie.select_list(:id,'P32_INDICATIVE_TIME').exists?,'Could not find P32_INDICATIVE_TIME select list')
    assert(@@ie.select_list(:id,'P32_REQUIRED_SVCP_CODE').exists?,'Could not find P32_REQUIRED_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_ANNUAL_QUANTITY').exists?,'Could not find P32_ANNUAL_QUANTITY field')
    assert(@@ie.text_field(:id,'P32_REQUIRED_METERING_PRESSURE').exists?,'Could not find P32_REQUIRED_METERING_PRESSURE field')
    assert(@@ie.select_list(:id,'P32_DS_BOOSTER_OR_COMPRESS').exists?,'Could not find P32_DS_BOOSTER_OR_COMPRESS select list')
    assert(@@ie.text_field(:id,'P32_INDICATIVE_DATE').exists?,'Could not find P32_INDICATIVE_DATE field')
    assert(@@ie.text_field(:id,'P32_OTHER_PROJECT_REFERENCE').exists?,'Could not find P32_OTHER_PROJECT_REFERENCE field')
    assert_equal(false,@@ie.select_list(:id,'P32_HOUSING_REQUIRED').exists?,'Found P32_HOUSING_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_BASE_REQUIRED').exists?,'Found P32_BASE_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_CONVERTOR_REQUIRED').exists?,'Could not find P32_CONVERTOR_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_AMR_REQUIRED').exists?,'Found P32_AMR_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_EMS_REQUIRED').exists?,'Could not find P32_EMS_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_BYPASS_REQUIRED').exists?,'Could not find P32_BYPASS_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_LOAD_CONTROL_TYPE').exists?,'Could not find P32_LOAD_CONTROL_TYPE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_TWIN_STREAM_REQUIRED').exists?,'Found P32_TWIN_STREAM_REQUIRED select list')
    assert(@@ie.text_field(:id,'P32_JOB_DESCRIPTION').exists?,'Could not find P32_JOB_DESCRIPTION field')
    assert(@@ie.text_field(:id,'P32_QMAX').exists?,'Could not find P32_QMAX field')
    assert(@@ie.text_field(:id,'P32_QMIN').exists?,'Could not find P32_QMIN field')
    assert_equal(false,@@ie.select_list(:id,'P32_REQUIRED_MESC_CODE').exists?,'Found P32_REQUIRED_MESC_CODE select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_METY_CODE').exists?,'Could not find P32_EXISTING_METY_CODE select list')
   # assert(@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').exists?,'Could not find P32_EXISTING_MESC_CODE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_SVCP_CODE').exists?,'Found P32_EXISTING_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_SERIAL_NO').exists?,'Could not find P32_EXISTING_METER_SERIAL_NO field')
    assert(@@ie.select_list(:id,'P32_EXISTING_PRTY_ID').exists?,'Could not find P32_EXISTING_PRTY_ID field')
    assert(@@ie.select_list(:id,'P32_EXISTING_METR_CODE').exists?,'Could not find P32_EXISTING_METR_CODE field')
    assert(@@ie.select_list(:id,'P32_MARKET_SECTOR_CODE').exists?,'Could not find P32_MARKET_SECTOR_CODE select list')
    assert(@@ie.text_field(:id,'P32_OTHER_INFORMATION').exists?,'Could not find P32_OTHER_INFORMATION field')
    assert(@@ie.select_list(:id,'P32_EXISTING_LOGGER').exists?,'Could not find P32_EXISTING_LOGGER select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_CONVERTOR').exists?,'Could not find P32_EXISTING_CONVERTOR select list')
  end 
  def test_20_other_selected_check_fields_appear_available
    @@ie.select_list(:id,'P32_ENTY_CODE').set @@enquirytypes[8]
    @@ie.wait
    assert_equal(@@enquirytypes,@@ie.select_list(:id, 'P32_ENTY_CODE').getAllContents ,'The expected list for job type was not found')    
    assert(@@ie.select_list(:id,'P32_EXISTING_METER_OWNER').exists?,'Could not find P32_EXISTING_METER_OWNER field')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_ASSET_PROVIDER').exists?,'Could not find P32_EXISTING_METER_ASSET_PROVIDER field')
    assert(@@ie.select_list(:id,'P32_INDICATIVE_TIME').exists?,'Could not find P32_INDICATIVE_TIME select list')
    assert(@@ie.select_list(:id,'P32_REQUIRED_SVCP_CODE').exists?,'Could not find P32_REQUIRED_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_ANNUAL_QUANTITY').exists?,'Could not find P32_ANNUAL_QUANTITY field')
    assert(@@ie.text_field(:id,'P32_REQUIRED_METERING_PRESSURE').exists?,'Could not find P32_REQUIRED_METERING_PRESSURE field')
    assert(@@ie.select_list(:id,'P32_DS_BOOSTER_OR_COMPRESS').exists?,'Could not find P32_DS_BOOSTER_OR_COMPRESS select list')
    assert(@@ie.text_field(:id,'P32_INDICATIVE_DATE').exists?,'Could not find P32_INDICATIVE_DATE field')
    assert(@@ie.text_field(:id,'P32_OTHER_PROJECT_REFERENCE').exists?,'Could not find P32_OTHER_PROJECT_REFERENCE field')
    assert(@@ie.select_list(:id,'P32_HOUSING_REQUIRED').exists?,'Could not find P32_HOUSING_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_BASE_REQUIRED').exists?,'Could not find P32_BASE_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_CONVERTOR_REQUIRED').exists?,'Could not find P32_CONVERTOR_REQUIRED select list')
    assert_equal(false,@@ie.select_list(:id,'P32_AMR_REQUIRED').exists?,'Found P32_AMR_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_EMS_REQUIRED').exists?,'Could not find P32_EMS_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_BYPASS_REQUIRED').exists?,'Could not find P32_BYPASS_REQUIRED select list')
    assert(@@ie.select_list(:id,'P32_LOAD_CONTROL_TYPE').exists?,'Could not find P32_LOAD_CONTROL_TYPE select list')
    assert(@@ie.select_list(:id,'P32_TWIN_STREAM_REQUIRED').exists?,'Could not find P32_TWIN_STREAM_REQUIRED select list')
    assert(@@ie.text_field(:id,'P32_JOB_DESCRIPTION').exists?,'Could not find P32_JOB_DESCRIPTION field')
    assert(@@ie.text_field(:id,'P32_QMAX').exists?,'Could not find P32_QMAX field')
    assert(@@ie.text_field(:id,'P32_QMIN').exists?,'Could not find P32_QMIN field')
    assert(@@ie.select_list(:id,'P32_REQUIRED_MESC_CODE').exists?,'Could not find P32_REQUIRED_MESC_CODE select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_METY_CODE').exists?,'Could not find P32_EXISTING_METY_CODE select list')
  #  assert(@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').exists?,'Could not find P32_EXISTING_MESC_CODE select list')
    assert_equal(false,@@ie.select_list(:id,'P32_EXISTING_SVCP_CODE').exists?,'Found P32_EXISTING_SVCP_CODE select list')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_SERIAL_NO').exists?,'Could not find P32_EXISTING_METER_SERIAL_NO field')
    assert(@@ie.select_list(:id,'P32_EXISTING_PRTY_ID').exists?,'Could not find P32_EXISTING_PRTY_ID field')
    assert(@@ie.select_list(:id,'P32_EXISTING_METR_CODE').exists?,'Could not find P32_EXISTING_METR_CODE field')
    assert(@@ie.select_list(:id,'P32_MARKET_SECTOR_CODE').exists?,'Could not find P32_MARKET_SECTOR_CODE select list')
    assert(@@ie.text_field(:id,'P32_OTHER_INFORMATION').exists?,'Could not find P32_OTHER_INFORMATION field')
    assert(@@ie.select_list(:id,'P32_EXISTING_LOGGER').exists?,'Could not find P32_EXISTING_LOGGER select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_CONVERTOR').exists?,'Could not find P32_EXISTING_CONVERTOR select list')
  end                 
  def test_21_logout_and_then_in_as_agent_check_enquiry_displays_correctly
    menu('Logout')
    assert(@@ie.button(:value, 'Login').exists?,'The Login button was not available')        
    @@ie.button(:value, 'Login').click        
    @@ie.wait
    #check we've got the login page
    assert(@@ie.text_field(:id,'P101_USERNAME').exists?,'Could not find P101_USERNAME field '+geterrormess(@@ie))     
    assert(@@ie.text_field(:id,'P101_PASSWORD').exists?,'Could not find P101_PASSWORD field '+geterrormess(@@ie))
    assert(@@ie.button(:id, 'P101_LOGIN').exists?,'Could not find a Login button '+geterrormess(@@ie))
    login(AGENT, AGENT_PWD)
    menu('Enquiries')
    @@ie.button(:id, 'NEW').click 
    assert(@@ie.contains_text('Enquiry'),'The Enquiry screen did not appear '+geterrormess(@@ie))
    #check the regions appear
    assert(@@ie.contains_text('Site Detail'),'Site Detail region not found')
    assert(@@ie.contains_text('Site Address'),'The Site Address region not found')
    assert(@@ie.contains_text('Contact Details'),'The Contact Details region not found')
    assert(@@ie.contains_text('Job Info'),'The Job Info region not found') 
    #check we've got the save and cancel buttons but not apply changes
    assert(@@ie.button(:class, 'save').exists?,'Could not find a Save button')
    assert(@@ie.button(:value, 'Cancel').exists?,'Could not find a Cancel button')
    assert_not_equal(@@ie.button(:class, 'update').exists?,true,'Found Save(update) button when it should have been hidden')
    #make sure that the ID field is not accessable (a form object)
    #assert_not_equal(@@ie.text_field(:name, 'P32_ID').exists?,true,'Found Apply Changes button when it should have been hidden')
    #make sure that the ID field is not accessable (a form object)
    #assert_not_equal(@@ie.text_field(:name, 'P32_ID').exists?,true,'Found Apply Changes button when it should have been hidden')
    assert(@@ie.text_field(:id,'P32_ID').exists?,'Could not find P32_ID field')
    assert(@@ie.select_list(:id,'P32_MKTP_REF2').exists?,'Could not find P32_MKTP_REF2 field')
    assert_equal(false,@@ie.select_list(:id,'P32_MKTP_REF').exists?,'Found P32_MKTP_REF field')
    assert(@@ie.select_list(:id,'P32_AGENT_COMT_CODE').exists?,'Could not find P32_AGENT_COMT_CODE select list')
    assert(@@ie.select_list(:id,'P32_ALTY_CODE').exists?,'Could not find P32_ALTY_CODE select list')
    assert(@@ie.select_list(:id,'P32_CACA_CODE').exists?,'Could not find P32_CACA_CODE select list')
    assert(@@ie.select_list(:id,'P32_ASSET_LOCATION_NOTES').exists?,'Could not find P32_ASSET_LOCATION_NOTES select list')
    assert(@@ie.text_field(:id,'P32_ACCESS_PASSWORD').exists?,'Could not find P32_ACCESS_PASSWORD field')
    assert(@@ie.text_field(:id,'P32_ACCESS_ADDITIONAL').exists?,'Could not find P32_ACCESS_ADDITIONAL field')
    assert(@@ie.text_field(:id,'P32_TRANSACTION_REFERENCE').exists?,'Could not find P32_TRANSACTION_REFERENCE field')
    assert(@@ie.text_field(:id,'P32_FIRST_CONTACT_TITLE').exists?,'Could not find P32_FIRST_CONTACT_FAX field')
    assert(@@ie.text_field(:id,'P32_FIRST_CONTACT_INITIALS').exists?,'Could not find P32_FIRST_CONTACT_FAX field')
    assert(@@ie.text_field(:id,'P32_FIRST_CONTACT_NAME').exists?,'Could not find P32_FIRST_CONTACT_NAME field')
    assert(@@ie.text_field(:id,'P32_FIRST_CONTACT_TELEPHONE_1').exists?,'Could not find P32_FIRST_CONTACT_TELEPHONE_1 field')
    assert(@@ie.text_field(:id,'P32_FIRST_CONTACT_TELEPHONE_2').exists?,'Could not find P32_FIRST_CONTACT_TELEPHONE_2 field')    
    assert(@@ie.text_field(:id,'P32_FIRST_CONTACT_FAX').exists?,'Could not find P32_FIRST_CONTACT_FAX field')
    assert(@@ie.text_field(:id,'P32_FIRST_CONTACT_EMAIL').exists?,'Could not find P32_FIRST_CONTACT_FAX field')
    assert(@@ie.text_field(:id,'P32_INSTALL_SUB_BUILDING').exists?,'Could not find P32_INSTALL_SUB_BUILDING field')
    assert(@@ie.text_field(:id,'P32_INSTALL_BUILDING').exists?,'Could not find P32_INSTALL_BUILDING field')
    assert(@@ie.text_field(:id,'P32_INSTALL_STREET').exists?,'Could not find P32_INSTALL_STREET field')
    assert(@@ie.text_field(:id,'P32_INSTALL_CITY').exists?,'Could not find P32_INSTALL_CITY field')
    assert(@@ie.text_field(:id,'P32_INSTALL_POSTCODE').exists?,'Could not find P32_INSTALL_POSTCODE field')
    assert(@@ie.select_list(:id,'P32_INSTALL_ADDRESS').exists?,'Could not find P32_INSTALL_ADDRESS select list')
    assert(@@ie.select_list(:id,'P32_SECOND_CONTACT').exists?,'Could not find P32_SECOND_CONTACT select list')
    assert(@@ie.select_list(:id,'P32_ENTY_CODE').exists?,'Could not find P32_ENTY_CODE select list')
    assert(@@ie.text_field(:id,'P32_EXISTING_METER_ASSET_PROVIDER').exists?,'Could not find P32_EXISTING_METER_ASSET_PROVIDER field')
    assert(@@ie.select_list(:id,'P32_INDICATIVE_TIME').exists?,'Could not find P32_INDICATIVE_TIME select list')
    assert(@@ie.text_field(:id,'P32_INDICATIVE_DATE').exists?,'Could not find P32_INDICATIVE_DATE field')
    assert(@@ie.text_field(:id,'P32_OTHER_PROJECT_REFERENCE').exists?,'Could not find P32_OTHER_PROJECT_REFERENCE field')
    assert_equal(false,@@ie.select_list(:id,'P32_AMR_REQUIRED').exists?,'Found P32_AMR_REQUIRED select list')
    assert(@@ie.text_field(:id,'P32_JOB_DESCRIPTION').exists?,'Could not find P32_JOB_DESCRIPTION field')
    assert(@@ie.text_field(:id,'P32_QMAX').exists?,'Could not find P32_QMAX field')
    assert(@@ie.text_field(:id,'P32_QMIN').exists?,'Could not find P32_QMIN field')
    assert(@@ie.select_list(:id,'P32_MARKET_SECTOR_CODE').exists?,'Could not find P32_MARKET_SECTOR_CODE select list')
    assert(@@ie.text_field(:id,'P32_OTHER_INFORMATION').exists?,'Could not find P32_OTHER_INFORMATION field')      
   end
  #  
  #   Check that the customer service user does not have access to create an enquiry from the 
  #   menu.
  def test_22_logout_and_then_in_as_Customer_Services_check_create_agent_displays_correctly
    menu('Logout')
    assert(@@ie.button(:value, 'Login').exists?,'The Login button was not available')        
    @@ie.button(:value, 'Login').click        
    @@ie.wait
    #check we've got the login page
    assert(@@ie.text_field(:id,'P101_USERNAME').exists?,'Could not find P101_USERNAME field '+geterrormess(@@ie))     
    assert(@@ie.text_field(:id,'P101_PASSWORD').exists?,'Could not find P101_PASSWORD field '+geterrormess(@@ie))
    assert(@@ie.button(:id, 'P101_LOGIN').exists?,'Could not find a Login button')
    login(CS, CS_PWD)
    menu('Enquiries')
    assert_nil(@@ie.contains_text('Create Enquiry'),'Create Enquiry menu option found when should have been hidden')
  end
  #
  #Supplier admin should be unable to create an enquiry via the menu.
  #  
  def test_23_logout_and_then_in_as_supplier_admin
    menu('Logout')
    assert(@@ie.button(:value, 'Login').exists?,'The Login button was not available')        
    @@ie.button(:value, 'Login').click        
    @@ie.wait
    #check we've got the login page to enter data into
    assert(@@ie.text_field(:id,'P101_USERNAME').exists?,'Could not find P101_USERNAME field '+geterrormess(@@ie))     
    assert(@@ie.text_field(:id,'P101_PASSWORD').exists?,'Could not find P101_PASSWORD field '+geterrormess(@@ie))
    assert(@@ie.button(:id, 'P101_LOGIN').exists?,'Could not find a Login button')
    login(SA, SA_PWD)
    assert_nil(@@ie.contains_text('Create Enquiry'),'Create Enquiry menu option found when should have been hidden')
  end   
  #
  #  Log in as agent and create and save an enquiry
  #  
  def test_24_login_as_agent_and_save_enquiry_then_change_apply_changes_request_for_quote
    menu('Logout')
    assert(@@ie.button(:value, 'Login').exists?,'The Login button was not available')        
    @@ie.button(:value, 'Login').click        
    @@ie.wait
    #check we've got the login page
    assert(@@ie.text_field(:id,'P101_USERNAME').exists?,'Could not find P101_USERNAME field')     
    assert(@@ie.text_field(:id,'P101_PASSWORD').exists?,'Could not find P101_PASSWORD field')
    assert(@@ie.button(:id, 'P101_LOGIN').exists?,'Could not find a Login button')
    login(AGENT, AGENT_PWD)
    menu('Enquiries')
    @@ie.button(:id, 'NEW').click 
    assert(@@ie.contains_text('Enquiry'),'The Enquiry screen did not appear')
    #check the regions appear
    assert(@@ie.contains_text('Site Detail'),'Site Detail region not found')
    assert(@@ie.contains_text('Site Address'),'The Site Address region not found')
    assert(@@ie.contains_text('Contact Details'),'The Contact Details region not found')
    assert(@@ie.contains_text('Job Info'),'The Job Info region not found') 
    #check we've got the save and cancel buttons but not apply changes
    assert(@@ie.button(:class, 'save').exists?,'Could not find a Save button')
    assert(@@ie.button(:value, 'Cancel').exists?,'Could not find a Cancel button')
    assert_not_equal(@@ie.button(:class, 'update').exists?,true,'Found Save(update) button when it should have been hidden')
    #make sure that the ID field is not accessable (a form object)
    #assert_not_equal(@@ie.text_field(:name, 'P32_ID').exists?,true,'Found Apply Changes button when it should have been hidden')
    @@ie.select_list(:id,'P32_AGENT_COMT_CODE').set 'Fax'
    @@ie.wait
    @@ie.text_field(:id,'P32_AGENT_CONTACT_VALUE').set '1234567890'
    @@ie.select_list(:id,'P32_ALTY_CODE').set 'Office' 
    @@ie.select_list(:id,'P32_CACA_CODE').set 'Blind'
    @@ie.select_list(:id,'P32_ASSET_LOCATION_NOTES').set 'Post'
    @@ie.text_field(:id,'P32_ACCESS_PASSWORD').set 'test 23'
    @@ie.text_field(:id,'P32_ACCESS_ADDITIONAL').set 'no more info'
    @@ie.text_field(:id,'P32_TRANSACTION_REFERENCE').set 'this is test 23'
    @@ie.text_field(:id,'P32_INSTALL_SUB_BUILDING').set ADDRESSA[0]
    @@ie.text_field(:id,'P32_INSTALL_BUILDING').set ADDRESSA[1]
    @@ie.text_field(:id,'P32_INSTALL_STREET').set ADDRESSA[2]
    @@ie.text_field(:id,'P32_INSTALL_CITY').set ADDRESSA[3]
    @@ie.text_field(:id,'P32_INSTALL_POSTCODE').set ADDRESSA[4]
    @@ie.text_field(:id,'P32_FIRST_CONTACT_TITLE').set 'Mr'
    @@ie.text_field(:id,'P32_FIRST_CONTACT_INITIALS').set 'Z'
    @@ie.text_field(:id,'P32_FIRST_CONTACT_NAME').set 'Ted tester23'
    @@ie.text_field(:id,'P32_FIRST_CONTACT_TELEPHONE_1').set '123456789'
    @@ie.text_field(:id,'P32_FIRST_CONTACT_TELEPHONE_2').set '123456789'
    @@ie.text_field(:id,'P32_FIRST_CONTACT_FAX').set '123456789'
    @@ie.text_field(:id,'P32_FIRST_CONTACT_EMAIL').set 'jamie.priest@advanticagroup.com'
    #moved enty_code here to negate slight bvug with MPRN field not displaying correctly
    @@ie.select_list(:id,'P32_ENTY_CODE').set @@enquirytypes[6]
    @@ie.wait
    @@ie.button(:class, 'save').click
    @@ie.wait 
    assert_nil(@@ie.contains_text('Error'),'Error found (__LINE__) '+geterrormess(@@ie))    
    assert_equal(false,@@ie.button(:class, 'save').exists?,'Found Save button when it should have been hidden')
    assert(@@ie.button(:class, 'update').exists?,'Could not find a Save(update) button')    
    assert(@@ie.button(:value, 'Cancel').exists?,'Could not find a Cancel button')  
    assert(@@ie.button(:value, 'Upload File').exists?,'Could not find an Upload File button')
    assert(@@ie.text_field(:id,'P32_ID').to_s,'No value in the ID field')
    #
    #We'll save the enquiry id so we can search for it later
    #
    @@savedenquiryid = @@ie.text_field(:id,'P32_ID').value    
    #Job details
    @@ie.text_field(:id,'P32_MPRN').set '12345678910'
    @@ie.select_list(:id,'P32_EXISTING_METER_OWNER').set 'Supplier'
    @@ie.text_field(:id,'P32_EXISTING_METER_ASSET_PROVIDER').set 'Mam stuff goes here'
    #@@ie.select_list(:id,'P32_INDICATIVE_TIME').set ''
    @@ie.select_list(:id,'P32_REQUIRED_SVCP_CODE').set 'LP'
    @@ie.wait
    @@ie.text_field(:id,'P32_ANNUAL_QUANTITY').set '1000'
    @@ie.text_field(:id,'P32_REQUIRED_METERING_PRESSURE').set '15'
    @@ie.select_list(:id,'P32_DS_BOOSTER_OR_COMPRESS').set 'No'
    @@ie.text_field(:id,'P32_INDICATIVE_DATE').set '17/07/2008'
    @@ie.text_field(:id,'P32_OTHER_PROJECT_REFERENCE').set 'Test 23'
    @@ie.select_list(:id,'P32_HOUSING_REQUIRED').set 'No'
    @@ie.select_list(:id,'P32_BASE_REQUIRED').set 'No'
    @@ie.select_list(:id,'P32_CONVERTOR_REQUIRED').set 'No'
    #@@ie.select_list(:id,'P32_AMR_REQUIRED').set 'No'
    @@ie.select_list(:id,'P32_EMS_REQUIRED').set 'No'
    @@ie.select_list(:id,'P32_BYPASS_REQUIRED').set 'Not required'
    @@ie.wait
    @@ie.select_list(:id,'P32_LOAD_CONTROL_TYPE').set 'Constant'
    @@ie.select_list(:id,'P32_TWIN_STREAM_REQUIRED').set 'No'
    @@ie.text_field(:id,'P32_JOB_DESCRIPTION').set ''
    @@ie.text_field(:id,'P32_QMAX').set '16'
    @@ie.text_field(:id,'P32_QMIN').set '0'
    @@ie.select_list(:id,'P32_REQUIRED_MESC_CODE').set 'U16'
    #@@ie.select_list(:id,'P32_EXISTING_METY_CODE').set ''
    #@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').set ''
    #@@ie.text_field(:id,'P32_EXISTING_METER_SERIAL_NO').set ''
    #@@ie.text_field(:id,'P32_EXISTING_METR_CODE').set ''
    #@@ie.select_list(:id,'P32_MARKET_SECTOR_CODE').set ''
    @@ie.text_field(:id,'P32_OTHER_INFORMATION').set ''
    #@@ie.text_field(:id,'P32_EXISTING_LOGGER').set ''
    #@@ie.text_field(:id,'P32_EXISTING_CONVERTOR').set ''
    @@ie.button(:class, 'update').click
    @@ie.wait
    
    @@ie.button(:value, 'Upload File').click
    @@ie.wait
    #check fileupload via upload control on enquiry form
    #we know InstallMIP.cmd is around
    @@ie.file_field(:id, 'P41_FILE_UPLOAD').set(WORKINGDIR+'\\InstallMIP.cmd')
    @@ie.button(:value, 'Upload').click    
    @@ie.wait

    assert_nil(@@ie.contains_text('Error'),'Error found (__LINE__) '+geterrormess(@@ie))
    @@ie.button(:value, 'Request Quotation').click    
    @@ie.wait
    assert_nil(@@ie.contains_text('Error'),'Error found (__LINE__) '+geterrormess(@@ie))
    assert_nil(@@ie.contains_text('error'),'Error found (__LINE__) '+geterrormess(@@ie))  
  end  

  def test_25_find_saved_quote
    menu('Enquiries')
    menu('Search for Enquiry')
    assert(@@ie.text_field(:id,'P30_ENQUIRY_ID').exists?,'Could not find P30_ENQUIRY_ID field')  
    assert(@@ie.text_field(:id,'P30_MPRN').exists?,'Could not find P30_MPRN field') 
    assert(@@ie.text_field(:id,'P30_TRANS_REF').exists?,'Could not find P30_TRANS_REF field') 
    assert(@@ie.text_field(:id,'P30_POSTCODE').exists?,'Could not find P30_POSTCODE field') 
    
    assert(@@ie.contains_text('Search Enquiries'),'Search Enquiries region not found')
    assert(@@ie.contains_text('Supplier Enquiries'),'All Enquiries region not found')
        
    assert(@@ie.button(:value, 'Search').exists?,'Could not find a Search button')
    assert(@@ie.button(:value, 'New').exists?,'Could not find a New button')
    
    @@ie.text_field(:id,'P30_ENQUIRY_ID').set @@savedenquiryid 
    @@ie.button(:value, 'Search').click
    @@ie.wait
    assert(@@ie.contains_text(@@savedenquiryid),' Enquiry '+@@savedenquiryid+' not found '+geterrormess(@@ie))
    assert(@@ie.link(:name,'View_enquiry_'+@@savedenquiryid).exists?,'Could not find link to Enquiry '+@@savedenquiryid)
    @@ie.link(:name,'View_enquiry_'+@@savedenquiryid).click
    @@ie.wait
    assert(@@ie.contains_text('Enquiry'),'The Enquiry screen did not appear '+geterrormess(@@ie))
    #check the regions appear
    assert(@@ie.contains_text('Site Detail'),'Site Detail region not found')
    assert(@@ie.contains_text('Site Address'),'The Site Address region not found')
    assert(@@ie.contains_text('Contact Details'),'The Contact Details region not found')
    assert(@@ie.contains_text('Job Info'),'The Job Info region not found') 
    assert_equal(@@savedenquiryid,@@ie.text_field(:id,'P32_ID').value,' Enquiry screen for'+@@savedenquiryid+' not found')
    assert(@@ie.hidden(:id,'P32_ACCESS_PASSWORD').exists?,'Password field is not read only, it should be!') 
  end  
  def test_26_upload_document_to_enquiry
    menu('Logout')
    assert(@@ie.button(:value, 'Login').exists?,'The Login button was not available')        
    @@ie.button(:value, 'Login').click        
    @@ie.wait
    login(MIPADMIN, MIPADMIN_PWD)
    menu('Enquiries')
    @@ie.button(:id, 'NEW').click 
    assert(@@ie.contains_text('Enquiry'),'The Enquiry screen did not appear '+geterrormess(@@ie))
    #check the regions appear
    assert(@@ie.contains_text('Site Detail'),'Site Detail region not found')
    assert(@@ie.contains_text('Site Address'),'The Site Address region not found')
    assert(@@ie.contains_text('Contact Details'),'The Contact Details region not found')
    assert(@@ie.contains_text('Job Info'),'The Job Info region not found') 
    #check we've got the save and cancel buttons but not apply changes
    assert(@@ie.button(:class, 'save').exists?,'Could not find a Save button')
    assert(@@ie.button(:value, 'Cancel').exists?,'Could not find a Cancel button')
    assert_not_equal(@@ie.button(:class, 'update').exists?,true,'Found Save(update) button when it should have been hidden')
    #make sure that the ID field is not accessable (a form object)
    #assert_not_equal(@@ie.text_field(:name, 'P32_ID').exists?,true,'Found Apply Changes button when it should have been hidden')
    @@ie.select_list(:id,'P32_MKTP_REF').set 'Northern Supplies'
    @@ie.wait
    @@ie.select_list(:id,'P32_AGENT_ID').set 'Fred Smith'
    @@ie.wait
    @@ie.select_list(:id,'P32_AGENT_COMT_CODE').set 'Fax'
    @@ie.wait
    @@ie.text_field(:id,'P32_AGENT_CONTACT_VALUE').set '1234567890'
    @@ie.select_list(:id,'P32_ALTY_CODE').set 'Office' 
    @@ie.select_list(:id,'P32_CACA_CODE').set 'Blind'
    @@ie.select_list(:id,'P32_ASSET_LOCATION_NOTES').set 'Post'
    @@ie.text_field(:id,'P32_ACCESS_PASSWORD').set 'Test 25'
    @@ie.text_field(:id,'P32_ACCESS_ADDITIONAL').set 'no more info'
    @@ie.text_field(:id,'P32_TRANSACTION_REFERENCE').set 'this is test 25'
    @@ie.text_field(:id,'P32_INSTALL_SUB_BUILDING').set ADDRESSB[0]
    @@ie.text_field(:id,'P32_INSTALL_BUILDING').set ADDRESSB[1]
    @@ie.text_field(:id,'P32_INSTALL_STREET').set ADDRESSB[2]
    @@ie.text_field(:id,'P32_INSTALL_CITY').set ADDRESSB[3]
    @@ie.text_field(:id,'P32_INSTALL_POSTCODE').set ADDRESSB[4]
    @@ie.text_field(:id,'P32_FIRST_CONTACT_TITLE').set 'Miss'
    @@ie.text_field(:id,'P32_FIRST_CONTACT_INITIALS').set 'Q'
    @@ie.text_field(:id,'P32_FIRST_CONTACT_NAME').set 'Charlie Test25'
    @@ie.text_field(:id,'P32_FIRST_CONTACT_TELEPHONE_1').set '123456789'
    @@ie.text_field(:id,'P32_FIRST_CONTACT_TELEPHONE_2').set '123456789'
    @@ie.text_field(:id,'P32_FIRST_CONTACT_FAX').set '123456789'
    @@ie.text_field(:id,'P32_FIRST_CONTACT_EMAIL').set 'jamie.priest@advanticagroup.com'    
    @@ie.button(:class, 'save').click
    @@ie.wait
    assert_nil(@@ie.contains_text('Error'),'Error found '+geterrormess(@@ie)) 
    assert(@@ie.button(:class, 'update').exists?,'Could not find a Save(update) button')         
    assert(@@ie.button(:value, 'Upload File').exists?,'Could not find a Save button')         
    @@ie.button(:value, 'Upload File').click
    @@ie.wait
    #check the regions appear
    assert(@@ie.contains_text('Current Files'),'Current Files region not found '+geterrormess(@@ie))
    assert(@@ie.contains_text('Upload File'),'Upload File region not found '+geterrormess(@@ie))
    #we know InstallMIP.cmd is around
    @@ie.file_field(:id, 'P41_FILE_UPLOAD').set(WORKINGDIR+'\\InstallMIP.cmd')
    @@ie.button(:value, 'Upload').click
    @@ie.wait
    assert(@@ie.contains_text('File for enquiry uploaded'),'Upload success message not found '+geterrormess(@@ie))
    assert(@@ie.button(:value, 'Delete File').exists?,'Could not find a Delete File button')         
    @@ie.button(:value, 'Delete File').click
    @@ie.wait
    #check the regions appear
    assert(@@ie.contains_text('Current Files'),'Current Files region not found '+geterrormess(@@ie))
    assert(@@ie.contains_text('Upload File'),'Upload File region not found '+geterrormess(@@ie))
    #Due to the Antivirus checking the file may not yet be ready for deleting 
    #so I've remove the assertion below
    #assert(@@ie.link(:text,'Delete').exists?,'Could not find a Delete link')         
  end
  
  def test_27_upload_manual_quote
    menu('Logout')
    assert(@@ie.button(:value, 'Login').exists?,'The Login button was not available')        
    @@ie.button(:value, 'Login').click        
    @@ie.wait
    login(MIPADMIN, MIPADMIN_PWD)
    menu('Enquiries')
    @@ie.button(:id, 'NEW').click
    assert(@@ie.contains_text('Enquiry'),'The Enquiry screen did not appear '+geterrormess(@@ie))
    #check the regions appear
    assert(@@ie.contains_text('Site Detail'),'Site Detail region not found')
    assert(@@ie.contains_text('Site Address'),'The Site Address region not found')
    assert(@@ie.contains_text('Contact Details'),'The Contact Details region not found')
    assert(@@ie.contains_text('Job Info'),'The Job Info region not found') 
    #check we've got the save and cancel buttons but not apply changes
    assert(@@ie.button(:class, 'save').exists?,'Could not find a Save button')
    assert(@@ie.button(:value, 'Cancel').exists?,'Could not find a Cancel button')
    assert_not_equal(@@ie.button(:class, 'update').exists?,true,'Found Save(update) button when it should have been hidden')
    #make sure that the ID field is not accessable (a form object)
    #assert_not_equal(@@ie.text_field(:name, 'P32_ID').exists?,true,'Found Apply Changes button when it should have been hidden')
    @@ie.select_list(:id,'P32_MKTP_REF').set 'Northern Supplies'
    @@ie.wait
    @@ie.select_list(:id,'P32_AGENT_ID').set 'Fred Smith'
    @@ie.wait
    @@ie.select_list(:id,'P32_AGENT_COMT_CODE').set 'Fax'
    @@ie.wait
    @@ie.text_field(:id,'P32_AGENT_CONTACT_VALUE').set '1234567890'
    @@ie.select_list(:id,'P32_ALTY_CODE').set 'Office' 
    @@ie.select_list(:id,'P32_CACA_CODE').set 'Blind'
    @@ie.select_list(:id,'P32_ASSET_LOCATION_NOTES').set 'Post'
    @@ie.text_field(:id,'P32_ACCESS_PASSWORD').set 'Test 26'
    @@ie.text_field(:id,'P32_ACCESS_ADDITIONAL').set 'no more info'
    @@ie.text_field(:id,'P32_TRANSACTION_REFERENCE').set 'this is test 26'
    @@ie.text_field(:id,'P32_INSTALL_SUB_BUILDING').set ADDRESSB[0]
    @@ie.text_field(:id,'P32_INSTALL_BUILDING').set ADDRESSB[1]
    @@ie.text_field(:id,'P32_INSTALL_STREET').set ADDRESSB[2]
    @@ie.text_field(:id,'P32_INSTALL_CITY').set ADDRESSB[3]
    @@ie.text_field(:id,'P32_INSTALL_POSTCODE').set ADDRESSB[4]
    @@ie.text_field(:id,'P32_FIRST_CONTACT_TITLE').set 'Dr'
    @@ie.text_field(:id,'P32_FIRST_CONTACT_INITIALS').set 'P'    
    @@ie.text_field(:id,'P32_FIRST_CONTACT_NAME').set 'Chaz Test26'
    @@ie.text_field(:id,'P32_FIRST_CONTACT_TELEPHONE_1').set '123456789'
    @@ie.text_field(:id,'P32_FIRST_CONTACT_TELEPHONE_2').set '123456789'
    @@ie.text_field(:id,'P32_FIRST_CONTACT_FAX').set '123456789'
    @@ie.text_field(:id,'P32_FIRST_CONTACT_EMAIL').set 'jamie.priest@advanticagroup.com'  
    @@ie.select_list(:id,'P32_ENTY_CODE').set @@enquirytypes[7]
    @@ie.wait
    @@ie.text_field(:id,'P32_MPRN').set '12345678910'
    @@ie.button(:class, 'save').click
    @@ie.wait
    assert_nil(@@ie.contains_text('Error'),'Error found '+geterrormess(@@ie)) 
    assert(@@ie.button(:class, 'update').exists?,'Could not find a Save(update) button')         
    assert(@@ie.button(:value, 'Upload File').exists?,'Could not find a Save button')         

    assert_nil(@@ie.contains_text('Error'),'Error found')    
    assert_equal(false,@@ie.button(:class, 'save').exists?,'Found Save button when it should have been hidden')
    assert(@@ie.button(:class, 'update').exists?,'Could not find a Save(update) button')    
    assert(@@ie.button(:value, 'Cancel').exists?,'Could not find a Cancel button')  
    assert(@@ie.button(:value, 'Upload File').exists?,'Could not find an Upload File button')
    assert(@@ie.text_field(:id,'P32_ID').to_s,'No value in the ID field')
    #
    #We'll save the enquiry id so we can search for it later
    #
    @@savedenquiryid = @@ie.text_field(:id,'P32_ID').value    
    #Job details
    
    @@ie.select_list(:id,'P32_EXISTING_METER_OWNER').set 'Supplier'
    @@ie.text_field(:id,'P32_EXISTING_METER_ASSET_PROVIDER').set 'Mam stuff goes here'
    #@@ie.select_list(:id,'P32_INDICATIVE_TIME').set ''
    @@ie.select_list(:id,'P32_REQUIRED_SVCP_CODE').set 'MP65'
    @@ie.wait
    @@ie.text_field(:id,'P32_ANNUAL_QUANTITY').set '1000'
    @@ie.text_field(:id,'P32_REQUIRED_METERING_PRESSURE').set '65'
    @@ie.select_list(:id,'P32_DS_BOOSTER_OR_COMPRESS').set 'Yes'
    @@ie.text_field(:id,'P32_INDICATIVE_DATE').set '17/07/2008'
    @@ie.text_field(:id,'P32_OTHER_PROJECT_REFERENCE').set 'Test 23'
    @@ie.select_list(:id,'P32_HOUSING_REQUIRED').set 'No'
    @@ie.select_list(:id,'P32_BASE_REQUIRED').set 'No'
    @@ie.select_list(:id,'P32_CONVERTOR_REQUIRED').set 'Yes'
    #@@ie.select_list(:id,'P32_AMR_REQUIRED').set 'No'
    @@ie.select_list(:id,'P32_EMS_REQUIRED').set 'No'
    @@ie.select_list(:id,'P32_BYPASS_REQUIRED').set 'Not required'
    @@ie.wait
    @@ie.select_list(:id,'P32_LOAD_CONTROL_TYPE').set 'Constant'
    @@ie.select_list(:id,'P32_TWIN_STREAM_REQUIRED').set 'No'
    @@ie.text_field(:id,'P32_JOB_DESCRIPTION').set ''
    @@ie.text_field(:id,'P32_QMAX').set '100'
    @@ie.text_field(:id,'P32_QMIN').set '0'
    #@@ie.select_list(:id,'P32_EXISTING_METY_CODE').set ''
    #@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').set ''
    #@@ie.text_field(:id,'P32_EXISTING_METER_SERIAL_NO').set ''
    #@@ie.text_field(:id,'P32_EXISTING_METR_CODE').set ''
    #@@ie.select_list(:id,'P32_MARKET_SECTOR_CODE').set ''
    @@ie.text_field(:id,'P32_OTHER_INFORMATION').set ''
    #@@ie.text_field(:id,'P32_EXISTING_LOGGER').set ''
    #@@ie.text_field(:id,'P32_EXISTING_CONVERTOR').set ''
    @@ie.button(:value, 'Request Quotation').click    
    @@ie.wait
    assert_nil(@@ie.contains_text('Error'),'Error found '+geterrormess(@@ie))
    menu('Enquiries')
    assert(@@ie.contains_text('Search Enquiries'),'Search Enquiries region not found')
    assert(@@ie.contains_text('All Enquiries'),'All Enquiries region not found')
        
    assert(@@ie.button(:value, 'Search').exists?,'Could not find a Search button')
    assert(@@ie.button(:value, 'New').exists?,'Could not find a New button')

    @@ie.text_field(:id,'P30_ENQUIRY_ID').set @@savedenquiryid 
    @@ie.button(:value, 'Search').click
    @@ie.wait
    assert(@@ie.contains_text(@@savedenquiryid),' Enquiry '+@@savedenquiryid+' not found '+geterrormess(@@ie))
    assert(@@ie.link(:name,'View_enquiry_'+@@savedenquiryid).exists?,'Could not find link to Enquiry '+@@savedenquiryid)
    @@ie.link(:name,'View_enquiry_'+@@savedenquiryid).click
    @@ie.wait
    assert(@@ie.contains_text('Enquiry'),'The Enquiry screen did not appear '+geterrormess(@@ie))
    #check the regions appear
    assert(@@ie.contains_text('Site Detail'),'Site Detail region not found')
    assert(@@ie.contains_text('Site Address'),'The Site Address region not found')
    assert(@@ie.contains_text('Contact Details'),'The Contact Details region not found')
    assert(@@ie.contains_text('Job Info'),'The Job Info region not found') 
    assert_equal(@@savedenquiryid,@@ie.text_field(:id,'P32_ID').value,' Enquiry screen for'+@@savedenquiryid+' not found')
    assert(@@ie.hidden(:id,'P32_ACCESS_PASSWORD').exists?,'Password field is not read only, it should be!') 
    #Start manual quote stuff 
    assert(@@ie.button(:value, 'Manual Quote').exists?,'Could not find Manual Quote button')
    @@ie.button(:value, 'Manual Quote').click
    @@ie.wait
    @@ie.file_field(:id, 'P41_FILE_UPLOAD').set(WORKINGDIR+'\\InstallMIP.cmd')
    @@ie.button(:value, 'Upload').click    
    @@ie.wait
    assert_nil(@@ie.contains_text('Error'),'Error found '+geterrormess(@@ie))
    menu('Enquiries')
    @@ie.text_field(:id,'P30_ENQUIRY_ID').set @@savedenquiryid 
    @@ie.button(:value, 'Search').click
    @@ie.wait
    assert(@@ie.contains_text(@@savedenquiryid),' Enquiry '+@@savedenquiryid+' not found '+geterrormess(@@ie))
    assert(@@ie.link(:name,'View_enquiry_'+@@savedenquiryid).exists?,'Could not find link to Enquiry '+@@savedenquiryid)
    @@ie.link(:name,'View_quote_'+@@savedenquiryid).click
    @@ie.wait
    assert(@@ie.contains_text(@@savedenquiryid),' Enquiry '+@@savedenquiryid+' not found '+geterrormess(@@ie))
    assert(@@ie.contains_text('Manual Quote'),'Manual Quote Region not found '+geterrormess(@@ie))
    assert(@@ie.link(:text,'View PDF').exists?,'Could not find link to manual quote file '+geterrormess(@@ie))      
  end
#Tripartite agreement(need to get data)
#Test Manual quote, request for quote and upload file buttons
  def test_28_check_the_meter_model_selection
    fulllisofmetertypes=["-Please select a value-",
                        "- OTHER -",
                        "Coriolis",
                        "Diaphragm",
                        "Orifice","Rotary",
                        "Turbine",
                        "Ultrasonic flow"]
    menu('Logout')
    assert(@@ie.button(:value, 'Login').exists?,'The Login button was not available')        
    @@ie.button(:value, 'Login').click        
    @@ie.wait
    login(MIPADMIN, MIPADMIN_PWD)
    menu('Enquiries')
    @@ie.button(:id, 'NEW').click 
    assert(@@ie.contains_text('Enquiry'),'The Enquiry screen did not appear '+geterrormess(@@ie))
    #Set the enquiry to an exchange job as this requires the user to select a meter to remove
    @@ie.select_list(:id,'P32_ENTY_CODE').set @@enquirytypes[5]
    @@ie.wait   
    #check the fields we want to test have remained on the page 
   # assert(@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').exists?,'Could not find P32_EXISTING_MESC_CODE select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_METY_CODE').exists?,'Could not find P32_EXISTING_METY_CODE select list')
    assert(@@ie.select_list(:id,'P32_EXISTING_PRTY_ID').exists?,'Could not find P32_EXISTING_PRTY_ID field')
    assert(@@ie.select_list(:id,'P32_EXISTING_METR_CODE').exists?,'Could not find P32_EXISTING_METR_CODE field')
    #set the meter size to U16, this should force the meter type to default to diaphragm
    #@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').set 'U16'
    #@@ie.wait
    #assert_equal(["-Please select a value-","Diaphragm"],@@ie.select_list(:id,'P32_EXISTING_METY_CODE').getAllContents,'List of options for P32_EXISTING_METY_CODE did not match what was expected') 
    #check that if we select OTHER and -Please select a value- all the meter types are available
    #@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').set '-Please select a value-'
    #@@ie.wait 
    assert_equal(fulllisofmetertypes,@@ie.select_list(:id,'P32_EXISTING_METY_CODE').getAllContents,'List of options for P32_EXISTING_METY_CODE did not match what was expected') 
    #@@ie.select_list(:id,'P32_EXISTING_MESC_CODE').set 'OTHER'
    #@@ie.wait 
    #assert_equal(fulllisofmetertypes,@@ie.select_list(:id,'P32_EXISTING_METY_CODE').getAllContents,'List of options for P32_EXISTING_METY_CODE did not match what was expected') 
    #check that the list of meters is more than 2 items long if the meter type is diaphragm
    #we would always expect to have at least one manufacturer for diaphragms 
    @@ie.select_list(:id,'P32_EXISTING_METY_CODE').set "Diaphragm"
    assert(@@ie.select_list(:id,'P32_EXISTING_METR_CODE').getAllContents.length > 2,"Did not find any diaphragm meter models")
    assert(@@ie.select_list(:id,'P32_EXISTING_PRTY_ID').getAllContents.length > 0,"Did not find any diaphragm meter manufacturers")
        
  end
  def test_50_logout
    menu('Logout')
    assert(@@ie.button(:value, 'Login').exists?,'The Login button was not available '+geterrormess(@@ie))        
    @@ie.button(:value, 'Login').click        
    @@ie.wait
  end
   
end  