Forum Discussion

Mk1's avatar
Mk1
Occasional Contributor
7 years ago

When i send keys and add a click inside the Keys it then passes "Undefined"

When i send keys and add a click inside the Keys it then passes "Undefined" plus the correct data to the dropdown

Below is my code, see attached for dropdown layout, even when i separate the function calls, it clicks the dropdown and by the time it gets to the second line the pop up list disappears.

a.Click();

b.Keys(aqString.Trim(tempPathName, aqString.stAll));

b.Keys("[Tab]");

 

  var PathName = eval(genericPath);

  var tempPathName = context1.get(dataName);

  var objNames = objName;

      if(aqString.GetLength(tempPathName) != null) {

          b = PathName.PwcAutoComplete(objNames).TextInput(0);

          a = PathName.PwcAutoComplete(objNames).Button(0);

            if((b.Exists) && (b.Enabled == true)) {

                var fieldContent = getInputValue(b); 

                b.Keys(a.Click() + aqString.Trim(tempPathName, aqString.stAll));

                b.Keys("[Tab]");

                genCheckAlertFormPWC();

            }

      } else {

        Log.Warning("The Supplied data is not valid for the field, please check the data and try again.");

        aqUtils.Beep();

      }

  • Mk1's avatar
    Mk1
    7 years ago

    I found a solution, created a new function to my click that returns an empty string. Works like a charm

     

    Thanks.

     

    function myButtonClick(a)
    {
    a.Click();
    return("");
    }


    b.Keys(myButtonClick(a) + aqString.Trim(tempPathName, aqString.stAll)); 

     

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    You can't send a "Click" method to the Keys command.  Keys takes, as a parameter, a string.  Click doesn't return anything hence the undefined.

     

    What are you attempting to do with that process?  If all you're attempting to do is click on the field and then do a key entry, simply do the following:

      var PathName = eval(genericPath);
    
      var tempPathName = context1.get(dataName);
    
      var objNames = objName;
    
          if(aqString.GetLength(tempPathName) != null) {
    
              b = PathName.PwcAutoComplete(objNames).TextInput(0);
    
              a = PathName.PwcAutoComplete(objNames).Button(0);
    
                if((b.Exists) && (b.Enabled == true)) {
    
                    var fieldContent = getInputValue(b); 
                    
                    a.Click();
    
                    b.Keys(aqString.Trim(tempPathName, aqString.stAll));
    
                    b.Keys("[Tab]");
    
                    genCheckAlertFormPWC();
    
                }
    
          } else {
    
            Log.Warning("The Supplied data is not valid for the field, please check the data and try again.");
    
            aqUtils.Beep();
    
          }
    • Mk1's avatar
      Mk1
      Occasional Contributor

      Thanks for the feedback, I'm trying to click on the field and then do a key entry.

      I tried the suggested solution but after the a.Click(); the script looses focus and the pop-up list would disappear again.

       

    • Mk1's avatar
      Mk1
      Occasional Contributor

      Thanks for the feedback, I'm trying to click on the field and then do a key entry.

      I tried the suggested solution but after the a.Click(); the script looses focus and the pop-up list would disappear again.

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Subtle change... but try this.

          var PathName = eval(genericPath);
        
          var tempPathName = context1.get(dataName);
        
          var objNames = objName;
        
              if(aqString.GetLength(tempPathName) != null) {
        
                  b = PathName.PwcAutoComplete(objNames).TextInput(0);
        
                  a = PathName.PwcAutoComplete(objNames).Button(0);
        
                    if((b.Exists) && (b.Enabled == true)) {
        
                        var fieldContent = getInputValue(b); 
                        
                        b.Click();
        
                        b.Keys(aqString.Trim(tempPathName, aqString.stAll));
        
                        b.Keys("[Tab]");
        
                        genCheckAlertFormPWC();
        
                    }
        
              } else {
        
                Log.Warning("The Supplied data is not valid for the field, please check the data and try again.");
        
                aqUtils.Beep();
        
              }