Updating path of ORs
Im using AOM to update an OR path.
The OR is not local to the test, so I need to update where it is located.
I try in the following way:
Get Actions from test
Get OR collection from action
for all OR in OR collection look at their old name.
If their old name matches the name of the global OR name, delete it, and add it again with the correct path
Something along these lines:
<font class="small">Code:</font><hr /><pre>
private void SetObjectRepositories(string orPath, string orName)
Test test = QTPApp.Test as Test;
Actions actions = test.Actions as Actions;
for (int i = 1; i <= actions.Count; i++)
QuickTest.Action action = actions[i] as QuickTest.Action;
ObjectRepositories ors = action.ObjectRepositories;
for (int j = 1; j <= ors.Count; j++)
String orsPath = ors[j] as String;
if (ors.Find(orPath + orName) == -1)
ors.Add(orPath + orName, -1);
} </pre><hr />
However 'Remove' throws an execption. I think it is because the OR is seen as missing resource from QTP point of view, so it is in the collection of ORs but im not allowed to remove it. 'RemoveAll' works, but that is not what I want.
Any ideas what Im doing wrong?