# Ruby: Watir HRESULT error code 0x80020006

**URL:** <https://www.ruby-forum.com/t/ruby-watir-hresult-error-code-0x80020006/119265>\
**Category:** Ruby\
**Created:** [November 5, 2007, 5:33pm UTC](https://www.ruby-forum.com/t/ruby-watir-hresult-error-code-0x80020006/119265 "2007-11-05T17:33:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![starmaerker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@starmaerker](https://www.ruby-forum.com/u/starmaerker)\
**Post date:** [November 5, 2007, 5:33pm UTC](https://www.ruby-forum.com/t/ruby-watir-hresult-error-code-0x80020006/119265/1 "2007-11-05T17:33:41Z")

</div>

Hi,

I’m having some problems with a Ruby script that I’ve adapted to use  
HTTPWatch. The program uses Watir, and goes through a site and checks  
all the links.

However when the link checker reaches a page that is a redirect then the  
following error occurs:

c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1230/./watir.rb:4188:in  
`method_missing': unknown property or method`getElem  
entsByTagName’ (WIN32OLERuntimeError)  
HRESULT error code:0x80020006  
Unknown name. from  
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1230/./watir.rb:4188:in  
`length' from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1230/./watir.rb:2817:in`initialize’  
from  
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1230/./watir.rb:613:in `new' from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1230/./watir.rb:613:in`links’  
from  
H:/Test\_scripts/Watir\_scripts/test\_scripts/Http\_Watch/httpwatch.rb:94

The code snippet in question is this section, with the error occurring  
on the line ‘e.links().each do |link|’:

ie.goto(nextUrl) # get WATIR to load URL  
@PageCounter += 1  
urlsVisited.push( nextUrl) # store this URL in the list that  
has been visited  
# Look at each link on the page and decide if it needs to be  
visited

```
ie.links().each do |link|
  linkUrl = link.href.CanonicalUrl
  if @response.code == '301'||@response.code ==

```

‘302’||@response.code == ‘303’||@response.code == ‘304’||@response.code  
== ‘305’||@response.code == ‘306’||@response.code == ‘307’  
puts @response.code  
next  
end  
# if the url has already been accessed or if it is a download or  
if it from a different domain  
# linkUrl.Path.include?( “.pdf” )  
if !url.IsSubDomain( linkUrl.HostName ) ||  
linkUrl.Path.include?(".zip") || linkUrl.Path.include?( “.png” ) ||  
urlsToVisit.find{ |aUrl| aUrl == linkUrl} != nil ||  
urlsVisited.find{ |aUrl| aUrl == linkUrl} != nil  
# Don’t add this URL to the list  
next  
end  
# Add this URL to the list  
urlsToVisit.push(linkUrl)  
end

Any ideas on this?

Andrew
