Variable Scope Question - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners) +--- Thread: Variable Scope Question (/Thread-Variable-Scope-Question) |
Variable Scope Question - morecarl - 11-05-2008 I am trying to optimize a recorded test. The existing test assigns employees to departments in a home grown web application. In expert view, I have tried to define a couple of variables and added an IF statement to test if the current iteration is updating the same department record as the previous iteration. If it is the same department, I just add the next employee. If it is different - then I close the existing department and have the application open the next department before adding the next employee record. My question pertains to variable scope. Each new iteration does not seem to be able to read the "lastDepartment" variable that was defined during the previous iteration - so when I compare currentDepartment to lastDepartment they never match and the application closes the department record and then just reopens it. How do I define a variable during the execution of an iteration so that it is available to the next iteration? RE: Variable Scope Question - manojmathew1984 - 11-28-2008 if you take last department value from datasheet, then there is no need to store it to a variable. you can get the currentrow of the iteration check the value in the datasheet for that row and previous row. |