1. For getElementsByTagName, instead of:

If objDIV(k).className = "cErrors" Then

use this:

If objDIV.item(k).className = "cErrors" Then

2. Last I checked, getElementsByClassName was not supported by several 
browsers.  You can see if your browsers are supported:  
https://www.google.com/search?q=getelementsbyclassname+compatibility

Use XPath.  I have not tested this in any browser, but you can give it a 
try:

set objDIV = Browser("Browser").Page("Page").WebElement(
"xpath:=//.[@class='cErrors']")

On Friday, May 10, 2013 12:04:21 PM UTC-4, TM wrote:
>
> Hi again Ganesh,
>
> Thanks for sharing the link. Would request you to explain how to retrieve 
> the innertext of an element in FF and Chrome?
>
>
> for e.g. here is the sample code; here, I am looking to retrieve the Error 
> messages if Class CErrors exist on the Page
> HTML Source:
>
> <div class="cErrors">
> <ul>
>   <li><span class="cQA-missing-geolocation">The minimum required address 
> is a postal code, or street address with a city and a province.</span></li>
>   <li><span class="cQA-missing-street">Please enter a street 
> address.</span></li>
>   <li><span class="cQA-missing-city">City name required.</span></li>
>   <li><span class="cQA-missing-province">Please select a 
> province.</span></li>
> </ul>
> </div>
>
> (1)
> ' Following code works in IE but NOT in Firefox and Chrome
> set objDIV = 
> Browser("Browser").Page("Page").Object.getElementsByTagName("DIV")
> For k = 0 to objDIV.length - 1
> If  objDIV(k).className = "cErrors" Then
>   msgbox "Div Inner Text is " & objDIV(k).innertext
> End If
> Next
>
>
> (2)
> ' Following code works in IE but NOT in Firefox and Chrome
> set objDiv = 
> Browser("Browser").Page("Page").Object.getElementsByClassName("cErrors")
> msgbox objDiv(0).innerText ' Retrieves all the Error messages
>
> >> Chrome & Firefox throws the error "Object Required"
>
>
> (3)
> ' Following code works in IE and Chrome but NOT in Firefox
> set objDiv = 
> Browser("Browser").Page("Page").Object.getElementsByClassName("cErrors")
> msgbox objDiv.length
>
> >> Firefox returns the empty string
>
>
>
> Thanks
> Taru
>
>
> On Friday, 10 May 2013 10:20:57 UTC-4, Ganesh muralidharan wrote:
>>
>>
>> http://www.sqaforums.com/forums/hp-functional-testing-mercury-quicktest-pro-qtp/147634-dom-object-support-google-chrome-qtp-11-a.html
>>
>>
>> On Fri, May 10, 2013 at 9:14 AM, TM <[email protected]> wrote:
>>
>>> Hi,
>>>
>>> I'm building QTP tests to be tested on IE, Chrome and Firefox using DOM.
>>>
>>> *getElementsByTagName*: works ONLY in IE and *NOT *in Chrome and 
>>> Firefox. *Is there a way that this method can be used in Chrome and 
>>> Firefox?* Please guide giving an example
>>> *getElementsByClassName: *works in both IE and Chrome but *NOT *Firefox
>>>
>>> are these methods not supported in Chrome and Firefox?
>>> I'm using QTP 11, IE 9, FF 17 and Chrome 25.
>>>
>>> Please advise.
>>>
>>> Thanks
>>> Taru
>>>
>>>
>>>
>>>  -- 
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> "QTP - HP Quick Test Professional - Automated Software Testing"
>>> group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/MercuryQTP?hl=en
>>>  
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "QTP - HP Quick Test Professional - Automated Software Testing" 
>>> group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>>
>>
>>
>>
>> -- 
>> Regards,
>>
>>
>> Ganesh Muralidharan
>> 'God Never Forgets' 
>>
>

-- 
-- 
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

--- 
You received this message because you are subscribed to the Google Groups "QTP 
- HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to