Forum Discussion

er_amitgupta198's avatar
er_amitgupta198
Occasional Contributor
11 years ago
Solved

GridList Checkbox

Dear All

I am B.E. Student and also try to learn test complete tool as better way .
I am facing some problem to click on Check box in given Grid list .If I found many check box in particular grid list for window or web application but i am unable to fetch property value of individual check box for doing some click operation.

During recording , I am not getting any property value or hierarchy of check box in name mapping or object browser window .So I have used some method as wstate, item(row,column) for performing some click operation But i am failed.

I don't believe in coordinate system if you put some coordinate in click method then some time its work but this is not correct solution Because some time script is failed .

So please share some good idea or solution for clicking check box in grid list if we are unable to fetch object property of check box..

please help

Thanks for giving some valuable time

  • Dear,



    Try below code, it  may help you to find and Select check boxes



    Sub Test


    Set CheckBoxs = Sys.Browser("iexplore").Page("your URL").FindChild("ObjectType", "Checkbox", 300)



    For each checkbox in CheckBoxs



    checkbox.Click



    Next



    End Sub


10 Replies

  • Ravik's avatar
    Ravik
    Super Contributor
    Dear,



    Try below code, it  may help you to find and Select check boxes



    Sub Test


    Set CheckBoxs = Sys.Browser("iexplore").Page("your URL").FindChild("ObjectType", "Checkbox", 300)



    For each checkbox in CheckBoxs



    checkbox.Click



    Next



    End Sub


  • Our application had a checkbox right in the middle of a cell, and I had to figure out how to click not just the cell, but that point inside a cell. 

    If you're using Java, this code might help. Call the routine, and pass in the numbers.

    This assumes twips conversion is needed.

    And as always, if anyone can suggest a better method, I am always looking for improvements. =)



    // function to click the middle of a cell, where a checkbox may reside


    function MiddleCheckClick(ColumnNumber, RowNumber)


    {

    // "Grid" should be the mapped name of your object, down to the flex grid.

    var Grid = Aliases.yourObjectName.yourObjectsFlexgrid



    // Calculate X and Y coordinates relative to the cell.

    // Assumes cell measurements in twips. Tweak numbers if needed.


    var HalfColumnWidth = Grid.ColWidth(ColumnNumber)/30;


    var HalfRowHeight = Grid.RowHeight(RowNumber)/30;


    var XCoordinate = (Grid.ColPos(ColumnNumber)/ 15) + HalfColumnWidth;


    var YCoordinate = (Grid.RowPos(RowNumber)/ 15) + HalfRowHeight;




    // Click, baby, click! 


    Grid.Click(XCoordinate, YCoordinate);


    }

  • er_amitgupta198's avatar
    er_amitgupta198
    Occasional Contributor
    Hi Ravi 



    Thanks For giving valuable time .



    But This solution will never work because I told you that Testcomplete is not able to fetch object property of check box by using object spy or recording.



    After using this code it is not going to inside the for checkbox  loop and also throwing error as "object does not support this property method.






    End Sub

     

    Can you provide other some solution 



  • er_amitgupta198's avatar
    er_amitgupta198
    Occasional Contributor
    Hi Kirk B



    T
    hanks For Giving Valuable Time 



    But ColWidth , RowHeight , ColPos and RowPos Method is not found by testcomplete after using gridlist property.



    Only get_width,getmaxcolumnwidth ,get_rowheaderwidth and set_width are available for gridlist .



    I have used your shared code by using old or new method but it is not working properly .



    So please share other solution if you find it
  • er_amitgupta198's avatar
    er_amitgupta198
    Occasional Contributor
    Hi Viper 



    Thanks For giving valuable time .



    But This shared code(ClickCheckboxGridColumn) is not working properly becasue During Execution of same code , TestCompleted is unable to find view index.So script is failed.



    If you have another solution please let me know
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Amit,


     


    To help us understand what is going on on your computer, let us know more about your control and environment:


    1. What is the value of the control's WndClass property (you can check it using the Object Browser)? If the control is a .NET control, please tell me the value of its ClrFullClassName property.


    2. What is the name of the component used to implement the control?


    3. What language and IDE were used to create the application?


    4. What is the control vendor and version?


     

  • The XPath and CSS selectors worked fine for me to solve very similar task.



    Please see JScript example below:



    // Describe XPath locator

    var checkbox_locator = "//td[text()='Some text']/following-sibling::td[7]/input"



    // Use described locator to find needed element

    var checkbox =  page.FindChildByXPath(checkbox_locator);



    // Click on the needed element.

    checkbox.Click();



    You can google xpath or css selectors to find out how they work.

























  • amit gupta

     


    Hi Viper 



    Thanks For giving valuable time .



    But This shared code(ClickCheckboxGridColumn) is not working properly becasue During Execution of same code , TestCompleted is unable to find view index.So script is failed.



    If you have another solution please let me know


    You may want to try different view index or ask your development dept. to see which views they are using. They may use many views as well. As long as you can spy the grid object, the rest should be easy. My grid control is TcxGridSite. 



    To find out why you cannot spy the objects, we may need to go back to Tanya Gorbunova's questions. 
  • Sorry, just went through my code again and I used TRScxGrid, not TcxGridSite. You can manually switch your control to TRScxGrid for testing purpose (under Name Mapping tree).