Alison_Hawke
14 years agoOccasional Contributor
Search for an element within a DIV on a web page
Our application is large, and Page.NativeWebObject.Find("id", "myID") is crushingly slow. I need to narrow down the search to a specific DIV within the web page.
I've tried this:
search()
I've tried this:
function search()
search()
{
// this will always find the first link
var app, testfile, myPage, myLink;
app = TestedApps.iexplore.Run();
testfile = "file:///" + Project.Path + "search-test.html";
Log.Message(testfile);
myPage = app.ToURL(testfile);
// search for the element ID "muppet" and click it
myLink = myPage.NativeWebObject.Find("id", "muppet");
if (myLink.Exists)
myLink.Click();
else
Log.Warning("No link here");
}
What I want to do is search for a link within a DIV with the ID "second_section" (<div id="second_section">)
How do I do this, in vbscript and in jscript, for IE7 and IE8? I've been looking at the FindChild method, and the Find method, and the documentation doesn't help.