Jmeter beanshell: get variable type

Examples:

if (vars.get(“price_matchNr”) instanceof Integer){
log.info(“integer”);
}
if (vars.get(“price_matchNr”) instanceof String){
log.info(“string”);
}
if (Integer.parseInt(vars.get(“price_matchNr”)) instanceof int){
log.info(“int”);
}
if (Integer.valueOf(vars.get(“price_matchNr”)) instanceof Integer){
log.info(“Integer ValueOf”);
}

Jmeter: first line of a csv not read in a loop

One obvious reason for this to happen is that you set the “ignore first line” parameter to true.

The most likely case is that you used the csv in another request before your loop. This previous request is taken into account and the first line is considered already done when the loop starts.

If you call the csv three times in three separate requests before using it in a loop, the loop will starts at the fourth line of the csv (disregarding the column name line), even though only the first line was read in the first attempt.

Log integer in beanshell and get integer from variables

Issue:

log.info() returns the following error in JMeter beanshell:

 Error in method invocation: Method info( int ) not found in class'org.apache.logging.slf4j.Log4jLogger'

Solution:

The error message indicates you are trying to pass an integer in the log.info() method. To prevent this issue, convert the integer to the type String using:

String SomeString = new Integer.toString(somInteger);

Similarly, numerals are passed as strings in JMeter variables, to make arithmetic operation on them, you’ll need to convert them to integer using:

int someInteger = new Integer.parseInt(someString);

Example use:

vars.put("test", new Integer(i).toString());