[error] TypeError: Cannot read property 'condition' of undefined - Nested While

Hi! I have an issue with nested loop “while”.
**
TestCase:**

storeEval | 10 | pages
storeEval  | 1 | pageIndex
while | ${pageIndex}<${pages} |
store | page_${pageIndex} | url
store | 10 | rows
store | 0 | rowIndex
while | ${rowIndex}<${rows} |
storeEval | ${rowIndex} + 1 | rowIndex
store | click_${rowIndex} | click
endWhile  | |
storeEval | ${pageIndex} + 1 | pageIndex
endWhile

 Variables when error appears:




























pages 10
pageIndex 10
url page_10
rows 10
rowIndex 10
click click_10

And here is a tail of Log:
. . .

[info] Executing: | store | 10 | rows |

[info] Executing: | store | 0 | rowIndex |

[info] Executing: | while | ${rowIndex}<${rows} | |

[info] Executing: | storeEval | ${rowIndex} + 1 | rowIndex |

[info] Executing: | store | click_${rowIndex} | click |

[info] Executing: | endWhile | | |

[info] Executing: | endWhile | | |

[error] TypeError: Cannot read property ‘condition’ of undefined
. . .

Maybe I’m doing something wrong ?
Thank you!

1 Like

Example of issue here https://github.com/a2ncer/katalon-nested-loops

Browser: Chrome Version: 63.0

Katalon Automation Recorder: 3.3.2

I believe I’ve had a similar issue to what Alex is describing but in my case I’m setting up more than one variable in my script will cause the while statement to fail.

For example:

  1. I’m storing a date value in variable1:
    storeEval | new Date().getFullYear()-1 | variable1

I can echo this out and everything looks good

  1. later I’m storing the contents of an id into another variable, lets say variable2
    storeEval | this.browserbot.findElement("//div[@id=‘reportResultsBody’]").innerHTML; | variable2

again I can echo out the value, no problem

when I initiate my while statement using variable2 I get an error saying variable2 is undefined, the variable that I just echo’d out previously is now magically undefined

while | variable2 ==‘whatever my contents are’ |

at this point I get a message saying variable2 is undefined.

If I remove the line of code related to variable1 then my while statement works correctly. It seems like if you use the storeEval command to define multiple variables then whatever variable you want to use in your while statement will fail. I was able to work around the issue by only using storeEval once in my test case but that’s not very practical.

Hi Alex and Steven,

Both bugs have been fixed in 3.4.0. If you have any issue with the new version, kindly let me know.

Alex said:

Hi Alex and Steven,

Both bugs have been fixed in 3.4.0. If you have any issue with the new version, kindly let me know.

Hi Alex,
Now it works well.
Thank you!

Hi everyone. Thank you all for valuable feedback. I’ll close this discussion. If you have any issue, don’t hesitate to start a new one. We are happy to hear from you!

Continuing the discussion from [error] TypeError: Cannot read property 'condition' of undefined - Nested While:

No problem recording and playing the script?May ask why?I ![erro|548x500](upload://yQ5sEkPd8IXPsIHDaHmbPsflSh4.png