01-21-2008, 03:28 PM
Hi!
I once wrote a little tool function, which collects all error messages (all objects having the class *error*) on a page/table. Basically it works fine, but it seems not on all pages. There is a certain one, where it just won't pick up the <p> tags. To be more exact, if I use ChildObjects() without a decription object it will pick up 14 items, but in all of them the "class" is empty (when debugging or outputting it in qtp), even though in the html source cleary shows that those html items do have a class set. Also I tried using the whole page as parent, or the WebTable those messages are in, but it does not make a difference.
In the following is the code of that function, and further down the html (-snipplet, only the one table with the messages) where it should actually work on, but it does not.
Thanks for reading and potentially helping!
CC
html code (not that the classes are set)
I once wrote a little tool function, which collects all error messages (all objects having the class *error*) on a page/table. Basically it works fine, but it seems not on all pages. There is a certain one, where it just won't pick up the <p> tags. To be more exact, if I use ChildObjects() without a decription object it will pick up 14 items, but in all of them the "class" is empty (when debugging or outputting it in qtp), even though in the html source cleary shows that those html items do have a class set. Also I tried using the whole page as parent, or the WebTable those messages are in, but it does not make a difference.
In the following is the code of that function, and further down the html (-snipplet, only the one table with the messages) where it should actually work on, but it does not.
Thanks for reading and potentially helping!
CC
Code:
Function getAllErrorMessagesOnPage(parentObject)
Dim errorDescription
Dim allErrorMessages
Dim i
Dim returnValue
Set errorDescription=Description.Create
if(isNull(parentObject) or not parentObject.exist(2)) then
Exit function
end if
errorDescription("class").value = ".*error.*"
errorDescription("class").regularexpression =true
set allErrorMessages=parentObject.ChildObjects(errorDescription)
For i=0 to allErrorMessages.count-1
returnValue=returnValue+allErrorMessages(i).getRoProperty("innertext")+";"
Next
getAllErrorMessagesOnPage=returnValue
End Function
html code (not that the classes are set)
Code:
<table class="blueTop"width="100%">
<tr>
<th colspan="2">Uploaded Files</th>
</tr>
<tr>
<td colspan="2"><p class="errorText">Error</p><p class="errorText">You must correct the following error(s) before proceeding:</p><p class="errorText"><img src="/images/new/cross.gif"> image is not JPeg/GIF format</p></td>
</tr>
<tr>
<td valign="top">
<select name="removedFiles" size="5" multiple>
</select>
</td>
<td align="right" valign="bottom">
<input type="image" name="" src="/images/new/remove.gif" onclick="remove(document.dealerCatBImageUploaderForm)">
</td>
</tr>
<tr>
<td class="boldText">
Current total = 0 K
</td>
<td align="right">
<input type="image" src="/images/new/finish.gif" onClick="window.close();">
</td>
</tr>
</table>