Invalid URI error during web test

I created a very simple web test that had only one request for one simple URL: https://www.domain.com/ .

When I run the test, although I get Failed and this message:

Request Error: Invalid URI: URI format could not be determined.

But the Response tab has the correct HTTP/1.1 200 OK response with lots of HTML. Is this a bug in Visual Studio or something else, and is there a way to make sure that it doesn't handle the correct requests as broken?

PS I also noticed that the request takes 10-15 seconds, although the RequestTime (as shown by the visual studio) is really less than 1.

+6
source share
3 answers

The HTML of most web pages requires the loading of other files, such as images, JSON, CSS, JavaScript, etc. These are dependent queries. Visual Studio validates HTML to find many dependent queries. All must be valid URLs. Visual Studio code retrieving these dependent requests is less simple than many browsers. Visual Studio requires them to be valid URLs. Many real browsers do their best to deal with bad HTML so that something reasonable can be displayed.

The reason for the exception is probably the wrong HTML format in the response. Some browsers have tools for developers who will describe errors found in the downloaded html. Verify that these developer tools report errors on the page; it might be worth trying several browsers to get different page ratings.

One example: an incorrectly formed base tag can result in the exception you are reporting.


When you view the web test execution log for a successful request, you will see a list of dependent requests. Visual Studio seems to β€œtrust” that these requests form valid URLs, that is, they are formatted correctly. Your test has a poorly formatted URL. If you specified a correctly formatted URL, but there was no resource, you would see a dependent request and receive a 404 error. This is an extreme case, and you can argue that Visual Studio should report it differently.

By "web test execution log" I mean a way to display the results of a web test. This is a tabular form with column headings: Request + Status + Total Time + Request Time + Request Bytes + Response Bytes. Below are tabs that display information about the selected item, tabs are marked as Web browser + Request + Response + Context + Details. If you click on the small triangles on the left side of the Query column, you will see redirects and dependent queries. (Note that the logs for web tests run as part of the load test, omitting the dependent details of the request)

+6
source

The Parsing Dependency setting of False for this particular call helps.

+3
source

I managed to catch an invalid URI value in the VS debugger:

  • Web test code generation (using the toolbar button)
  • Set debugger to stop when any CLR exception occurs
  • Add a breakpoint before an erroneous request
  • Run it under the debugger (via the right mouse button in the code)
  • When you reach the breakpoint, attach QTDCAgent32.exe to the process.
  • Run test

You will be asked to indicate the source file, which you do not have, but it is in order. The Locals debugger window shows a faulty URI. Depending on the presence of debugging symbols, you may need to re-run the test several times (until all symbols are loaded).

Update:

Adrian XXX was right - the problem was in the "base" tag. It looks like this:

  <base href='/foo/'> 

In HTML4, this was illegal, but in HTML5 this is a valid construct. But the VS2013 web testing engine does not work here.

0
source

All Articles