Forum Discussion

MMZ's avatar
MMZ
Occasional Contributor
22 days ago
Solved

If statement

I need help about if...then statement in keyword testing. I'va an form where an column contains two LOVs i.e., Yes & No. When user select Yes more additional fields are appearing and if user select No it remains normal. I'm confused how to handle such scenario via if...then statement.

  • Hello,

    From your previous reply,

    Condition do you need to verify:

    If a user selects "Yes," an additional two to three dependent fields appear below it. If "No" is selected, the form proceeds normally without displaying these additional fields.

    I think an 'If Object' after TC clicks Yes would work.  The' If Then' block may not be what you want?

     

6 Replies

  • scot1967's avatar
    scot1967
    Icon for Champion Level 3 rankChampion Level 3

    Hello MMZain,

    I can't answer your question precisely without knowing what you want to test.  A code snip or screen grab would help.  For now I can share this link...

    https://support.smartbear.com/testcomplete/docs/keyword-testing/reference/statements/if-then.html 

    Get back to us with the behavior you are trying to test if you are still stuck.  Pass me a like 👍🏼or set this as resolved if I gave you the info to answer your question.

    Have a super day / evening!

    • MMZ's avatar
      MMZ
      Occasional Contributor

      I am currently conducting system testing for a web-based application. During this process, I’ve encountered a dynamic form scenario where the visibility of certain fields depends on user input in another fields.

      Specifically, there is a field called "UOB" with a drop-down list containing "Yes" and "No." If a user selects "Yes," an additional two to three dependent fields appear below it. If "No" is selected, the form proceeds normally without displaying these additional fields.

      I am using TestComplete for keyword testing and am unsure how to properly handle this conditional field behavior. Could you advise on the best approach or relevant TestComplete keywords to manage such dynamic UI changes.

      • Hassan_Ballan's avatar
        Hassan_Ballan
        Icon for Champion Level 3 rankChampion Level 3

        For this scenario, don’t branch on the dropdown value itself—branch on what appears in the UI after the selection.

        Recommended approach:

        1. Select Yes or No from the UOB dropdown
        2. Wait for the page to update (WaitProperty or short Delay)
        3. Use If Object or If…Then with a Property Checkpoint

         

        Example logic:

        • After selecting Yes
          → If Object (DependentField.Exists = True)
          → Fill the additional fields
        • After selecting No
          → Verify the dependent fields do not exist and continue

         

        Important note:
        When checking that an object exist, TestComplete will wait up to its default timeout (typically 10 seconds) before continuing. To avoid unnecessary delays, it’s a good practice to lower the check operation timeout to 1 second.

        Best keywords to use:

        • If Object
        • Property Checkpoint (Exists or Visible)
        • WaitProperty

         

        This is the most reliable way to handle dynamic fields in TestComplete keyword tests.

        🤖 AI-assisted response
        👍 Found it helpful? Click Like
        âś… Issue resolved? Click Mark as Solution

         

  • scot1967's avatar
    scot1967
    Icon for Champion Level 3 rankChampion Level 3

    Hello,

    From your previous reply,

    Condition do you need to verify:

    If a user selects "Yes," an additional two to three dependent fields appear below it. If "No" is selected, the form proceeds normally without displaying these additional fields.

    I think an 'If Object' after TC clicks Yes would work.  The' If Then' block may not be what you want?