Ask a Question

Find an object with a variable

llcotton
Occasional Contributor

Find an object with a variable

Do you ever need to find a row or cell in a table?

 

Findobject could do it for you but you have to hardcode a value from a property such as contentText. I have found a way to add a variable to find object.

 

  1. Make a new keyword test
  2. Perform find object and add a value for content text
  3. Right click on the keyword test to create a script. This is an easy way to get the mapping correct.
  4. In the script add an input variable to the function call
  5. Change the hardcoded value in quotes to the new variable
  6. Now drag the script into a keyword test and add the input value.

 

You can now find any value in the Table.

 

function Find_an_object(passed_in_value) {
//Simulates a left-button single click in a window or control as specified (relative position, shift keys).
var PropNames, PropValues, passed_in_value, row_num;
PropNames = new Array("ContentText");
PropValues = new Array(passed_in_value);
Aliases.xxx.Find(PropNames, PropValues, 1000, true).Click();
row_num = Aliases.xxx.Find(PropNames, PropValues, 1000, true).RowIndex;
return (row_num)
}

Happy Testing

Lori

1 REPLY 1
sonya_m
SmartBear Alumni (Retired)

Great advice! Thank you for sharing Lori.


Sonya Mihaljova
Community and Education Specialist

cancel
Showing results for 
Search instead for 
Did you mean: