The current scope already contains a variable of the name locator2The current scope already contains a variable of the name locator2


"The current scope already contains a variable of the name locator2"

I’ve seen this errors quiet few times before and have always been able to fix it by removing the duplicate def for the variable.
However, this time I have removed the duplicate from this test case but it still keeps complaining. I’ve searched the file/testcase but can’t find another
reference of locator2. I’ve closed and reopened Katalon. I’ve deleted bin, libs, .classpath, and project folders but I’m still getting the same error.
It’s a long test case so I don’t want to delete and retype it.

Any help will be appreciated. Thanks

Are you changing the data type of “locator2”? In other words, are you using “locator2” to contain an Integer at one time and then a String at another? Or any other two data types. You cannot do that. The data type you define it the first time is how it needs to stay (within the variable’s scope).

Or you can change the locator2 variable name anytime it is on the left hand side of an assignment (equate) statement to see which line is causing the concern.

Back in my early days with Katalon, I had this same issue. Nothing seems to fix it, except…

  1. Copy/paste the source to another editor – not Katalon, use anything else.
  2. Delete the file in Katalon.
      – Check on disk the file is deleted!
  3. Close Katalon.
  4. Repeat the steps to clean Katalon (libs, bin, etc).
  5. Start Katalon.
      – At this point the error should be gone.
  6. Start a new file (you might try a different name).
  7. Paste the copy into the new file, save.

Hopefully, the problem has gone away.

1 Like

If you are seeing this error message in the Problems tab, then I would suggest to delete the error from the Problems tab and then run your test again.

Copying to notepad and then following all the steps Russ_Thomas suggested finally worked.

1 Like