org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'null' with class 'null' to class 'int'. Try 'java.lang.Integer' instead

I am getting the above exception. What dis I miss?

WebUI.click(findTestObject(‘Object Repository/SchooladminFunctions/Lesson/CreateRepeatedLesson/start_time_input’))

def defaultStartTime = WebUI.getAttribute(findTestObject('SchooladminFunctions/Lesson/CreateRepeatedLesson/start_time_input'), 'value')

String[] parts = defaultStartTime.split(':')

String hourPart = parts[0]

String minPart = parts[1]

int min = Integer.parseInt(minPart)

int hour = Integer.parseInt(hourPart)

int startHour = calculateHour(hour, min)

int startMin = calculateClickableMinute(min)

TestObject hourCircle = WebUI.modifyObjectProperty(findTestObject('Object Repository/TeacherFunctions/Lesson/span_18'), 'text', 'equals', startHour.toString(), true)

WebElement element = WebUiCommonHelper.findWebElement(hourCircle, 5)

WebElement clickableElement = element.findElement(By.tagName('span'))

clickableElement.click()

TestObject minCircle = WebUI.modifyObjectProperty(findTestObject('Object Repository/TeacherFunctions/Lesson/span_18'), 'text', 'equals', startMin.toString(), true)

element = WebUiCommonHelper.findWebElement(minCircle, 5)

clickableElement = element.findElement(By.tagName('span'))

clickableElement.click()

def int calculateClickableMinute(int min) {

if(min % 5 == 0) {
	return min
}else if(min > 54) {
	return 0
}else {
int remainder = (min % 5)
	return (min - remainder + 5)
}

}

def int calculateHour(int hour, int min) {
if (min > 54) {
return hour ++
}
}

No, we can not find an answer for you out of the limited information you exposed.

In the Console tab, you would find a message that indicate which line of your script caused the Exception. Take a careful look.

In truth, it seems your error message is saying that your first line is not returning anything (or null)

def defaultStartTime = WebUI.getAttribute(findTestObject('SchooladminFunctions/Lesson/CreateRepeatedLesson/start_time_input'), 'value')

And if it is null, then everything goes downhill from there. So put some print statements so you can see their values. As an example, you are definitely doing two casts right here:

So, before this perhaps display their result to see if they have a value.

String hourPart = parts[0]

String minPart = parts[1]

WebUI.comment("the minute is ${minPart}")
WebUI.comment("the hour is ${hourPart}")

int min = Integer.parseInt(minPart) 
int hour = Integer.parseInt(hourPart)