Forum Discussion

tonje_almending's avatar
tonje_almending
Occasional Contributor
10 years ago

For Loop not working as it should

Hi!

I'm trying to setup a memory leak test similar to the one you have in a video tutorial. I can't, however, get the for loop to behave as it should.

It runs through the test as it should the first time, but the second time it fails to find the start page after logging in. This is for chrome, firefox and ie. And I never close the browser during the test.

If I add a test step for closing the browser at the end of the test, it fails to launch the browser at the second iteration.

Any idea why this is not working?

6 Replies

  • I tried to use aqFile WriteToTextFile for myself for the first time.  I noticed some traps for the unwary (all of which I fell into):



    - Your Path parameter doesn't look right.  I suspect that you used a Code Expression and entered a string.  Rather, enter a Constant of String Type with the filename as the Value.  When done, that Step in your Test Steps window should show the backslashes doubled.



    - I forgot to modify the TextCodingType parameter.  The default of '0' doesn't work (for me).  For that I had to use a Code Expression with a Value of aqFile.ctANSI (or a Constant Integer of 20).  Other values are available.  See the article



      WriteToTextFile Method



    - You may need to set the OverwriteOrCreate parameter to true.

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Tonje,



    So, according to your description, the Loop itself works as expected (i.e. loops for the second iteration), isn't it?



    As for the other problems you've mentioned: start page most probably it not recognized because it is identified by the not stable parameters. And the browser may not be started because there is no command to start it.

    You may get a more definite answer if you provide us with more details about your problematic test (code, screenshots, etc.).
  • tonje_almending's avatar
    tonje_almending
    Occasional Contributor
    Hi,

    I solved the problem myself - I had placed the aqFile object method call in the wrong place.

    I have, however, bumped into another problem:

    The test is not running the aqFile writhe to text file object call at all. And I can't see what's wrong?
  • tonje_almending's avatar
    tonje_almending
    Occasional Contributor
    Thanks for the answer to both of you!

    Joseph: My aqFile WriteToTextFile was configured exactly the way you have described it.

    It seems like the test is not running the aqFile at all, because it is not mentioned in the log. I tried to create an aqFile OpenTextFile at the start of the test, but the test is not running that step either. 

    Jeremy: The file exists, and is writeable. "OverwriteOrCreate" is set to False.

    I was hoping to solve this without any scripting, but I think I will give it a go, and see if I can solve the problem that way. I can't find any way to close the file without coding?







  • tonje_almending's avatar
    tonje_almending
    Occasional Contributor
    Hi again!

    I finally got my memory leak test to work by scripting the test. I had to convert the CPU usage and memory usage into a string




        intCPU = Sys.Process("firefox").CPUUsage


        strCPU = aqConvert.IntToStr(intCPU)


        


        intMem = Sys.Process("firefox").MemUsage


        strMem = aqConvert.IntToStr(intMem)


        


        Call MemOutput.WriteLine(strCPU + ";" + strMem)



    Next I also solved my loop issue:

    When the close browser command is called, the process is not properly shut down. (A bug to report for Testcomplete?)

    So in order for the next iteration to run properly, I had to kill the browser process.




        Aliases.browser.BrowserWindow.Close


        


        Dim browser


        Set browser = Sys.Process("firefox")


        


        If browser.Exists then


          browser.Close


        End if