Forum Discussion

G-wagon's avatar
G-wagon
Regular Contributor
7 years ago
Solved

Loop Test

Hi all

 

I intend to design a loop test where my keyword test will look at the 'Next' button on the screen and its property. If the button is disabled it will select number 2 from one of the drop down list, if still disabled then it must select number 3 from the dropdown list and so on. So this loop must continue to select the next available number until the 'Next' button is enabled.

I am bit struggling to come up with a keyword test solution which will continue to select next available number from the list until the the button in question is enabled. Any help around this will be much appreciated.

 

Thanks

G

9 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    I would do something like this... pseudo code, you understand, but translate to a keyword test.

     

    set variable(boolean) HasNext = Aliases.MyApp.MyForm.buttonNext.Enabled
    set variable(integer) rowtoclick = 0
    while HasNext not equal to true
       Click row(rowtoclick)
    set variable rowtoclick = rowtoclick + 1; set variable(boolean) HasNext = Aliases.MyApp.MyForm.buttonNext.Enabled

    Essentially, check the enabled property of the button and, with a while loop, click on each row, incrementing the row number each time.

     

    Hope this helps give you direction.

    • G-wagon's avatar
      G-wagon
      Regular Contributor

      tristaanogre wrote:

      I would do something like this... pseudo code, you understand, but translate to a keyword test.

       

      set variable(boolean) HasNext = Aliases.MyApp.MyForm.buttonNext.Enabled
      set variable(integer) rowtoclick = 0
      while HasNext not equal to true
         Click row(rowtoclick)
      set variable rowtoclick = rowtoclick + 1; set variable(boolean) HasNext = Aliases.MyApp.MyForm.buttonNext.Enabled

      Essentially, check the enabled property of the button and, with a while loop, click on each row, incrementing the row number each time.

       

      Hope this helps give you direction.


      So here's what I did:

       

       

      However the problem now is that it does not drop out of the loop as soon as the button is enabled and continues to iterate through numbers 1 to 12

       

      In the above scenario the button is enabled when list box item 02 is selected however the test doesn't drop out of the loop at this stage and continues to iterate through all the remaining numbers. I dont want it to iterate through the remaining numbers if the button is enabled at early stages.

       

      Thanks

      G

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        I think what needs to happen is that you need to refresh the value being used in the while loop... that's why I reassigned the variable "HasNext" inside the loop, to make sure we get the latest version of it.  TestComplet caches some information so there needs to be some sort of refresh of the cache.

        Alternatively, in the "while" loop, in your evaluation of the Enabled property, instead of simply using "Object Property" use a code expression and utilize the WaitAliasChild method to "search" for the buttonNext which does a refresh of the object in memory.