Here's the Object Repository creation code I wrote (below). It puts the object functions into c:\testfile.txt
function FindPageObjsAndCreateObjRepository()
{
//ObjRep();
var fso, tf;
fso = new ActiveXObject("Scripting.FileSystemObject");
tf = fso.CreateTextFile("c:\\testfile.txt", true);
var pageObjNames = new Array();
var pageObjNamesIndex = 0;
//Page
page = Sys.Process("IEXPLORE").Page("*");
pageURL = page.ObjectIdentifier;
//find page name from Title bar in browser tab
pageTitle = Sys.Process("iexplore").IEFrame(0).CommandBar.TabBand.TabButton("*").Name.split("\"")[1];
pageTitleElements = pageTitle.split(" ");
for(var i = 0; i < pageTitleElements.length; i++)
{
if(i == 0)
pageTitle = pageTitleElements.toLowerCase();
else
pageTitle = pageTitle + pageTitleElements;
}
pageTitle = pageTitle.toString().replace(/\W/g, '');
//Optional: specify page title alias
pageTitle = "rmLogin";
tf.writeLine("/*");
tf.writeLine("\t" + pageTitle + " page objects");
tf.writeLine("*/");
tf.writeLine("//var pageURL = \"" + pageURL + "\"\;");
tf.writeLine("function " + pageTitle + "(){return " + page.FullName.replace(pageURL, "*") + "\;}");
//Textboxes
tf.writeLine("//");
tf.writeLine("//Textboxes");
tf.writeLine("//");
pageObjs = page.FindAll("ObjectType", "*Textbox*", 9999);
pageObjs = (new VBArray(pageObjs)).toArray();
for(var i = 0; i < pageObjs.length; i++)
{
//If page objects have the same name, add an index number for each subsequent entry
var objNum = 1;
var pageObjName, newPageObjName;
pageObjName = pageObjs.ObjectIdentifier;
newPageObjName = pageObjName;
pageObjNames[pageObjNamesIndex] = pageObjs.ObjectIdentifier;
for(var z = 0; z < pageObjNames.length; z++)
{
if((z != i) && newPageObjName == pageObjNames)
{
objNum++;
newPageObjName = pageObjName + objNum;
pageObjNames = newPageObjName;
}
}
pageObjName = newPageObjName.toString().replace(/\W/g, '');
//if object name is just a number, add object type to the name to make it unique
if(!isNaN(pageObjName))
pageObjName = "textbox" + pageObjName;
tf.writeLine("function " + pageTitle + "_" + pageObjName.replace(/\s+/g, '') + "(){return " + pageObjs.FullName.replace(pageURL, "*") + "\;}");
pageObjNamesIndex++;
}
pageObjs = page.FindAll("ObjectType", "Password*", 9999);
pageObjs = (new VBArray(pageObjs)).toArray();
for(var i = 0; i < pageObjs.length; i++)
{
tf.writeLine("function " + pageTitle + "_" + pageObjs.ObjectIdentifier.toString().replace(/\W/g, '') + "(){return " + pageObjs.FullName.replace(pageURL, "*") + "\;}");
}
//Textareas
tf.writeLine("//");
tf.writeLine("//Textareas");
tf.writeLine("//");
pageObjs = page.FindAll("ObjectType", "*Textarea*", 9999);
pageObjs = (new VBArray(pageObjs)).toArray();
for(var i = 0; i < pageObjs.length; i++)
{
//If page objects have the same name, add an index number for each subsequent entry
var objNum = 1;
var pageObjName, newPageObjName;
pageObjName = pageObjs.ObjectIdentifier;
newPageObjName = pageObjName;
pageObjNames[pageObjNamesIndex] = pageObjs.ObjectIdentifier;
for(var z = 0; z < pageObjNames.length; z++)
{
if((z != i) && newPageObjName == pageObjNames)
{
objNum++;
newPageObjName = pageObjName + objNum;
pageObjNames = newPageObjName;
}
}
pageObjName = newPageObjName.toString().replace(/\W/g, '');
//if object name is just a number, add object type to the name to make it unique
if(!isNaN(pageObjName))
pageObjName = "textarea" + pageObjName;
tf.writeLine("function " + pageTitle + "_" + pageObjName.replace(/\s+/g, '') + "(){return " + pageObjs.FullName.replace(pageURL, "*") + "\;}");
pageObjNamesIndex++;
}
//Drop down selection boxes
tf.writeLine("//");
tf.writeLine("//Drop down selection boxes");
tf.writeLine("//");
pageObjs = page.FindAll("ObjectType", "*Select*", 9999);
pageObjs = (new VBArray(pageObjs)).toArray();
for(var i = 0; i < pageObjs.length; i++)
{
//If page objects have the same name, add an index number for each subsequent entry
var objNum = 1;
var pageObjName, newPageObjName;
pageObjName = pageObjs.ObjectIdentifier;
newPageObjName = pageObjName;
pageObjNames[pageObjNamesIndex] = pageObjs.ObjectIdentifier;
for(var z = 0; z < pageObjNames.length; z++)
{
if((z != i) && newPageObjName == pageObjNames)
{
objNum++;
newPageObjName = pageObjName + objNum;
pageObjNames = newPageObjName;
}
}
pageObjName = newPageObjName.toString().replace(/\W/g, '');
//if object name is just a number, add object type to the name to make it unique
if(!isNaN(pageObjName))
pageObjName = "dropDownBox" + pageObjName;
tf.writeLine("function " + pageTitle + "_" + pageObjName.replace(/\s+/g, '') + "(){return " + pageObjs.FullName.replace(pageURL, "*") + "\;}");
pageObjNamesIndex++;
}
//Links
tf.writeLine("//");
tf.writeLine("//Links");
tf.writeLine("//");
pageObjs = page.FindAll("ObjectType", "*Link*", 9999);
pageObjs = (new VBArray(pageObjs)).toArray();
for(var i = 0; i < pageObjs.length; i++)
{
//If page objects have the same name, add an index number for each subsequent entry
var objNum = 1;
var pageObjName, newPageObjName;
pageObjName = pageObjs.innerText;
newPageObjName = pageObjName;
pageObjNames = pageObjs.innerText;
for(var z = 0; z < pageObjNames.length; z++)
{
if((z != i) && newPageObjName == pageObjNames)
{
objNum++;
newPageObjName = pageObjName + objNum;
pageObjNames = newPageObjName;
}
}
pageObjName = newPageObjName.toString().replace(/\W/g, '');
//if object name is just a number, add object type to the name to make it unique
if(!isNaN(pageObjName))
pageObjName = "link" + pageObjName;
tf.writeLine("function " + pageTitle + "_" + pageObjName.replace(/\s+/g, '') + "(){return " + pageObjs.FullName.replace(pageURL, "*") + "\;}");
pageObjNamesIndex++;
}
//Buttons
tf.writeLine("//");
tf.writeLine("//Buttons");
tf.writeLine("//");
pageObjs = page.FindAll("ObjectType", "*Button*", 9999);
pageObjs = (new VBArray(pageObjs)).toArray();
for(var i = 0; i < pageObjs.length; i++)
{
//If page objects have the same name, add an index number for each subsequent entry
var objNum = 1;
var pageObjName, newPageObjName;
pageObjName = pageObjs.ObjectIdentifier;
newPageObjName = pageObjName;
pageObjNames[pageObjNamesIndex] = pageObjs.ObjectIdentifier;
for(var z = 0; z < pageObjNames.length; z++)
{
if((z != i) && newPageObjName == pageObjNames)
{
objNum++;
newPageObjName = pageObjName + objNum;
pageObjNames = newPageObjName;
}
}
pageObjName = newPageObjName.toString().replace(/\W/g, '');
//if object name is just a number, add object type to the name to make it unique
if(!isNaN(pageObjName))
pageObjName = "button" + pageObjName;
tf.writeLine("function " + pageTitle + "_" + pageObjName.replace(/\s+/g, '') + "(){return " + pageObjs.FullName.replace(pageURL, "*").replace(pageObjs.Name, pageObjs.Name.replace(/\s+/g, "*")) + "\;}");
pageObjNamesIndex++;
}
//Tables
tf.writeLine("//");
tf.writeLine("//Tables");
tf.writeLine("//");
pageObjs = page.FindAll("ObjectType", "*Table*", 9999);
pageObjs = (new VBArray(pageObjs)).toArray();
for(var i = 0; i < pageObjs.length; i++)
{
//If page objects have the same name, add an index number for each subsequent entry
var objNum = 1;
var pageObjName, newPageObjName;
pageObjName = pageObjs.ObjectIdentifier;
newPageObjName = pageObjName;
pageObjNames[pageObjNamesIndex] = pageObjs.ObjectIdentifier;
for(var z = 0; z < pageObjNames.length; z++)
{
if((z != i) && newPageObjName == pageObjNames)
{
objNum++;
newPageObjName = pageObjName + objNum;
pageObjNames = newPageObjName;
}
}
pageObjName = newPageObjName.toString().replace(/\W/g, '');
//if object name is just a number, add object type to the name to make it unique
if(!isNaN(pageObjName))
pageObjName = "table" + pageObjName;
tf.writeLine("function " + pageTitle + "_" + pageObjName.replace(/\s+/g, '') + "(){return " + pageObjs.FullName.replace(pageURL, "*") + "\;}");
pageObjNamesIndex++;
}
tf.close();
}