SimpleBrowserDotNet / SimpleBrowser.WebDriver

A webdriver for SimpleBrowser
Apache License 2.0
43 stars 16 forks source link

Browser navigation error when port number in URL #4

Closed RoyMiller closed 12 years ago

RoyMiller commented 12 years ago

Hi there,

The error I'm seeing has nothing directly to do with SimpleBrowser.WebDriver. At least I don't think it does. I believe the problem is in SimpleBrowser.

I'm brand new to .NET and Visual Studio 2010, but I did simple Microsoft tutorial on MVC3 to try to learn about the platform. Being an old eXtreme Programming guy, I wanted to write acceptance tests. So I poked around and found SpecFlow. Then I found SimpleBrowser and SimpleBrowser.WebDriver, which seem like perfect tools for headless web app testing. With that context...

I was seeing an error in my sample app when I tried to use SimpleBrowser.WebDriver to click this link on a page:

http://localhost:2118/movies/Create

The click simply didn't work. It would execute, but it had no effect (i.e., no navigation occurred). I suspected the issue was with SimpleBrowser, so I removed your project from my References and pointed straight to SimpleBrowser. After some debugging I isolated the problem.

As I'm sure you know, the Browser class (Browser.cs) has a method named DoRequest(). That method builds a URL to execute an HttpRequest with. At line 262 in my file, I find this statement:

uri = new Uri(uri.Scheme + "://" + uri.Host + uri.AbsolutePath + "?" + StringUtil.MakeQueryString(userVariables));

That takes the original URI and builds a new one for methods other than POST. Notice that it strips the port number from between uri.Host and uri.AbsolutePath. I changed the line to this:

uri = new Uri(uri.Scheme + "://" + uri.Host + ":" + uri.Port + uri.AbsolutePath + "?" + StringUtil.MakeQueryString(userVariables));

Now it works like a charm, and can find that link I was trying to click.

You don't control SimpleBrowser, obviously, but you use it, so I figured you'd want to know. I would very much like to use SimpleBrowser.WebDriver because the interface is very nice, but I can't use it until SimpleBrowser lets me click my links.

By the way, when I try to load your VS solution file, VS tells me I can't load it up because of these errors:

C:\Documents and Settings\Roy\My Documents\browserdrivers\Teun-SimpleBrowser.WebDriver-794abf4\SimpleBrowser.WebDriver\SimpleBrowser.WebDriver.csproj : error : Unable to read the project file 'SimpleBrowser.WebDriver.csproj'. C:\Documents and Settings\Roy\My Documents\browserdrivers\Teun-SimpleBrowser.WebDriver-794abf4\SimpleBrowser.WebDriver\SimpleBrowser.WebDriver.csproj(80,3): The imported project "C:\Documents and Settings\Roy\my documents\visual studio 2010\Projects\MvcMovie.nuget\nuget.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

C:\Documents and Settings\Roy\My Documents\browserdrivers\Teun-SimpleBrowser.WebDriver-794abf4\DriverTest\DriverTest.csproj : error : Unable to read the project file 'DriverTest.csproj'. C:\Documents and Settings\Roy\My Documents\browserdrivers\Teun-SimpleBrowser.WebDriver-794abf4\DriverTest\DriverTest.csproj(116,3): The imported project "C:\Documents and Settings\Roy\my documents\visual studio 2010\Projects\MvcMovie.nuget\nuget.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

I'm not sure what's wrong. I downloaded your stuff and extracted to my hard drive. Didn't seem like a tough task :) But I can't add it to my own solution in VS. I can add it as a reference via NuGet without any problem at all.

Thanks for your time.

Roy

Teun commented 12 years ago

Hi Roy,

Thanks for your remark. That seems like a bug in SimpleBrowser. I'll fix it and post a new minor version to NuGet.

Teun

RoyMiller commented 12 years ago

Excellent! That's quick turnaround. Thank you very much.

Incidentally, the small change I noted got me past the bug without a hitch, but then I hit another snag. It could be something wrong in my setup, not sure.

Here's the scenario:

Inspecting some variables in the catch block, I see that this appears to be the underlying cause:

"The underlying connection was closed: An unexpected error occurred on a receive."

It's the strangest thing. I don't see anything wrong with the page or the MVC code. The app runs fine when I interact with it physically, and I can add movies all day by clicking that Create button.

Have you ever seen this before?

Some comments on this page suggest it might be an IIS 6.0 bug:

http://geekswithblogs.net/denis/archive/2005/08/16/50365.aspx

But honestly, I didn't know I was even running IIS 6.0. Maybe that came as part of the VS 2010 install and I was unaware of it.


Roy Miller http://www.TheOtherRoad.com

On Sat, May 12, 2012 at 3:19 PM, Teun reply@reply.github.com wrote:

Hi Roy,

Thanks for your remark. That seems like a bug in SimpleBrowser. I'll fix it and post a new minor version to NuGet.

Teun


Reply to this email directly or view it on GitHub: https://github.com/Teun/SimpleBrowser.WebDriver/issues/4#issuecomment-5671063

Teun commented 12 years ago

That's interesting. You are not running IIS, but the development webserver that comes with VS. Can you provide a link to the exact sample app you're working with? I would like to try to reproduce.

RoyMiller commented 12 years ago

Sure. Any sleuthing you can provide would be appreciated. Here's the tutorial:

http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/intro-to-aspnet-mvc-3

I made a few slight changes as I experimented with things like class names, etc., but the core CRUD functionality I have is exactly what you see there.

Thanks.


Roy Miller http://www.TheOtherRoad.com

On Sat, May 12, 2012 at 4:17 PM, Teun reply@reply.github.com wrote:

That's interesting. You are not running IIS, but the development webserver that comes with VS. Can you provide a link to the exact sample app you're working with? I would like to try to reproduce.


Reply to this email directly or view it on GitHub: https://github.com/Teun/SimpleBrowser.WebDriver/issues/4#issuecomment-5671441

Teun commented 12 years ago

Problem with the : is fixed and published to NuGet. The issue you encountered with "underlying connection is closed" are reproducible on my machine. Not clear yet what causes it. I will investigate further.

Teun commented 12 years ago

I'm pretty sure that this behavior was caused by a bug I just fixed in the ContentType header for form POSTs. Recently, I added support for multipart MIME uploads in forms, but I seem to have broken the normal plain vanilla POST. Embarrassing.

All in all: bugs in SimpleBrowser, not in the WebDrive. Please update your dependency. We really must make SimpleBrowser a bit easier to unit test. @RoyMiller: could you test the fix please?

RoyMiller commented 12 years ago

Hi Teun,

It is working for me so far. The SpecFlow scenario which was failing before because of the POST bug appears to be working.

The URL issue appears to be resolved as well. I updated my references to nuke my manual changes, and everything's working.

For some context, I'm doing this experimentation because I'm the coach for an Agile team at a large banking client in the U.S. and they're going to be moving to ATDD and TDD in a big way in the coming weeks. I'm preparing myself to recommend SpecFlow and SB.WD as the right testing tools. Next on the experimentation list is to add a mocking framework to the toolset.

Thanks very much for your help. I'll keep you posted about any other issues I find.


Roy Miller http://www.TheOtherRoad.com

On Sun, May 13, 2012 at 10:55 AM, Teun reply@reply.github.com wrote:

I'm pretty sure that this behavior was caused by a bug I just fixed in the ContentType header for form POSTs. Recently, I added support for multipart MIME uploads in forms, but I seem to have broken the normal plain vanilla POST. Embarrassing.

All in all: bugs in SimpleBrowser, not in the WebDrive. Please update your dependency. We really must make SimpleBrowser a bit easier to unit test. @RoyMiller: could you test the fix please?


Reply to this email directly or view it on GitHub: https://github.com/Teun/SimpleBrowser.WebDriver/issues/4#issuecomment-5676797

Teun commented 12 years ago

OK, cool. SimpleBrowser has been stable for quite a while, but also without much active development. Recently I've started to make improvements, but (as in this case), there were no unit tests with the code, so it's easy to break stuff. Please let me know if you run into more trouble.