Forum Discussion
function search_in_a_div()
{
var app, testfile, myPage, mySection, myLink;
var PropArray, ValuesArray;
var ConvertedPropArray, ConvertedValuesArray;
app = TestedApps.iexplore.Run();
testfile = "file:///" + Project.Path + "search-test.html";
Log.Message(testfile);
myPage = app.ToURL(testfile);
// search for the link "Click" and click it
mySection = myPage.NativeWebObject.Find("id", "second_section");
if (mySection.Exists)
{
Log.Message("Found second_section");
// now search WITHIN this DIV for an element with the id of "muppet"
PropArray = new Array("div", "id");
ValuesArray = new Array("muppet", true);
// Converts arrays
ConvertedPropArray = ConvertJScriptArray(PropArray);
ConvertedValuesArray = ConvertJScriptArray(ValuesArray);
myLink = mySection.Find(ConvertedPropArray, ConvertedValuesArray, 5);
if (myLink.Exists)
myLink.Click();
else
Log.Warning("No link here");
}
else
Log.Warning("No second_section here");
}
function ConvertJScriptArray(AArray)
{
// Uses the Dictionary object to convert a JScript array
var objDict = Sys.OleObject("Scripting.Dictionary");
objDict.RemoveAll();
for (var j in AArray)
objDict.Add(j, AArray
return objDict.Items();
}
Related Content
- 4 years agomehdisinger
- 11 years agokirk_bottomley
- 2 years agoPossum
Recent Discussions
- 11 hours agotramuntana
- 3 days agoSlickRick