Skip to content. | Skip to navigation

Personal tools


You are here: Home / Blog / Testbrowser Redirects with Fragments

Testbrowser Redirects with Fragments

by Ross Patterson last modified Nov 23, 2008 03:04 AM
Using zope.testbrowser when a redirect URL includes a fragment

I was trying to add functional test coverage for commenting on content when I kept getting 404 NotFound errors.  I tried it in a real browser and everything worked just fine.  After a little googling, I found an answer in a post on the zope3-dev mailing list:

Note that the fragment identifier is *never* going to be passed to the server by a "real" browser: instead, the browser strips of the fragment part, submits the remainder of the URL to the server, and then does a search for the appropriate '<a name="bar">' element *on the client side*.

I'm not sure how this is pertinent to the problem you have found, but Zope will never traverse '#bar' or '%23bar' in the real world.

It seems like maybe testbrowser should not send fragments to the underlying mechanize browser.  But failing that, for now I just add a note to my tests about why we expect a 404, NotFound error in our tests that we won't see in a real browser.

Hope this saves someone else the search time.  :)

OpenID Login


IRC: rossp
Yahoo IM: patterson_ross
AIM: rosspatters
Skype: merpattersonnet

PO Box 7775 #10587
San Francisco, CA

+1 (415) 894-5323