'This script is to initiate a Leave Request . It does not check leave balances, so you must ensure the employee has enough of each type requested ' ENTRY : Application is on the ETM launchpad for the accepting employee, i.e. the substitute ' Employee has sufficient leave time for the type of hours requested ' EXIT: Application is on the ETM launchpadfor the accepting employee, i.e. the substitute Dim rowcounter, numleavedates, errmsg 'Get the data from the data file for this leave request Datatable.ImportSheet "..\Leave Request Test Data.xls" , Parameter ("Requestor"), "Leave Request [Leave Request]" 'Get the number of rows for this leave request; this script will process up to 6. If the number is blank, it assumes 1 and if the number is > 6 it gives a message and stops. 'It needs this ahead of time because the script needs to know how many rows of data go to each requestor. numleavedates = DataTable.GetSheet("Leave Request [Leave Request]").GetRowCount If numleavedates > 6 Then Reporter.ReportEvent micFail, "Row Verification Failed","Script reads a max of 6 rows. " & Parameter ("Requestor") & " not tested." ExitTest End If If numleavedates = 0 Then Reporter.ReportEvent micFail, "Data Verification Failed","Date is blank. Test for " & Parameter ("Requestor") & " terminated.." ExitTest End If 'Click on the leave request link to go to the leave request page Browser("vw_browser").Page("ETM Launchpad").Link("Leave Request").Click Do'this loop is for handling improper inputs for balances For rowcounter = 1 to numleavedates 'this loops handles each line of leave request DataTable.SetCurrentRow(rowcounter) Select Case rowcounter Case "1" 'Fill in the information including dates, times, comments Browser("vw_browser").Page("Leave Request").WebEdit("dpNewStartDate_DBT_1_dummy").Set DataTable("Start_Date", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewStartTime_DBT_1_time").Set DataTable("Start_Time", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("dpNewEndDate_DBT_1_dummy").Set DataTable("End_Date", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewEndTime_DBT_1_time").Set DataTable("End_Time", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewComments_DBT_1").Set DataTable("Comment", "Leave Request") Browser("vw_browser").Page("Leave Request").WebButton("Choose_1").Click Case "2" 'Fill in the information including dates, times, comments Browser("vw_browser").Page("Leave Request").WebEdit("dpNewStartDate_DBT_2_dummy").Set DataTable("Start_Date", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewStartTime_DBT_2_time").Set DataTable("Start_Time", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("dpNewEndDate_DBT_2_dummy").Set DataTable("End_Date", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewEndTime_DBT_2_time").Set DataTable("End_Time", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewComments_DBT_2").Set DataTable("Comment", "Leave Request") Browser("vw_browser").Page("Leave Request").WebButton("Choose_2").Click Case "3" 'Fill in the information including dates, times, comments Browser("vw_browser").Page("Leave Request").WebEdit("dpNewStartDate_DBT_3_dummy").Set DataTable("Start_Date", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewStartTime_DBT_3_time").Set DataTable("Start_Time", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("dpNewEndDate_DBT_3_dummy").Set DataTable("End_Date", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewEndTime_DBT_3_time").Set DataTable("End_Time", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewComments_DBT_3").Set DataTable("Comment", "Leave Request") Browser("vw_browser").Page("Leave Request").WebButton("Choose_3").Click Case "4" 'Fill in the information including dates, times, comments Browser("vw_browser").Page("Leave Request").WebEdit("dpNewStartDate_DBT_4_dummy").Set DataTable("Start_Date", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewStartTime_DBT_4_time").Set DataTable("Start_Time", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("dpNewEndDate_DBT_4_dummy").Set DataTable("End_Date", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewEndTime_DBT_4_time").Set DataTable("End_Time", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewComments_DBT_4").Set DataTable("Comment", "Leave Request") Browser("vw_browser").Page("Leave Request").WebButton("Choose_4").Click Case "5" 'Fill in the information including dates, times, comments Browser("vw_browser").Page("Leave Request").WebEdit("dpNewStartDate_DBT_5_dummy").Set DataTable("Start_Date", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewStartTime_DBT_5_time").Set DataTable("Start_Time", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("dpNewEndDate_DBT_5_dummy").Set DataTable("End_Date", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewEndTime_DBT_5_time").Set DataTable("End_Time", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewComments_DBT_5").Set DataTable("Comment", "Leave Request") Browser("vw_browser").Page("Leave Request").WebButton("Choose_5").Click Case "6" 'Fill in the information including dates, times, comments Browser("vw_browser").Page("Leave Request").WebEdit("dpNewStartDate_DBT_6_dummy").Set DataTable("Start_Date", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewStartTime_DBT_6_time").Set DataTable("Start_Time", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("dpNewEndDate_DBT_6_dummy").Set DataTable("End_Date", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewEndTime_DBT_6_time").Set DataTable("End_Time", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tbNewComments_DBT_6").Set DataTable("Comment", "Leave Request") Browser("vw_browser").Page("Leave Request").WebButton("Choose_6").Click End Select 'Divide up hours to the various types of leave Browser("vw_browser").Page("Leave Request").WebEdit("vac_hrs").Set DataTable("Vac_hrs", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("per_hrs").Set DataTable("Per_hrs", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("sck_hrs").Set DataTable("SCK", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("th_hrs").Set DataTable("_4th", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("cd_hrs").Set DataTable("CD", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("ce_hrs").Set DataTable("CE", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("ld_hrs").Set DataTable("LD", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("md_hrs").Set DataTable("MD", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("nyd_hrs").Set DataTable("NYD", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("tgd_hrs").Set DataTable("TGD", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("poff_hrs").Set DataTable("POFF", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("brv_hrs").Set DataTable("BRV", "Leave Request") Browser("vw_browser").Page("Leave Request").WebEdit("jry_hrs").Set DataTable("JRY", "Leave Request") 'Browser("vw_browser").Page("Leave Request").WebEdit("sckup_hrs").Set DataTable("SCK_UP", "Leave Request") 'Browser("vw_browser").Page("Leave Request").WebEdit("vacup_hrs").Set DataTable("VAC_UP", "Leave Request") 'Browser("vw_browser").Page("Leave Request").WebEdit("mil_hrs").Set DataTable("MIL", "Leave Request") 'Browser("vw_browser").Page("Leave Request").WebEdit("fml_hrs").Set DataTable("FML_UP", "Leave Request") 'Save the choices (which also calculates the number of hours) Browser("vw_browser").Page("Leave Request").WebButton("Save Choice").Click If Left(Browser("vw_browser").Dialog("DialogText").Static("StaticMessage").GetVisibleText, 4) = "Hour" then Reporter.ReportEvent micPass, "Hours Verfification", "VandyWorks has verified the number of hours is not zero. The script will adjust the balances to continue." Browser("vw_browser").Dialog("DialogText").WinButton("OK").Click While Browser("vw_browser").Page("Leave Request").webedit("hrsLeft").GetROProperty("value") <> 0 If Browser("vw_browser").Page("Leave Request").webedit("hrsLeft").GetROProperty("value") > 0 Then Reporter.ReportEvent micPass, "Hours Verfification", "VandyWorks has verified the number of hours is more than zero. The script will add hours to Vacation to continue." While Browser("vw_browser").Page("Leave Request").webedit("hrsLeft").GetROProperty("value") > 0 DataTable("Vac_hrs", "Leave Request") = DataTable("Vac_hrs", "Leave Request") + 1 Browser("vw_browser").Page("Leave Request").WebEdit("vac_hrs").Set DataTable("Vac_hrs", "Leave Request") Wend Else Reporter.ReportEvent micPass, "Hours Verfification", "VandyWorks has verified the number of hours is less than zero. The script will adjust the balances to continue." While Browser("vw_browser").Page("Leave Request").webedit("hrsLeft").GetROProperty("value") < 0 and DataTable("Per_hrs", "Leave Request") > 0 DataTable("Per_hrs", "Leave Request") = DataTable("Per_hrs", "Leave Request") - 1 Browser("vw_browser").Page("Leave Request").WebEdit("per_hrs").Set DataTable("Per_hrs", "Leave Request") Wend While Browser("vw_browser").Page("Leave Request").webedit("hrsLeft").GetROProperty("value") < 0 and DataTable("SCK", "Leave Request") > 0 DataTable("SCK", "Leave Request") = DataTable("SCK", "Leave Request") - 1 Browser("vw_browser").Page("Leave Request").WebEdit("sck_hrs").Set DataTable("SCK", "Leave Request") Wend While Browser("vw_browser").Page("Leave Request").webedit("hrsLeft").GetROProperty("value") < 0 DataTable("Vac_hrs", "Leave Request") = DataTable("Vac_hrs", "Leave Request") -1 Browser("vw_browser").Page("Leave Request").WebEdit("vac_hrs").Set DataTable("Vac_hrs", "Leave Request") Wend End If Wend 'Save the choice again; it should go through as Browser("vw_browser").Page("Leave Request").WebButton("Save Choice").Click End if Browser("vw_browser").Dialog("DialogText").WinButton("OK").Click 'if there are more than 3 rows of leave dates, then you must add a row, but you can't add it until after you have filled up the 3 existing rows ' this conidition is reached when rowcounter = 3, i.e. the 3 existing rows are full, and numleavedates > 3, meaning you want more rows If (rowcounter = 3 and numleavedates > 3) Then Browser("vw_browser").Page("Leave Request").WebButton("Add Rows").Click Wait (1) Browser("vw_browser").WinButton("This website is using").Click Browser("vw_browser").WinMenu("ContextMenu").Select "Temporarily Allow Scripted Windows" Browser("vw_browser").Page("Leave Request").WebButton("Add Rows").Click Browser("vw_browser").Dialog("Explorer User Prompt").WinEdit("How many rows would you").Set numleavedates Browser("vw_browser").Dialog("Explorer User Prompt").WinButton("OK").Click End If Next 'rowcounter 'Submit the leave request and wait for it to be entered and returns you to "Your form has been submitted page" Browser("vw_browser").Page("Leave Request").WebButton("Submit Request").Click Browser("vw_browser").Page("Leave Request").Sync If Browser("vw_browser").webelement("Your Form Has Been Submitted").Exist Then 'It means everything is okay with the submission Reporter.ReportEvent micPass, "Balance Verfication", "VandyWorks has submitted the form." Exit do End If If Browser("vw_browser").Page("Valdiation_Error_Page").Exist Then 'Write to report the name of the requestor and the values for the request; reset all values for leave to 0 except for Vac_hrs to allow the script to continue Reporter.ReportEvent micPass, "Balance Verification", "VandyWorks balance check worked." errmsg = Browser("vw_browser").Page("Valdiation_Error_Page").WebElement("Validation Failure").GetROProperty("innertext") Reporter.ReportEvent micPass, "Validation Error Msg", errmsg rowcounter = 1 Do DataTable.SetCurrentRow(rowcounter) If (instr(errmsg, DataTable("Start_Date", "Leave Request")) <> 0) then Exit do rowcounter = rowcounter + 1 Loop Reporter.ReportEvent micPass, "Validation Error", ("Row Number" & rowcounter & " " & DataTable("Start_Date", "Leave Request")) If Instr(errmsg, "4TH") <> 0 Then Reporter.ReportEvent micPass, "Balance Verification", "VandyWorks balance check worked. Improper use for the 4th. The script will use Vac_hrs instead." DataTable("Vac_hrs", "Leave Request") = Int(DataTable("Vac_hrs", "Leave Request")) + Int(DataTable("_4th", "Leave Request")) DataTable("_4th", "Leave Request") = 0 ElseIf Instr(errmsg, "CD") <> 0 Then Reporter.ReportEvent micPass, "Balance Verification", "VandyWorks balance check worked. Improper use for the CD. The script will use Vac_hrs instead." DataTable("Vac_hrs", "Leave Request") = Int(DataTable("Vac_hrs", "Leave Request")) + Int(DataTable("CD", "Leave Request")) DataTable("CD", "Leave Request") = 0 ElseIf Instr(errmsg, "CE") <> 0 Then Reporter.ReportEvent micPass, "Balance Verification", "VandyWorks balance check worked. Improper use for the CE. The script will use Vac_hrs instead." DataTable("Vac_hrs", "Leave Request") = Int(DataTable("Vac_hrs", "Leave Request")) + Int(DataTable("CE", "Leave Request")) DataTable("CE", "Leave Request") = 0 ElseIf Instr(errmsg, "LD") <> 0 Then Reporter.ReportEvent micPass, "Balance Verification", "VandyWorks balance check worked. Improper use for the LD. The script will use Vac_hrs instead." DataTable("Vac_hrs", "Leave Request") = Int(DataTable("Vac_hrs", "Leave Request")) + Int(DataTable("LD", "Leave Request")) DataTable("LD", "Leave Request") = 0 ElseIf Instr(errmsg, "MD") <> 0 Then Reporter.ReportEvent micPass, "Balance Verification", "VandyWorks balance check worked. Improper use for the MD. The script will use Vac_hrs instead." DataTable("Vac_hrs", "Leave Request") = Int(DataTable("Vac_hrs", "Leave Request")) + Int(DataTable("MD", "Leave Request")) DataTable("MD", "Leave Request") = 0 ElseIf Instr(errmsg, "NYD") <> 0 Then Reporter.ReportEvent micPass, "Balance Verification", "VandyWorks balance check worked. Improper use for the NYD. The script will use Vac_hrs instead." DataTable("Vac_hrs", "Leave Request") = Int(DataTable("Vac_hrs", "Leave Request")) + Int(DataTable("NYD", "Leave Request")) DataTable("NYD", "Leave Request") = 0 ElseIf Instr(errmsg, "TGD") <> 0 Then Reporter.ReportEvent micPass, "Balance Verification", "VandyWorks balance check worked. Improper use for the TGD. The script will use Vac_hrs instead." DataTable("Vac_hrs", "Leave Request") = Int(DataTable("Vac_hrs", "Leave Request")) + Int(DataTable("TGD", "Leave Request")) DataTable("TGD", "Leave Request") = 0 ElseIf Instr(errmsg, "PER") <> 0 Then Reporter.ReportEvent micPass, "Balance Verification", "VandyWorks balance check worked. Improper use for the PER. The script will use Vac_hrs instead." DataTable("Vac_hrs", "Leave Request") = Int(DataTable("Vac_hrs", "Leave Request")) + Int(DataTable("Per_hrs", "Leave Request")) DataTable("Per_hrs", "Leave Request") = 0 ElseIf Instr(errmsg, "SCK") <> 0 Then Reporter.ReportEvent micPass, "Balance Verification", "VandyWorks balance check worked. Improper use for the SCK. The script will use Vac_hrs instead." DataTable("Vac_hrs", "Leave Request") = Int(DataTable("Vac_hrs", "Leave Request")) + Int(DataTable("SCK", "Leave Request")) DataTable("SCK", "Leave Request") = 0 ElseIf Instr(errmsg, "unexpected error") <> 0 Then Reporter.ReportEvent micFail, "Balance Verification", "VandyWorks enrowcountered an unexpected error. If input data is correct, investigate for possible defect." ExitAction (99) Else Reporter.ReportEvent micPass, "Balance Verification", "VandyWorks balance check worked. Improper use of a balance. The script will use Vac_hrs instead." DataTable("Vac_hrs", "Leave Request") = 12 DataTable("POFF", "Leave Request") = 0 DataTable("BRV", "Leave Request") = 0 DataTable("JRY", "Leave Request") = 0 End If errmsg = "" If numleavedates > 3 then Reporter.ReportEvent micPass, "Balance Verification", "VandyWorks has an error, so this will restart with updated balances.." Browser("vw_browser").Page("Leave Request").WebElement("Launchpad").Click 'this is here to start all over due to defect in VW Browser("vw_browser").Page("ETM Launchpad").Link("Leave Request").Click Else Browser("vw_browser").Page("Valdiation_Error_Page").WebButton("Go Back to the form").Click End if End If loop Reporter.ReportEvent micPass, "Leave Request", "Leave Request Submitted for Approval" 'Return to the launchpad Browser("vw_browser").Page("Leave Request").WebElement("Launchpad").Click