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.

could't work when index more than 100

beesmanbeesman Members
edited November -1 in Sahi - Open Source
a table like

<td>checkbox radio label<td>
<td>checkbox radio label<td>
<td>checkbox radio label<td>
...........
<td>checkbox radio label<td>
    var $childNodes = _tableHeader("Genre").nextSibling.childNodes;
    var $labelIndex;
    var $radioIndex;
    _debug($childNodes.length);
    for(var $i = 0; _condition($i<$childNodes.length-5); $i = $i + 5){
        $labelIndex = $i + 3;
        _debug($labelIndex);
        if(_condition($childNodes[$labelIndex] != undefined)){
            if(_condition($childNodes[$labelIndex].nodeType == 3)){
                if(_condition($childNodes[$labelIndex].nodeValue.indexOf("Auto") >=0)){//label
                    _check($childNodes[$i]); //checkbox
                    $radioIndex = $i + 2;
                    _click($childNodes[$radioIndex]); //radio
                }
            }else{
                _debug("nodeType:" + $childNodes[$labelIndex].nodeType);
            }
        }else{
            _debug("undefined");
        }
    }



console

Debug: 134
Debug: 3
Debug: 8
Debug: 13
Debug: 18
Debug: 23
Debug: 28
Debug: 33
Debug: 38
Debug: 43
Debug: 48
Debug: 53
Debug: 58
Debug: 63
Debug: 68
Debug: 73
Debug: 78
Debug: 83
Debug: 88
Debug: 93
Debug: 98
Debug: 103
Debug: undefined
Debug: 108
Debug: undefined
Debug: 113
Debug: undefined
Debug: 118
Debug: undefined
Debug: 123
Debug: undefined
Debug: 128
Debug: undefined


when index more than 100 couldn't find the object



and i tried the following code in sahi controller:

_debug("from sahi controller:" + _tableHeader("Genre").nextSibling.childNodes[103].nodeName)

console
Debug: from sahi controller:#text

Comments

  • narayannarayan Administrators
    Hi Beesman,

    Sahi creates Stub objects for most normal javascript DOM expressions.

    For example, document.form is actually a Stub in Sahi. When it is evaled on the browser it becomes the correct object. If you take the case of

    document.forms[0].elements[13], each of these has to resolve to a Stub. By default Sahi creates stubs for elements upto index 99. If you want more than that, you can modify it this way:

    1) Open sahi/htdocs/spr/lib.js

    2) Search for
    for (var i=0; i<100; i++){
        Stub.prototype.__defineGetter__(""+i, indexBinder(i));
    }
    

    and replace it with

    for (var i=0; i<300; i++){
    Stub.prototype.__defineGetter__(""+i, indexBinder(i));
    }

    3) Restart Sahi and you should be able to access index more than 100 (upto 300).

    Regards,
    Narayan
  • hi narayan

    i replace 100 to 300 and it works fine
    Thanks for your rapid response
This discussion has been closed.