cancel
Showing results for 
Search instead for 
Did you mean: 

Can I use variable in FindObject operation (Keyword Test)

SOLVED
mikileung
Occasional Contributor

Can I use variable in FindObject operation (Keyword Test)

Hi, 

 

I am writing a keyword test to find an object using "find object" with the criteria of contentText = "Manual entry, manual allocation"

 

However, I would like to change it to a variable, so that I can make it data driven. Is it possible? 

 

If not possible for keyword test, can I do that with a simple script? 

 

Thanks 

 

mikileung_1-1612540665590.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
sonya_m
Community Manager

Re: Can I use variable in FindObject operation (Keyword Test)

@mikileung This KDT operation is a keyword test analog to searching for an object with the Find method and then calling a method or property of the found object. (https://support.smartbear.com/testcomplete/docs/keyword-testing/reference/test-actions/find-object.h...)
So, here are two parts: 1. when you are selecting the property and the value that are used to Find the object and 2. when you are calling the method or property of the object, doing something with the found object - e.g. click on it or changing the text.


As far as I know this part - the operation is a keyword test analogue to searching for an object with the Find method - can't be parameterized (the one on your screenshot). The property will be the same that you choose.

 

But this one - then calling a method or property of the found object - you can parameterize using KDT - instead of value in some cases you can use variable (e.g. for the SetText() method - see the screenshot)

 

image (16).png

 


Alternatively, you can do it from script

 

 

function Test1()
{
  //JavaScript
  //Contents of the edit control, as text string.
  var PropNames, PropValues;
  PropNames = new Array("wText");
  PropValues = new Array("test");
  Aliases.notepad.Find(PropNames, PropValues, 1000, true).wText = "test1";
}

 

 

Try using this function and adding a loop and using PropValues not like an array, but rather a separate value and change it from Excel.
An article for reference: https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/find-m... 


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

2 REPLIES 2
sonya_m
Community Manager

Re: Can I use variable in FindObject operation (Keyword Test)

Thanks for the question @mikileung !

 

@Marsha_R @AlexKaras @Wamboo , could you take a look? Thank you!🙂


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
sonya_m
Community Manager

Re: Can I use variable in FindObject operation (Keyword Test)

@mikileung This KDT operation is a keyword test analog to searching for an object with the Find method and then calling a method or property of the found object. (https://support.smartbear.com/testcomplete/docs/keyword-testing/reference/test-actions/find-object.h...)
So, here are two parts: 1. when you are selecting the property and the value that are used to Find the object and 2. when you are calling the method or property of the object, doing something with the found object - e.g. click on it or changing the text.


As far as I know this part - the operation is a keyword test analogue to searching for an object with the Find method - can't be parameterized (the one on your screenshot). The property will be the same that you choose.

 

But this one - then calling a method or property of the found object - you can parameterize using KDT - instead of value in some cases you can use variable (e.g. for the SetText() method - see the screenshot)

 

image (16).png

 


Alternatively, you can do it from script

 

 

function Test1()
{
  //JavaScript
  //Contents of the edit control, as text string.
  var PropNames, PropValues;
  PropNames = new Array("wText");
  PropValues = new Array("test");
  Aliases.notepad.Find(PropNames, PropValues, 1000, true).wText = "test1";
}

 

 

Try using this function and adding a loop and using PropValues not like an array, but rather a separate value and change it from Excel.
An article for reference: https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/find-m... 


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors