Forum Discussion

rushikesh's avatar
rushikesh
Contributor
6 years ago
Solved

When a checkbox is checked/unchecked in Test Complete it logs error

I am using below code to check/uncheck a checkbox. The checkbox in application is sucessfully checked/unchecked, but i am getting following error in log "The tree node's '[0]' state image was clicked, but the node stayed in the unchecked state."

 

Below is the code 

pmAfxWnd.page32770.pageFeature.TreeViewFeature.wItems.Item(0).Check(cbChecked)

 

Same is observed when uncheck the checkbox

 

Any help is appricated.

  • Hi rushikesh,

     

    I assume the check action is associated with an event handler in your app and the event in question does not fire in your case. In such situations, it's usually a good idea to try to simulate a mouse click or a spacebar keystroke over the object to make sure the action simulated by TestComplete is as close to real-life user interaction as possible.

     

    In your script, you use Check(cbChecked) action. According to this article, this action moves the mouse pointer to the item and set its value. However, TestComplete doesn't click it.

     

    Since you need to trigger the event handler, I recommend that you use just a single action (without wState assignment) to interact with the checkbox. The action can be any of the following:

    ...ClickChecked(false)  
    ...Click() // this assumes the checkbox is not in the needed state
    ...Keys(" ") // this assumes the checkbox is not in the needed state

    Does it help?

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Possibly a timing issue... that the box is not ready to be operated on immediately.  If there's background processing still in progress that would do it.  Could be something with expanding the tree... maybe it needs to be expanded first before you can check the box.

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi rushikesh,

     

    I assume the check action is associated with an event handler in your app and the event in question does not fire in your case. In such situations, it's usually a good idea to try to simulate a mouse click or a spacebar keystroke over the object to make sure the action simulated by TestComplete is as close to real-life user interaction as possible.

     

    In your script, you use Check(cbChecked) action. According to this article, this action moves the mouse pointer to the item and set its value. However, TestComplete doesn't click it.

     

    Since you need to trigger the event handler, I recommend that you use just a single action (without wState assignment) to interact with the checkbox. The action can be any of the following:

    ...ClickChecked(false)  
    ...Click() // this assumes the checkbox is not in the needed state
    ...Keys(" ") // this assumes the checkbox is not in the needed state

    Does it help?