Forum Discussion

Morgan's avatar
Morgan
Frequent Contributor
11 years ago

Incrementing an action

I'm trying to create a little script that loops through a dropdown to find the desired value.  Can someone direct me as to an example?  

 

Thanks,

Morgan

6 Replies

  • Morgan's avatar
    Morgan
    Frequent Contributor

     

    Initial code looks as follows....  what's not working is that the [Down] needs to increment each time.  So first time, one down action is needed, second 2, etc...

     

    Thanks!

    Morgan

    ----

     

    repeat                            // If X appears in the list, we select it and continue.
    grdAnalyte.Keys(' ');
    grdAnalyte.Keys('[Down][Enter]');
    Delay(Std_Wait);

    until frmAnalyte.Window('TDBGridInplaceEdit', '', 1).text = 'X';

    • mes6073's avatar
      mes6073
      Contributor

      until frmAnalyte.Window('TDBGridInplaceEdit', '', 1).text = 'X';


      Is this a custom control similar to a Win32 ComboBox? If so, I would think that if you instantiate a variable of that type, then that would expose the item count for the dropdown similar to the method in the TestComplete Working with dropdowns support article:

       

      procedure Main();
      var
      p, w, ComboBox: OleVariant;
      begin
        // Run Notepad
        Win32API.WinExec('notepad.exe', SW_SHOWNORMAL);
        // Obtain a combo box object
        p := Sys.Process('NOTEPAD');
        Sys.Keys('~of');
        w := Sys.Process('NOTEPAD').Window('#32770', 'Font', 1);
        ComboBox := w.Window('ComboBox', '', 5);
        
        // Post the total number of items to the log
        Log.Message('The total number of items:' + aqConvert.IntToStr(ComboBox.wItemCount));
      end;

    • tonydugay's avatar
      tonydugay
      Contributor

      you could put the call to [Down] in a loop and increment the times that loop is executed each time it is called.

       

      in pseudo code:

       

      maxLoop = 0

      repeat                            // If X appears in the list, we select it and continue.
      maxLoop++

      grdAnalyte.Keys(' ');

      for (i=0; i < maxLoop; i++) {
        grdAnalyte.Keys('[Down][Enter]');

      }
      Delay(Std_Wait);

      • Morgan's avatar
        Morgan
        Frequent Contributor

        Hmmm... I think I get what you are saying but I'm having trouble converting it to DelphiScript.  Any ideas? 

        Appreciate the help!

        Morgan