Forum Discussion

cdeng's avatar
cdeng
Occasional Contributor
11 years ago

Issues On Working with the table cell for Java Application Web Testing


Hello,



I have Issues on working with table Cell.  I know there are some postings about the table cell but I found those posting are not my answers.



I came across with several problems on it.  


(1) I am able to locate the cell but not able to click.


(2) On object spy I was able to see the className property but the className became empty during execution on the TC - thus showing on the debug, object evaluation, the className is empty but I can see it on with object spy.

 


I am using TC 10.40.2015.7 and I have a table in screenshot 1(before click), screeshot(2,3,4) are by different click actions and I want to verify.  I need to check the state of the columes of Yes and the No. Before click and I found the only property change before click and after click is the className. Before click, both of the Yes/No has the the property for the className: selectButton rosYN and the property for the className: selectButton rosYN selected.


 





 



function verifyChildSystem() {


 


    var page =  Sys.Browser(startstop.readBroswerFromIni()).Page("*");


    var tblChildSystem = page.Find('idStr','childsystem',100);


    if (tblChildSystem.Exists)   {


      //Goes through the rows and cells of the table


      for (var i = 2; i < tblChildSystem.rows.length; i++) {


        Log.AppendFolder("Row " + i);


        for (var j = 0; j < tblChildSystem.rows.item(i).cells.length; j++)


        //j = 1/2 (yes/no), j = 4/5 (yes/no), j = 7/8 (yes/no)


          if (aqString.GetLength((tblChildSystem.rows.item(i).cells.item(j).innerText))>1){ 


            Log.Message("Cell " + j + ": " + tblChildSystem.rows.item(i).cells.item(j).innerText);


            var btn_InnerText = tblChildSystem.rows.item(i).cells.item(j).innerText;


            var btn_IdStr = tblChildSystem.rows.item(i).cells.item(j).idStr;


            //There is not any Yes/No selected


            //            if (j == 1 || j ==2 || j==4 || j ==5 || j== 7 || j==8)


            if (j == 1 || j==4 || j== 7) {


                var btnItem = tblChildSystem.rows.item(i).cells.item(j);


                var btnItemStr = tblChildSystem.rows.item(i).cells.item(j).idStr;


                bResult=aqObject.CheckProperty(btnItem, "className", cmpEqual, 'selectButton rosYN');


            }


            else if (j ==2 || j ==5 || j==8) {


                var btnItem = tblChildSystem.rows.item(i).cells.item(j);


                btnItem = btnItem.Find('ContentText','No',100);


                bResult=aqObject.CheckProperty(btnItem, "className", cmpEqual, 'selectButton rosYN');


            }


          }


      }    


    }


}


 


 


function markShildSystem(iconBS,selectYesNo) {


 


    var page =  Sys.Browser(startstop.readBroswerFromIni()).Page("*");


    var tblChildSystem = page.Find('ObjectIdentifier','childsystem',100);


    var iconInnerText;


 


    if (tblChildSystem.Exists)   {


      //Goes through the rows and cells of the table


      for (var i = 2; i < tblChildSystem.rows.length; i++) {


        for (var j = 0; j < tblChildSystem.rows.item(i).cells.length; j++) {


            if (aqString.GetLength((tblChildSystem.rows.item(i).cells.item(j).innerText))>1){


                Log.Message("Cell " + j + ": " + tblChildSystem.rows.item(i).cells.item(j).innerText);


                iconInnerText = tblChildSystem.rows.item(i).cells.item(j).innerText;


                if (aqString.StrMatches(iconBS, iconInnerText)) {  //item found


                    if (selectYesNo == 'Yes') {


                     var iconYes = tblChildSystem.rows.item(i).cells.item(j+1) ;


                     iconYes.Click();


 


                    }


                    else {    //No


                      var clickNo=tblChildSystem.rows.item(i).cells.item(j+2);


                      clickNO.Click();


 


                    }  


                    //if the ChildSystem found then exit both of the loops


                    j = tblChildSystem.rows.item(i).cells.length + 1;


                    i = tblChildSystem.rows.length + 1;


                    break;


                }


            }


        }


      }


    }


 


}


 


 


function unittest(){  


    verifyChildSystem(); 


    markShildSystem('Chills','Yes');


 


}





3 Replies

  • cdeng's avatar
    cdeng
    Occasional Contributor
    Hear is my solution to resolved my issue.  Thanks!




    //Author: Carol D.


    //Date: November 2014


    //Purpose: Verify the ROS Child System UI


    //PM Reports > Custom Reports, Create Template, View Report, Cancel 


     


    function verifyChildSystem() {


     


        var page =  Sys.Browser("Firefox").Page("*");


     


        var tblChildSystem = page.Find('idStr','childsystem',100);


     


        if (tblChildSystem.Exists)   {


     


        


          //Goes through the rows and cells of the table


          for (var i = 2; i < tblChildSystem.rows.length; i++) {


     


            for (var j = 0; j < tblChildSystem.rows.item(i).cells.length; j++)


     


              if (aqString.GetLength((tblChildSystem.rows.item(i).cells.item(j).innerText))>1){ 


     


                var btn_InnerText = tblChildSystem.rows.item(i).cells.item(j).innerText;


     


                //The default status: there is not any Yes/No selected


                 if (j == 1 || j ==2 || j==4 || j ==5 || j== 7 || j==8){


                    var btn_Name = tblChildSystem.cell(i,j).Panel("*");


                    bResult=aqObject.CheckProperty(btn_Name, "className", cmpEqual, 'selectButton rosYN');


                    


                }


              }


          }    


        }


    }


     


     


    function markShildSystem(iconBS,selectYesNo) {


     


        var page =  Sys.Browser("Firefox").Page("*");


        var tblChildSystem = page.Find('ObjectIdentifier','childsystem',100);


    //        LogAppStructure(tblChildSystem);


        var iconInnerText;


     


        if (tblChildSystem.Exists)   {


          //Goes through the rows and cells of the table


          for (var i = 2; i < tblChildSystem.rows.length; i++) {


            for (var j = 0; j < tblChildSystem.rows.item(i).cells.length; j++) {


                if (aqString.GetLength((tblChildSystem.rows.item(i).cells.item(j).innerText))>1){


                    Log.Message("Cell " + j + ": " + tblChildSystem.rows.item(i).cells.item(j).innerText);


                    iconInnerText = tblChildSystem.rows.item(i).cells.item(j).innerText;


                    if (aqString.StrMatches(iconBS, iconInnerText)) {  //item found


                        if (selectYesNo == 'Yes') {


                            var iconYes = tblChildSystem.cell(i,j+1).Panel('*') ; 


                            iconYes.Click();                        


                            


                            //iconYes.Child(0).Panel("*").Click();


                            bResult=aqObject.CheckProperty(iconYes, "className", cmpEqual, 'selectButton rosYN selected');


                        }


                        else {    //No


                          var iconNo=tblChildSystem.cell(i,j+2).Panel('*') ;


                          iconNo.Click();


                          bResult=aqObject.CheckProperty(iconNo, "className", cmpEqual, 'selectButton rosYN selected');


                        }  


                        //if the ChildSystem found then exit both of the loops


                         


                        j = tblChildSystem.rows.item(i).cells.length + 1;


                        i = tblChildSystem.rows.length + 1;


                        break;


                    }


                }


            }


          }


        }


     


    }


     


    function unittest(){  


     


        verifyChildSystem();


        markShildSystem('Chills','Yes');


        markShildSystem('Fever','No');


     


    }


  • Hi Carol,


     


    As far as I see, you are working with our Support team regarding this issue. Please post here the solution you will find.


     

  • cdeng's avatar
    cdeng
    Occasional Contributor
    Tanya,



    I wish the it can be resolved faster.  Now almost two weeks passed by.



    Carol