Files
mip/Data/Test/apex_auto_install.rb

111 lines
3.2 KiB
Ruby

#requires
require 'watir'
#email stuff
require 'net/smtp'
#includes
include Watir
@@ie = IE.new
@@ie.visible= false
#set the speed of watir
@@ie.speed = :fast
#Set constants for import
ORIGINAL_APP_ID = '155'
NEW_APP_ID = '102'
SCHEMA = 'MIP_TEST'
APEX_EXPORT_SCRIPTS_DIR = 'c:\\webmip\\trunk\\Screens\\'
APPLICATION_SCRIPT = 'f155.sql'
CSS_SCRIPT = 'css.sql'
IMAGES_SCRIPT = 'f155_img.sql'
THEME_SCRIPT = 'f155_theme_101.sql'
ADID = '4550' #APEX admin identifier
WORKSPACE = 'MIP_TEST'
USER = 'ADMIN'
PASSWORD = 'password'
def importpageone (p_file, p_file_type, p_charset)
@@ie.link(:title, 'Application Builder').click
@@ie.wait
@@ie.button(:value, 'Import >').click
@@ie.wait
@@ie.file_field(:id, "P460_FILE").set(p_file)
@@ie.select_list(:id, "P460_FILE_TYPE").select p_file_type
@@ie.select_list(:id, "P460_FILE_CHARSET").select p_charset
@@ie.button(:value, 'Next >').click
@@ie.wait
@@ie.button(:value, 'Next >').click
@@ie.wait
end
begin
#Login
@@ie.goto("http://loordv01/pls/apex/f?p=#{ADID}:1")
@@ie.text_field(:id, "F#{ADID}_P1_COMPANY").set(WORKSPACE)
@@ie.text_field(:id, "F#{ADID}_P1_USERNAME").set(USER)
@@ie.text_field(:id, "F#{ADID}_P1_PASSWORD").set(PASSWORD)
@@ie.button(:value, 'Login').click
@@ie.wait
#Import Application export file
importpageone(APEX_EXPORT_SCRIPTS_DIR+APPLICATION_SCRIPT,
'Application, Page or Component Export',
'Western European Windows 1252')
#parse page
@@ie.select_list(:id, "P49_PARSE_AS" ).select(SCHEMA)
@@ie.select_list(:id, "P49_BUILD_STATUS" ).select 'Run and Build Application'
@@ie.radio(:id, "P49_NEW_FLOW_OPT_2" ).set
@@ie.wait
@@ie.text_field(:id, "P49_NEW_FLOW_ID").set(NEW_APP_ID)
@@ie.button(:value, 'Install').click
@@ie.wait
#This button won't appear the first time the import occurs
if @@ie.button(:value, 'Replace Existing Application '+NEW_APP_ID).exists?
@@ie.button(:value, 'Replace Existing Application '+NEW_APP_ID).click
@@ie.wait
end
#Install Supporting objects
@@ie.radio(:id, "P2100_ACTION_0" ).set
@@ie.button(:value, 'Next >').click
@@ie.wait
@@ie.button(:value, 'Install').click
@@ie.wait
#Install CSS
#Need to delete the existing CSS file before installing a new one
#have decided to just install the application for the moment.
#back to install page start
#importpageone(APEX_EXPORT_SCRIPTS_DIR+CSS_SCRIPT,
# 'CSS Export',
# 'Western European Windows 1252')
@@ie.close
rescue StandardError => anyerror
#Hopefully we never get here but, we'll try and send an email if the
#script errors so we can fix it
#don't leave memory hungry instances of ie running if we get an error
@@ie.close
#build the email
from_addr = 'jamie.priest@advantica.com'
to_addr = 'jamie.priest@advanticagroup.com'
project = 'webMIP test build process'
emailtext = <<END_EMAIL
From: webMIP <#{from_addr}>
To: Jamie Priest <#{to_addr}>
Subject: #{project} automated test failure
An automated assertion failed for the project
#{project}
#{anyerror}
END_EMAIL
Net::SMTP.start('LOMAIL01') do |smtp|
smtp.sendmail emailtext, from_addr, to_addr
end
end