18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

How to solve the '[auto]' issue when running _readFile many times?

ilovepumpkinilovepumpkin Members
edited November -1 in Sahi - Open Source
I have a test case and when it runs it need to read a file many times. To reproduce my issues I created the following script which read a file (2.6 K) for 100 times. Then the script terminates unexpectedly but the result shows it completes 100%. And you can see "[auto]" in the log window. What does '[auto]' mean? I doubt it relates the memory but I have no idea about how to fix it. If you use a bigger file (say 10K) then you can reproduce this error with less times (say 50). Could you please let me know how I should fix this issue? Thanks.

=========My Script==========
<browser>
function testReadFile(){
var files=new Array();
for(var i=0; i<100; i++) {
var content=_readFile("/tmp/msgs/RAS.properties");
files.push(content);
}
return files;
}
</browser>

var $files=new Array();
_set($files,testReadFile());


============Log messages=================
Test Total Steps Failures Errors Success Rate Time Taken (ms)
test.sah 3 0 0 100% 10360

Starting script
_sahi.setServerVar('\$files', testReadFile());
[auto] at Dec 31, 2011 4:22:59 PM
null at Dec 31, 2011 4:23:02 PM
_log(null); at Dec 31, 2011 4:23:02 PM
Stopping script
=========================
_log($files);

Comments

  • Hi ilovepumpkin,

    I tried the below code which works fine for me. I m using Sahi-2011-07-19 version.
    <browser>
    function testReadFile(){
        var $files=new Array();
        for(var $i=0; $i<10; $i++) {
            var $content=_readFile("C:/sahi-2011-07-19/config/sahi.properties");
            $files.push($content);
            _log($i, "CUSTOM");
        }
        return $files;
    }
    </browser>
    
    var $files1=new Array();
    _set($files1,testReadFile());
    _log($files1.toString(), "CUSTOM1");
    

    Here the file sahi.properties is 6KB . The above script does not throw "[auto]" in the logs window.

    Regards
    Sumitra
  • narayannarayan Administrators
    Hi,

    Explanation of [auto]

    Before executing a step, Sahi waits for page loads, AJAX etc. When all activity has subsided, Sahi does this:
    1) On the browser, mark a step as "inprogress" in the proxy.
    2) Execute the step on the browser
    3) Once the step is executed, let the proxy know that the step has finished, and can move to the next step.

    Sometimes, due to the way some browsers behave, the 3rd step may be missed. (This happens for older browsers which stop executing javascript if the page was navigated away from due to link click or form submit) Now if the 3rd step did not execute, Sahi may not know that the step has completed successfully. In which case it will keep retrying the same step and eventually fail. (For example, if you click on login button on a page, and the try to click login again, the second one would fail because you would have already moved to a new page).

    To prevent the above behaviour, Sahi automatically marks a step as finished if it does not get an success or error within a defined time limit. This is marked as [auto].

    In your script, you should not be reading the files via browser tags. Rather use something like this:
    function testReadFile(){
        var files=new Array();
        for(var i=0; i<100; i++) {
            var content=_readFile("/tmp/msgs/RAS.properties");
            files.push(content);
        }
        return files;
    }
    
    var $files=testReadFile();
    

    Regards,
    Narayan
  • Hi Sumitra,

    Your loop times is not big enough. Please try the code below again -- I change the loop times from 10 to 100.
    =====================
    <browser>
    function testReadFile(){
    var $files=new Array();
    for(var $i=0; $i<100; $i++) {
    var $content=_readFile("C:/sahi-2011-07-19/config/sahi.properties");
    $files.push($content);
    _log($i, "CUSTOM");
    }
    return $files;
    }
    </browser>

    var $files1=new Array();
    _set($files1,testReadFile());
    _log($files1.toString(), "CUSTOM1");
  • Hi narayan,

    Thanks for your explanation to "[auto]". Now I know what "[auto]" is although I still don't understand why I see it when using readFile functions winthin browser tags.

    Regarding your suggestion to move the readFile functions out from the browser tags, I have one question -- since readFile functions works within browser tags but only fail when it is executed for too many times, why must I use it out of the browser tags? And another reason why I want to use it within browser tags is because I am testing a dojo application and I need call some dojo functions like dojo.query(). If I put the functions out of the browser tags, I have put a local copy of dojo library so to be convenient I write all my functions within browser tags now. If I have to invoke readFile functions outside of browser tags, I will have to redesign my scripts.

    So, could you please let me know:
    1) Why I should not use readFile within browser tags?
    2) Why did I see "[auto]" when invoking readFile functions for lots of times?
    3) Is this case a defect or not? Is there any workaround?

    Really appreciate for your help!
  • Hi Sumitra & Narayan, just let you know that I changed my script so there are no so many calls of readFiles now, therefore, this error is gone. So solving this issue seems not so urgent to me. Thanks.
Sign In or Register to comment.