Forum Discussion
A little bit more information will be helpful. What sort of code are you running that gets that error? What are you testing? There could be any number of reasons for the error but without more details, we're pretty much blind here.
Hi Robert,
I am trying to check broken link.
I found the sample code in smartbear site and try running it.
It errored out on the switch statement, trying to get httpObj.status.
function VerifyWebObject(link, expectedObjectData)
{
var httpObj = Sys.OleObject("MSXML2.XMLHTTP");
httpObj.open("GET", link, true);
httpObj.send();
while (httpObj.readyState != 4 && httpObj.readyState != 1)
Delay(100);
switch (httpObj.status)
{
case 200:
case 302:
if (httpObj.responseText != expectedObjectData)
{
Log.Message("The " + link + " link is valid", httpObj.responseText);
return false;
}
break;
default:
Log.Message("The " + link + " link was not found, the returned status: " + httpObj.status, httpObj.responseText);
return false;
}
return true;
}
function Test()
{
var page = Sys.Browser("*").Page("*");
var expectedObjectData = "";
// Obtains the links
var links = page.contentDocument.links;
var linksCount = links.length;
if (linksCount > 0)
{
// Searches for broken links
for (var i = 0; i < linksCount; i++)
{
var link = links.item(i);
var URL = link.href;
Log.Message("The " + URL + " verification results: " + VerifyWebObject(URL, expectedObjectData));
}
}
}
Thanks
Mary
- tristaanogre7 years agoEsteemed Contributor
Just out of curiousity, did this work at one point in time and just stop working recently? Or is this your first attempt at executing that particular code?
I'm thinking, based upon my limited understanding (it's been a looooong time since I've messed with these objects) is that your inclusion of the httpObj.Send() call might be what's screwing things up. You have the open request which should be a sufficient request to get what's at the URL. Have you tried removing that send call?
An alternative... and thanks to LinoTadros for showing me this trick at SmartBear connect... look into using the WebAccessibility checkpoint. You can limit those checkpoints to only check link access so, with basically one line of code, you can get a quick report of which links work and which ones don't.
- mttsow7 years agoOccasional Contributor
Hi Robert,
This is the first time I tried the code and have not worked before.
I tried commented out. httpObj.send(), but still got the same error on msxml3.dll
Checkpoint of WebAccessibility is not preferred because I have a Lot of web pages to check broken links. I'll have to have a lot of files in WebTesting stores.
Mary
- tristaanogre7 years agoEsteemed Contributor
Actually, forget what I said about the "send" method. As I said, it's been a while.
I'm guessing that the "while" loop that you have is not getting hit fast enough and that you're entering the switch statement before the send has completed.
Suggestion: change the third parameter of your "open" command to false and see if this works better. That puts the "send" in a synchronus request and the tests will actually pause and wait for the send to complete, either successfully or with a timeout. I know that this runs the risk of waiting a LOOOONG time for the process to complete but this will at least let us know if the request is actually being sent.''
Another potential edit... change that while loop to only check for != 4. Any other readyState means that the send has not completed. Again, this could potentially put you in a long loop so you might want to add code to break out of the loop after a set amount of time.
- mttsow7 years agoOccasional Contributor
Thanks Robert for your suggestions.
Scripts went further, but eventually I still gotten msxml3.dll Access is denied dialog popup.
Related Content
- 7 years ago
- 5 years ago
Recent Discussions
- 2 days ago