Forum Discussion

chicks's avatar
chicks
Regular Contributor
11 years ago

select box ClickItem working intermittently

I am seeing the log message with the correct index for the selectItem.   No errors or warnings are printed for the log.  About 60% of the time the item in the drop down box does NOT change.   When this occurs I do see that the attempted recovery mechanism is triggered , that is, I do get trying again 7 times, however, the drop down box never changes.   So I have tried various combinations of refresh and delays, but do not see any difference.  It seems as if there were a problem needing a refresh on the GUI object,  then  the   while ( (select.wText != selectItem) would not see the problem as it would still be pointing to the incorrect GUI object.

 

This is happening in both 10.5 TestComplete and TestExecute.....   It just started happening today. 

 

Has anybody seen anything similar? 

 

Thanks.

 

 

function ClickItem_ExactMatch(select, selectItem)
{

.................

 

   if(foundItem) {
    Log.Message("ClickItem index = " + index);
    select.ClickItem(index);
    
    // 3.9.2015   for add paycards,  item is being selected per log (i.e. no error indication)  but not changing - HACK attempted work-around
    var maxTries = 0;
    while ( (select.wText != selectItem) && (maxTries < 7) ) {
        delay(1500);  
        maxTries++;
        Log.Message("trying again!");
        select.Refresh();
        select.ClickItem( select.wItemCount - 1 );  
        select.ClickItem(index);
    
    }  
   }

2 Replies

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor

    Need more of your code to tell what you're doing here exactly but it seems to me you could possibly replace all of that code with just one line:

     

    select.ClickItem(selectItem);

     If this doesn't work, please post the entire ClickItem_ExactMatch function.

    • chicks's avatar
      chicks
      Regular Contributor

      Thanks Ryan!

       

      I had added a wrapper to the click item code to handle the case of the dropdown not being fully populated initially.  In this particular instance, I can probably count on the dropdown always being fully populated.

       

      I replaced my call to the function with your suggested direct call as follows:

       

          myCards_addPayCard_cardType().ClickItem(cardType);
      //    ClickItem_ExactMatch(myCards_addPayCard_cardType(), cardType);
      //    if (myCards_addPayCard_cardType().Exists) {  
      //       ClickItem_ExactMatch(myCards_addPayCard_cardType(), cardType);
      //    }

          if (myCards_addPayCard_cardType().wText != cardType) {
             Log.Error("ERROR: addPayCard_fields() correct card type was NOT selected");
             return false;  
          }

      I got the same error.   In other words,  no error indication or warning for the ClickItem, but yet the card type value in the dropdown did NOT change.

       

      I had added a "context switch" where I go off and work in another browser to check the email was received properly for adding and removing the payment card.  When I comment that code out the problem with the drop down does not occur.  So apparently the "context switch" is causing a problem with the dropdown selection even though I can still determine that I am not on the selected value.....