Using If-Else to get data from csv

What i’m trying to do is, when the variable I set matches the current data from csv, it will end the loop and stop the test.

here’s a sample script I did, which will display the data from the csv, but when it reaches a certain email/index, it will end the loop and stop the test.


i hope someone could help me as this is just my 1st week of using Katalon recorder for testing.


Hi, welcome to Katalon Forum :slight_smile:

You can try command “goToLabel” and “label”, so after “else” command use “goToLabel” and in target You put Your label name i.e. “goOutOfTheLoop” and after “endLoadVars” use command “label” and in target You put “goOutOfTheLoop”. I think it’s should work.

1 Like

There are probably two reasons that ifelse(data$colors == second$If, data$colors == second$then, data$colors == data$colors) doesn’t “work”. The inner reason is that the “==” function is not a test for set containment, but is rather a vectorized function that is probably not going to successful match up values in columns of two different dataframes. You probably do want to use %in% as was mentioned in Richard comment. But probably more importantly, you did not assign the value of the ifelse function to anything. (And ifelse does not do assignment within the consequent and alternate expressions. R is a functional language. You really only do useful actions when you assign values to an object. You would instead do something like:

data$colors[ data$colors %in% second$If] <- second$then[ match( data$colors, second$If) ]
This will replace any value of data$colors with the value of seconds$then indexed by a vector of the position of the data$colors-value within the second$If-vector.

(At least that’s what I think should happen. You provided no test data and many of us here think that is your responsibility, not ours. So this theory is untested for logical or syntactic errors on my part. Standard Warranty for Internet Advice: If it breaks, you get to keep all the pieces.)