From: John Date: 2002-07-17T02:46:28+09:00 Subject: Re: Win32OLE: Is getting MSIE HTTP status possible? "Dossy" wrote in message news:20020716172105.GJ2284@panoptic.com... > Hi, > > I'm using Ruby, Win32OLE, Microsoft Internet Explorer and Test::Unit > to automate web testing (hopefully to eliminate any need for our team > to use WinRunner + WebTest for most of our testing). > > Is there any way to get the HTTP status code from IE through COM? > As in, to tell if the page displayed was HTTP status 200 OK vs. > 404 Not Found or 500 Server Error, etc.? > > Parsing the displayed page works in the specific case, but not in > the general case -- where we may not be able to control the 404 > display, or the 404 page is a javascript or meta-refresh redirect > to another page. I still need to know that the original URL that > was navigated to returned HTTP status 404 from the webserver. > > I think I'm out of luck here, but I figured I'd ask the gurus > first, before giving up hope. > > -- Dossy > > -- > Dossy Shiobara mail: dossy@panoptic.com > Panoptic Computer Network web: http://www.panoptic.com/ > "He realized the fastest way to change is to laugh at your own > folly -- then you can let go and quickly move on." (p. 70) > > I think its kinda strange to use Ruby to do this, but to each his own. For further questions regarding IE/automation I would recommend going to an IE/vbcript newsgroup. That said, the following vbscript code does what you want: set oHTTP = CreateObject ("msxml2.XMLHTTP") oHTTP.open "GET", "http://www.yahoo.com/", false oHTTP.send sRequest Wscript.echo "Status = " & oHTTP.status Rem Wscript.echo oHTTP.responseText It uses the msxml component. I did not have a sample for how to do this with the internet explorer control per se. That information, if it exists, will be available by asking in an IE programming newsgroup. HTH John.