-
Notifications
You must be signed in to change notification settings - Fork 415
Problems with redirect to HTTPS #121
Comments
I think this may be a problem with not having the correct SSL libraries on your system.
|
I'm running Cucumber (and subsequently Capybara, Poltergeist, and PhantomJS) on my Mac OS X 10.6. I haven't tried using PhantomJS directly because I don't know how to use it (I only learned about PhantomJS from finding Poltergeist while looking for a headless browser to use with Capybara). If you could give me some steps to take I can try to track this down further. |
create a page = require('webpage').create()
page.open('https://somewebsite.com/', function(status) {
console.log(status)
}) (obviously fill in with a real url) then run with |
Okay, so I tried a few different things and PhantomJS is working as expected. When I use my insecure http url, it redirects me to the HTTPS version and succeeds. However, I had to make sure to pass the command line option correctly:
|
Okay, so HTTPS is working. What comes up in the rails log when you run your test? |
The application I am testing is not a Rails app. It's not even Ruby. It's PHP. Sorry if I left that part out. =] So I'm not sure what you want me to look for. Are you interested in the Apache access logs? My app has a development log, but it only logs errors of which there are none that I know of. My question is what is Poltergeist doing with PhantomJS that causes this to fail in Poltergeist but not PhantomJS. Are the command line options being passed to PhantomJS correctly? |
Yes, Apache access logs would be interesting. I just want to see what requests actually get made. You could also print the output of |
At first, I wasn't able to get The next difference I noticed when I switched to master is that rather than getting a The apache logs show that PhantomJS is actually redirecting to the HTTPS page and making requests for javascript files:
I am aware that there are a few areas of the site that have javascript errors (this is a legacy site that I am trying to start testing) but they aren't noticeable when you are viewing it from a browser so we haven't tried to fix them. When I ran the
So I started looking around in the other issues to see if maybe my issue is related to something else. That's when I came across issue #124 and pull request #125. It sounds like a very similar issue. So I decided to try and see if their fix would help me. So I switched to their fork:
...and got a message very similar to the one from my PhantomJS test. Then setting the driver's So short story made long, I think my issue is more likely related to javascript errors and Poltergeist not handling them apropriately and/or a bug in PhantomJS. |
Regarding the crashing - PhantomJS should never crash so yeah, do file a bug report against PhantomJS. I'll look at #125 in due course... |
I'm having similar problems. I had cucumber working fine without javascript, but when I added poltergeist, any https redirects that happen for It appears that after being redirected to Here's my Capybara config: Capybara.configure do |config|
config.default_driver = :poltergeist
config.javascript_driver = :poltergeist
config.app_host = "http://127.0.0.1"
config.run_server = true
config.server_port = 7787
config.default_wait_time = 10
end
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app,
:phantomjs_options => ['--debug=yes', '--load-images=no', '--ignore-ssl-errors=yes'],
:debug => true)
end
Before '@javascript' do
Capybara.app_host = "http://127.0.0.1:#{Capybara.server_port}"
end Here's what the test does: When /^I am logged in as "(.*?)" with password "(.*?)"$/ do |email, password|
visit '/login/new'
puts page.driver.network_traffic.inspect
puts current_url
puts page.body
fill_in 'Email:', :with => email
fill_in 'Password:', :with => password
click_button 'Login'
page.should have_content('Logged In') # Note: unicode space
end Here's the output from cucumber:
then this is repeated a gazillion times:
lastly, this:
Here's what I see in
I'm using the
|
I have the same problem as @raphaelcm |
Also having the same problem. |
I am seeing the same: empty screenshot/blank age for a site with a redirect. |
I see the same, empty page when trying to load a https:// site with poltergeist. Works in capybara-webkit, fwiw. |
I'm seeing the same on my end. It's proving problematic, since we want a headless setup on our automated build process. As soon as I change my drivers to selenium rather then poltergeist, the page seems to redirect properly. The site I'm trying to hit basically has a URL that immediately is supposed to redirect the user to a sign in page, but it seems that redirect is never occurring, making all the tests fail since that page never loads. If anybody needs anything to provide in order to help them track this down, I'm more then willing to provide. The same goes for if anybody knows a solution I might be missing to get this to work properly. |
@joevandyk what OS are you running it on? Got it working on Ubuntu but failing on CentOS 6.5 and driving me crazy! |
BTW, I just revisited this a year later and because the problem still happens with current phantomjs, I looked further and found a workaround: --ssl-protocol=TLSv1 Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app,
:phantomjs_options => ['--debug=no', '--load-images=no', '--ignore-ssl-errors=yes', '--ssl-protocol=TLSv1'], :debug => false)
end
end and it works! (got the idea from here ariya/phantomjs#11239 ) |
👍 thanks for the followup, @dmacvicar |
No more information about this?? I am having this problem too with poltergeist 1.5.0 and phantomjs 1.9.0 |
Thanks @dmacvicar That solved the problem perfectly for me. Apparently some update seems to have arbitrarily broken SSL for me this week, but this fixed it right up |
thanks, @dmacvicar ! |
@dmacvicar Thanks, that solved my problem! |
@dmacvicar Thanks for that! After the POODLE exploit, SSL3 is going away so I think you have saved a lot of people's days! |
@dmacvicar, many thanks!, that solved the problem for us. |
I am too facing this issue : require "Capybara"
require "Capybara/cucumber"
require "rspec"
require "capybara/poltergeist"
Capybara.default_selector = :xpath
Capybara.configure do |config|
config.default_driver = :poltergeist
config.javascript_driver = :poltergeist
config.app_host = "http://127.0.0.1"
config.run_server = true
config.server_port = 7787
config.default_wait_time = 10
end
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app,
:phantomjs_options => ['--debug=no', '--load-images=no', '--ignore-ssl-errors=yes', '--ssl-protocol=TLSv1'], :debug => false)
end
end
Before '@javascript' do
Capybara.app_host = "http://127.0.0.1:7787"
end My test does as Given /^I am on "(.*?)" instance$/ do |sncurl|
visit ('https://leanpub.com/whatsnewinjava8/read')
puts page.driver.network_traffic.inspect
puts current_url
puts page.body
end When I run this code I am receiving:
And when I redirect to gooogle it is working fine but not for other URLs. |
@TriptiMittal turn on the debugging and see what you get. That was helpful for me once I enabled. You may want to experiment with using --ssl-protocol=auto as well, which seemed to also work for me. |
Hi.. I am new to this technology and don't know how to open the debugger.. Please help me know that how to do the same. |
Change it in the obvious place: :phantomjs_options => ['--debug=no', '--load-images=no', '--ignore-ssl-errors=yes', '--ssl-protocol=TLSv1'], :debug => false) |
Hi, [#<Capybara::Poltergeist::NetworkTraffic::Request:0x409d448 @data={"headers"=>[{"name"=>"User-Agent", "value"=>"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.7 Safari/534.34"}, {"na
me"=>"Accept", "value"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"}], "id"=>1, "method"=>"GET", "time"=>"2014-12-02T06:20:32.526Z", "url"=>"https://leanpub.com/whatsnewinjava8/read"}, @response_parts=[#<Capy
bara::Poltergeist::NetworkTraffic::Response:0x40a08c8 @data={"contentType"=>nil, "headers"=>[], "id"=>1, "redirectURL"=>nil, "stage"=>"end", "status"=>nil, "statusText"=>nil, "time"=>"2014-12-02T06:20:33.711Z", "url"=>"https://lea
npub.com/whatsnewinjava8/read"}>]>]
" <html><head></head><body></body></html>"
about:blank Moreover when I am using What changes need I to make to get an HTML page and proceed further with the tests? |
thx @dmacvicar |
👍 @dmacvicar thanks! |
Closing since this seems to have been an SSL settings issue -- we can reopen/open a new issue if people are still having problems |
Faced the same problem with poltergeist 1.3.0, phantomjs 1.9.1 and capybara 2.1.0 .
|
I'm doing web scraping, and |
Same situation as x-yuri and lui�smsilva99. Many pages would work fine, some would not load at all. |
@michaelschmitz This was closed over 2 years ago due to being user setting issues. If you actually have found a bug in Poltergeist please open a new issue and provide a reproducible example. Locking this issue now. |
I have a cucumber test suite using Capybara and Selenium which is all passing. I'm trying to switch to Poltergeist to speed up my tests, however I'm having problems getting it to work.
The first step of my test is to go to the login page and log in, but it's failing. The browser should first navigate to the insecure
http://dev.example.com/auth/login
, then redirect to the securehttps://dev.myapp.com/auth/login
. We are using self-signed certificates, but I enabledignore-ssl-errors
and it's still failing:What do I need to do to get this working?
The text was updated successfully, but these errors were encountered: