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.

I am unable to collect/count check boxes from child window.

kplokeshkplokesh Members
edited November -1 in Sahi - Open Source
Hi,

When I am trying to collect/count child window objects it is recognizing parent window check boxes.

I am using the below code,

var $chk_count = _count("_checkbox", "/./", _in(_table("")))
_debug($chk_count)
_debug("Total No. of CheckBoxes: "+ $chk_count.length);

for( var $i=0; $i<$chk_count.length; $i++)
{
_click(_checkbox($chk_count[$i].id));
}

In my application parent window having the following source code.,

<TABLE ID="LLInnerContainer" CLASS="pageBody" STYLE="height: 100%;" CELLSPACING="0" CELLPADDING="0" WIDTH="100%" BORDER="0">
<TR>
<TD VALIGN="TOP" >
<DIV ID="mastheadComponent">
<TABLE ID="titleComponent" WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0" STYLE="background-image: url( /img/project/projectheader.gif ); background-repeat: repeat-x;">
<TR NAME="mastHeadRow" ID="mastHeadRow">
<TD NOWRAP ALIGN="LEFT" VALIGN="MIDDLE"><IMG SRC="/img/project/28project.gif" ALT="Project" ALIGN="TOP" WIDTH="52" HEIGHT="44" BORDER="0"></TD>
<TD NOWRAP VALIGN="MIDDLE" WIDTH="100%">
<DIV ID="headerTitle1">Project Workspace:</DIV>
<DIV ID="headerTitle2">Lokesh Sahi 3 Project</DIV>
</TD>
<TD>
<IMG HEIGHT="31" ALT="" SRC="/img/project/projectheader_divider.gif" WIDTH="2" BORDER="0">
</TD>
<TD ALIGN="MIDDLE" VALIGN="MIDDLE" NOWRAP>
<DIV ID="headerUserName">lokesh.bam</DIV>
<DIV ID="headerCurrentDate">Friday, 12/09/2011</DIV>
</TD>
<TD>
<IMG HEIGHT="31" ALT="" SRC="/img/project/projectheader_divider.gif" WIDTH="2" BORDER="0">
</TD>
<TD NOWRAP ALIGN="RIGHT">
<STYLE TYPE="text/css"> .chickletImage { behavior: url('/img/pngbehavior.htc'); }</STYLE>
<A HREF="http://www.causeway.com"><IMG CLASS="chickletImage" SRC="/img/causeway_chicklet.png" ALIGN="RIGHT" HSPACE="8" ALT="Powered by Causeway Technologies" WIDTH="83" HEIGHT="30" BORDER="0"></A>
</TD>
</TR>
</TABLE>


child window contains the below source code


<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0">
<TR CLASS="browseListHeader">
<TD COLSPAN="2" STYLE="BACKGROUND-REPEAT: repeat-x" BACKGROUND="/img/fon-table-header-blue.gif" CLASS="browseListHeaderFunctions" SCOPE="colgroup" NOWRAP> Action: </TD>
<TD WIDTH="1%" CLASS="cellDivider" STYLE="BACKGROUND-REPEAT: no-repeat" BACKGROUND="/img/table-header-divider.gif"><IMG HEIGHT="19" ALT="" SRC="/img/px.gif" WIDTH="2" BORDER="0"></TD>
<TD STYLE="BACKGROUND-REPEAT: repeat-x" BACKGROUND="/img/fon-table-header-blue.gif" CLASS="browseListHeaderType" SCOPE="colgroup" NOWRAP > <A HREF="" ONCLICK="goToTargetBrowseURL( '/Livelink/Livelink.exe?func=ll&objID=298862&objAction=targetBrowse&sort=subtype&selectScreen=%7B144%2C736%7D&selectLabel=Select&multiSelect=attachIDs&headerLabel=Select&formName=collabdoc&fieldPrefix=AssocDoc' ); return false;">Type</A> </TD>
<TD WIDTH="1%" CLASS="cellDivider" STYLE="BACKGROUND-REPEAT: no-repeat" BACKGROUND="/img/table-header-divider.gif"><IMG HEIGHT="19" ALT="" SRC="/img/px.gif" WIDTH="2" BORDER="0"></TD>
<TD STYLE="BACKGROUND-REPEAT: repeat-x" BACKGROUND="/img/fon-table-header-blue.gif" CLASS="browseListHeaderName" SCOPE="colgroup" NOWRAP> <A HREF="" ONCLICK="goToTargetBrowseURL( '/Livelink/Livelink.exe?func=ll&objID=298862&objAction=targetBrowse&sort=%2Dname&selectScreen=%7B144%2C736%7D&selectLabel=Select&multiSelect=attachIDs&headerLabel=Select&formName=collabdoc&fieldPrefix=AssocDoc' ); return false;">Name</A> <IMG SRC="/img/sort-up.gif" ALT="Ascending Sort" WIDTH="9" HEIGHT="5" BORDER="0"> </TD>
<TD WIDTH="1%" CLASS="cellDivider" STYLE="BACKGROUND-REPEAT: no-repeat" BACKGROUND="/img/table-header-divider.gif"><IMG HEIGHT="19" ALT="" SRC="/img/px.gif" WIDTH="2" BORDER="0"></TD>
<TD STYLE="BACKGROUND-REPEAT: repeat-x" BACKGROUND="/img/fon-table-header-blue.gif" CLASS="browseListHeaderSize" SCOPE="colgroup" NOWRAP> <A HREF="" ONCLICK="goToTargetBrowseURL( '/Livelink/Livelink.exe?func=ll&objID=298862&objAction=targetBrowse&sort=size&selectScreen=%7B144%2C736%7D&selectLabel=Select&multiSelect=attachIDs&headerLabel=Select&formName=collabdoc&fieldPrefix=AssocDoc' ); return false;">Size</A> </TD>
</TR>
<TR CLASS="horizontalCellDivider"><TD CLASS="featuredItemBG" COLSPAN="100"><IMG HEIGHT="1" ALT="" SRC="/img/px.gif" WIDTH="2" BORDER="0"></TD></TR>
<TR CLASS="horizontalCellDivider"><TD CLASS="browseRowDivider" COLSPAN="100"><IMG HEIGHT="1" ALT="" SRC="/img/px.gif" WIDTH="1" BORDER="0"></TD></TR>
<TR CLASS="browseRow1">
<TD CLASS="browseItemActions" NOWRAP> 
<LABEL FOR="Node298746"></LABEL>
<INPUT TYPE="CHECKBOX" ID="Node298746" NAME="Node298746" TITLE="Select >" ONCLICK="modifyNodeSelection( 298746, 1, this )" VALUE="CheckBox">
Select >
 
</TD>
<TD NOWRAP> 
<A HREF="" ONCLICK="getVersionURL( 'livelink.exe?func=olink.SelectVersion&nodeID=298746&prefix=AssocDoc&formname=collabdoc' ); return false;">Versions</A>
</TD>
<TD><IMG SRC="/img/px.gif" ALT="" HEIGHT="24" WIDTH="2" BORDER="0"></TD>
<TD VALIGN="center" CLASS="browseItemType" NOWRAP><IMG SRC="/img/8space.gif" WIDTH="8" HEIGHT="8" BORDER="0" ALT=""><IMG SRC="/img/webdoc/appword.gif" WIDTH="16" HEIGHT="16" BORDER="0" ALT="Document"></TD>
<TD><IMG SRC="/img/px.gif" ALT="" HEIGHT="24" WIDTH="2" BORDER="0"></TD>
<TD CLASS="browseItemName" SCOPE="rowgroup">
 999.docx 
</TD>
<TD><IMG SRC="/img/px.gif" ALT="" HEIGHT="24" WIDTH="2" BORDER="0"></TD>
<TD CLASS="browseItemSize" NOWRAP>13 KB </TD>
</TR>
<TR CLASS="horizontalCellDivider"><TD CLASS="browseRowDivider" COLSPAN="100"><IMG HEIGHT="1" ALT="" SRC="/img/px.gif" WIDTH="1" BORDER="0"></TD></TR>
<TR CLASS="browseRow2">

the child window does not contain table name I think due to this reason it's taking parent window but how can I count/collect child window check boxes could you please help on this ?

Thanks,
Lokesh.

Comments

  • Hi Lokesh,

    I see that you are using _count. Please use _collect if you wish to iterate over the elements and click on each of them.
    This code collects all checkboxes present in the first table on the child window.
    var $chkBoxes = new Array();
    $chkBoxes = _popup("identifier")._collect("_checkbox", "/.*/", _in(_table(0)));
    _debug($chkBoxes)
    _debug("Total No. of CheckBoxes: "+ $chkBoxes.length);
    
    for( var $i=0; $i<$chkBoxes.length; $i++)
    {
       _check($chkBoxes[$i]);
    }
    

    Regards,
    dkulkarni
  • Hi

    I have used the following code but it's giving ERROR
    TypeError: Cannot call method "_collect" of undefined

    var $chkBoxes = new Array();
    $chkBoxes = _popup("SelectWidget")._collect("_checkbox", "/./", _in(_table(9)));
    _debug($chkBoxes)
    _debug("Total No. of CheckBoxes: "+ $chkBoxes.length);

    for( var $i=0; $i<$chkBoxes.length; $i++)
    {
    _check($chkBoxes[$i]);
    }
  • Hi Lokesh,

    What version of Sahi are you using?

    _collect() API is available from Sahi V3.5, 2011-03-14.

    Regards
    Sumitra
  • Hi,

    I am using Sahi Pro 3.6 yes _collect() API is available but when I am using the following the code

    var $chkBoxes = new Array();
    $chkBoxes = _popup("SelectWidget")._collect("_checkbox", "/./", _in(_table(9)));
    _debug($chkBoxes)
    _debug("Total No. of CheckBoxes: "+ $chkBoxes.length);
    for( var $i=0; $i<$chkBoxes.length; $i++)
    {
    _check($chkBoxes[$i]);
    }

    I am getting TypeError: Cannot call method "_collect" of undefined

    Can you look on this ?

    Thanks,
    Lokesh
  • Hi,

    Can any one reply for my issue, I was stuck up with this issue.

    Thanks,
    Lokesh.
  • Hello Lokesh,

    Could you run collect.sah in <SAHI-HOME>/userdata/scripts/demo/ folder using the start URL http://sahi.co.in/demo/ and check if it runs successfully?

    Regards,
    dkulkarni
  • Hi,

    It is running successfully.

    Thx,
    Lokesh.
  • Hi Lokesh,

    The earlier script is incorrect. My apologies.

    Please use this.
    var $chkBoxes = new Array();
    _selectWindow("SelectWidget");
    $chkBoxes = _collect("_checkbox", "/.*/", _in(_table(9)));
    _debug("Total No. of CheckBoxes: "+ $chkBoxes.length);
    for( var $i=0; $i<$chkBoxes.length; $i++)
    {
       _check($chkBoxes[$i]);
    }
    

    Regards,
    dkulkarni
  • Hi,

    Many thanks, now it's working.

    Lokesh.
This discussion has been closed.