thoughtbot / capybara-webkit

A Capybara driver for headless WebKit to test JavaScript web apps
https://thoughtbot.com/open-source
MIT License
1.97k stars 427 forks source link

Can't redirect to a secure port #16

Closed estoner closed 12 years ago

estoner commented 13 years ago

I'm seeing this error when running with capybara-webkit: Unable to load URL: http://127.0.0.1:9887/authentication/login (Capybara::Driver::Webkit::WebkitError)

We're doing something that's arguably a little odd in our app. To verify that login is all done via HTTPS, when we run our tests via Cucumber we spin up a second HTTPS Rails process on port 9888, and all auth requests are 302'd to that port. So our login URL should be https://127.0.0.1:9888/authentication/login.

There are a few things about this that typically cause problems with headless browsers (the separate port, a self-signed certificate) but it looks like we're not even getting as far as those, because capybara-webkit isn't following the 302 from port 9887 to port 9888.

Any idea what might be going wrong or how we could fix this?

Thanks for building this, I've been trying to get a headless browser going for months.

jferris commented 13 years ago

I'd have to try this locally and dig into Qt a bit. I'm guessing I'd need to tweak some settings to allow redirecting to the secure host.

estoner commented 13 years ago

Would it help if I could put together a little app that just did that redirect, to reduce effort on your end?

jferris commented 13 years ago

Sure - if you want to fork the project and add a failing spec, that would be great.

fd commented 13 years ago

I get a similar error:

Unable to load URL: http://127.0.0.1:53006/concepts/new (Capybara::Driver::Webkit::WebkitError) 

http://127.0.0.1:53006/concepts/new is the page capybara was at before submitting a form with goes to http://127.0.0.1:53006/concepts. The submit works but then http://127.0.0.1:53006/concepts 302-redirects to http://127.0.0.1:53006/concepts/1 which fails.

estoner commented 13 years ago

So maybe this has nothing to do with my secure port? Either capybara-webkit can't follow a 302 when a port is specified, or it can't follow a 302 at all?

mcollina commented 13 years ago

I got the very same error with an URL like http://127.0.0.1:50941/enable?some=data.

batasrki commented 13 years ago

Any traction here? I'm running into the same issue.

jferris commented 13 years ago

I haven't had time to work on this lately, so I haven't been able to look into it. If you submit a pull request, I'll make time to review it.

croaky commented 13 years ago

I'm hitting the Unable to load URL: http://127.0.0.1:49720/ (Capybara::Driver::Webkit::WebkitError) issue, too. In this app, when you go to the home page, a Javascript cookie is set for A/B testing and then the user is redirected using:

window.location = "/home";
wm commented 13 years ago

I have come across this problem too. It was caused by using multipart forms.

semantic_form_for @model, :html => { :multipart => true } do |form| %>

I wonder if other people that have this problem are using forms with multipart => true

I was able to confirm that turning off multipart makes my feature past

my error was Unable to load URL: http://127.0.0.1:54976/patients (Capybara::Driver::Webkit::WebkitError)

Not sure if this is related to issue 13

fd commented 13 years ago

I'm using multipart forms as well.

On Thu, Jun 16, 2011 at 3:06 AM, wmernagh < reply@reply.github.com>wrote:

I have come across this problem too. It was caused by using multipart forms.

semantic_form_for @model, :html => { :multipart => true } do |form| %>

I wonder if other people that have this problem are using forms with multipart => true

I was able to confirm that turning off multipart makes my feature past

my error was Unable to load URL: http://127.0.0.1:54976/patients(Capybara::Driver::Webkit::WebkitError)

Not sure if this is related to [issue 13][ https://github.com/thoughtbot/capybara-webkit/issues/13]

Reply to this email directly or view it on GitHub:

https://github.com/thoughtbot/capybara-webkit/issues/16#issuecomment-1378050

dpfranklin commented 13 years ago

Joe,

Had same problem:

Unable to load URL: http://127.0.0.1:55115/ (Capybara::Driver::Webkit::WebkitError)

Found this deep in trace:

Cannot modify SafeBuffer in place (ActionView::Template::Error)

Traced it to this issue with HAML gem:

https://github.com/nex3/haml/issues/404

Its fixed in Haml 3.1.2. Updating Haml corrected apparent capybara:webkit problem. Not sure if its related to other form problems above - so just an FYI.

qrush commented 13 years ago

Just tried upgrading HAML here on an app with the same situation and it didn't work. Just an FYI.

tomdmaguire commented 13 years ago

I am having a similar issue where the driver is unable to access any HTTPS urls on my local server for which I have set up self-signed certificates. I do not have this issue using WebDriver in Firefox as I can manually load the pages and add exceptions for the certificates, and was wondering if there is a similar way of doing this for webkit?

azolotov commented 13 years ago

I'm getting the same errors when I do redirects, for example

def new
  if current_user.profile
    redirect_to results_path 
  else
    @profile = current_user.build_profile
  end
end
cice commented 13 years ago

+1 i think, trying to test a payment page integration (wirecard qpay) with sandbox test login, works fine with firefox + selenium. the thing why i'd love to switch to capybara webkit, is that you can't disable firefox's security warning about leaving a secured page. so at every test run i have to dismiss this warning manually. this means, i can't enable this feature for CI, but have to run it manually from time to time.

dmacvicar commented 13 years ago

cice: Would this workaround work for you? https://github.com/thoughtbot/capybara-webkit/pull/152

cice commented 13 years ago

hi dmacvicar, i'll try that tomorrow, thnx!

jferris commented 12 years ago

We added the ability to ignore SSL errors to capybara-webkit a while back. Please take a look at #109 for general "unable to load URL" issues.