Forum Discussion

dswanstrom's avatar
dswanstrom
Regular Visitor
7 years ago

I'm trying to create a conditional statement in VBScript for if a box pops up or not.

I'm doing Data driven testing.  On some of my records a box will pop up, but not on all records.  If the box pops up, i need to click a button. If it doesn't, i need to skip that command and move on.

 

I haven't really found anything that is helping me with this, so any suggestions are welcome.

2 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    It will be something like this:

    if (object name of pop up box.enabled) then button.click

     

    Put it in the spot in the test where you would see the pop up if it happens.  If the pop up happens, the click will happen.  If it doesn't pop up, then the click won't happen.  Either way you go on to the next line.

    • SanderK's avatar
      SanderK
      Occasional Contributor

      That method will only work if the object is disabled. If it isn't there altogether your example will try to read the Enabled property of a non-existing object resulting in an error.

      What you want to do is first check if the object exists using the FindChild or Wait(Alias)Child method before attempting to use it.

       

      https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/waitchild-method.html

       

      Your code will be like this:

       

      if(ParentObject.WaitAliasChild("ObjectName", 1000).Exists) { DoStuff(); }

       

      This will always work since the method will return a dummy object with an Exists = false property if the object you're searching is not found.