Hello,
I am running following code and getting compilation error for the lines where I am parsing String to Int.
List ShiftGrid_Rows= DriverFactory.webDriver.findElements(By.xpath(’//tbody/tr’))
for (WebElement ShiftGridRow:ShiftGrid_Rows)
{
String Guest_to_Shift_Ratio= ShiftGridRow.findElement(By.xpath(’/td[2]’)).getText();
Int Guest_Ratio= Integer.parseInt(Guest_to_Shift_Ratio)
println ('Guest to shift Ratio is: '+Guest_to_Shift_Ratio)
String Guest_Count= WebUI.getText(findTestObject('Object Repository/Locators/Events/Shift Grid Panel/Guest_Count_Total'))
Int Guest_Count_Int= Integer.parseInt(Guest_Count)
println ('Guest Count is: '+Guest_Count)
Int Expected_Projected_Shifts= Guest_Ratio/Guest_Count_Int
Mod= Guest_to_Shift_Ratio%Guest_Count
if (Mod!=0) {
Expected_Projected_Shifts= Expected_Projected_Shifts+1
}
else {
Expected_Projected_Shifts= Expected_Projected_Shifts
}
String Actual_Projected_Shifts = ShiftGridRow.findElement(By.xpath('/td[3]')).getText()
Int Projected_Shifts= Integer.parseInt(Actual_Projected_Shifts)
//WebUI.verifyEqual(Actual_Projected_Shifts, Expected_Projected_Shifts)
Assert.assertEquals(Projected_Shifts, Expected_Projected_Shifts);
}
Because I have to some math operations, I need to convert Guest_to_Shift_Ratio and Guest_Count in Integers. But I get the following Compilation error.
11-26-2017 08:32:57 PM - [ERROR] - Test Cases/Events/Create Event- Valid Inputs FAILED because (of) org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
file:/C:/Users/b.rani/git/schedule-xpress-katalon/Scripts/Common/Test%20cases%20to%20be%20reused/Shift%20Grid%20Panel/Script1506712948187.groovy: 65: unable to resolve class Int
@ line 65, column 8.
Int Guest_Ratio= Integer.parseInt(Guest_to_Shift_Ratio)
^
file:/C:/Users/b.rani/git/schedule-xpress-katalon/Scripts/Common/Test%20cases%20to%20be%20reused/Shift%20Grid%20Panel/Script1506712948187.groovy: 69: unable to resolve class Int
@ line 69, column 8.
Int Guest_Count_Int= Integer.parseInt(Guest_Count)
^
file:/C:/Users/b.rani/git/schedule-xpress-katalon/Scripts/Common/Test%20cases%20to%20be%20reused/Shift%20Grid%20Panel/Script1506712948187.groovy: 72: unable to resolve class Int
@ line 72, column 8.
Int Expected_Projected_Shifts= Guest_Ratio/Guest_Count_Int
^
file:/C:/Users/b.rani/git/schedule-xpress-katalon/Scripts/Common/Test%20cases%20to%20be%20reused/Shift%20Grid%20Panel/Script1506712948187.groovy: 86: unable to resolve class Int
@ line 86, column 8.
Int Projected_Shifts= Integer.parseInt(Actual_Projected_Shifts)
^
4 errors