Forum Discussion

DCat1223's avatar
DCat1223
Frequent Contributor
9 years ago

Add "Contains" and "Does Not Contain" conditions to If...Then Statement in Keyword testing

Hey Smartbear team...

 

I'm pretty new to TestComplete but love it's ease of use and the community forum.

 

In the Keyword Test, I think it would be useful to add "Contains" and "Does Not Contain" to the available Condition dropdown selection for If...Then Statements.  There have been several instances where I would have liked to use this. 

 

Thanks for listening!

  • cunderw's avatar
    cunderw
    Community Hero

    Just use a compare properties operation using cmpContains, and then and if check on last operation result. Does exactly what you need it to. 

  • DCat1223's avatar
    DCat1223
    Frequent Contributor

    Hi cunderw.  Thank you for the response.  Please excuse my ignorance, but I'm not sure what cmpContains is.  Is this a feature of the Keyword test or a coded solution?  I'm not a developer, so I'm pretty much code illiterate. Thank you again.   

  • DCat1223's avatar
    DCat1223
    Frequent Contributor

    Thank you, cunderw.  I got it now.  I see how this will do what I want. 

     

    I'm hoping you can help shed some light on how I am using this.  I am trying to have a "or" in my Value but failing miserably. 

     

    What I am trying to do is look at a specific value on a spreadsheet (Dental Children) to see if the Value = "add dependent" OR "add one dependent"exists and based on that do a specific thing.  Here is what I have:

    Property = ProjectSuite.Variables.EmpData("Dental Children")

    Condition = cmpEqual

    Value = "add dependent" or "add one dependent"

    Case Sensitive = 0 (no?)

     

    I'm pretty sure the problem is syntax related in the Value field. 

     

    I've also tried making it a code expression:

    ProjectSuite.Variables.EmpData.Value("Dental Children") == "add dependent" || ProjectSuite.Variables.EmpData.Value("Dental Children") == "add one dependent" 

    but that also fails.

     

    Any thoughts on how to best approach this?

  • DCat1223's avatar
    DCat1223
    Frequent Contributor

    I just figured it out.  I used the cmpInCondition and seperated the values with a ",". 

     

    Thank you again #cunderw for pointing me in the right direction!