cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Highlighted
Occasional Contributor

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();

      }

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Occasional Contributor

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

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)); 

 

View solution in original post

5 REPLIES 5
Highlighted
Community Hero

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

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();

      }

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Occasional Contributor

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

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.

 

Highlighted
Occasional Contributor

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

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.

 

Highlighted
Community Hero

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

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();

      }

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Occasional Contributor

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

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)); 

 

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!

Retrieve Data from a Web Page

Participate!
Top Kudoed Authors