sunireddy2007
11 years agoOccasional Contributor
Scripting and Finding DIV Elements
Hi,
I am creating a simple test script to test a web page. After logging into the webapp, the page displays a list of DIV items and each DIV contains a hyperlink. And also some other text with some identifying numbers. Using the page.FindAllChildren method and passing className of the DIV plus the tagName as DIV, I am able to get an array of DIV objects. Now I loop thru and look for my particular DIV with the number I am looking for. The script finds it successfully. Now when I call Find method on the div object passing in the contentText and tagname properties, I am not able to find the hyperlink. I am able to see the properties in the Object Spy and cannot get the link via script. Please help!!!
Below is the code after finding the particular DIV I am looking for. It always goes into the Else block below.
hmap.Add "contentText", "Project Setup"
hmap.Add "tagName", "A"
hmap.Add "innerHTML", "Project Setup"
hmap.Add "title", "Click to work on the task"
keys = hmap.Keys
values = hmap.Items
Set PrjLink = myDiv.Find(keys, values, 100)
If (PrjLink.Exists) Then
Log.Message "link exists"
PrjLink.Click
Else
Log.Message "link does not exist, "
End If
Sunitha.
I am creating a simple test script to test a web page. After logging into the webapp, the page displays a list of DIV items and each DIV contains a hyperlink. And also some other text with some identifying numbers. Using the page.FindAllChildren method and passing className of the DIV plus the tagName as DIV, I am able to get an array of DIV objects. Now I loop thru and look for my particular DIV with the number I am looking for. The script finds it successfully. Now when I call Find method on the div object passing in the contentText and tagname properties, I am not able to find the hyperlink. I am able to see the properties in the Object Spy and cannot get the link via script. Please help!!!
Below is the code after finding the particular DIV I am looking for. It always goes into the Else block below.
hmap.Add "contentText", "Project Setup"
hmap.Add "tagName", "A"
hmap.Add "innerHTML", "Project Setup"
hmap.Add "title", "Click to work on the task"
keys = hmap.Keys
values = hmap.Items
Set PrjLink = myDiv.Find(keys, values, 100)
If (PrjLink.Exists) Then
Log.Message "link exists"
PrjLink.Click
Else
Log.Message "link does not exist, "
End If
Sunitha.