This is simple program of using the for loop in QTP automation .
Steps to develop this program:
1. start a for net loop from 0 and end at 10
2. put a if statement inside the for loop and if condition satisfy exit the loop by writing “Exit For”
3. Print the loop counter values inside the loop.
Program Code:
<html>
<body>
<script type="text/vbscript">
For i = 0 To 10
If i=5 Then Exit For
document.write("The loop counter # " & i & "<br />")
Next
</script>
</body>
</html>
Output:
Where to Run This Program:
1. This VBScript Program code either you can use in QTP editor (code between <script> and </script> tags ) and run it.
2. Write in Notepad, save with .htm extension and run on internet explorer.
This doesn't work in the standard QTP editor. It returns a syntax error.
ReplyDeletePlease use msgbox in place of document.write()
ReplyDelete