llcotton
6 years agoOccasional 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.
- Make a new keyword test
- Perform find object and add a value for content text
- Right click on the keyword test to create a script. This is an easy way to get the mapping correct.
- In the script add an input variable to the function call
- Change the hardcoded value in quotes to the new variable
- 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