save_and_open_page not working with capybara 2.0?

后端 未结 2 1374
太阳男子
太阳男子 2021-02-12 14:47

I just had my capybara updated to 2.0, and all of my save_and_open_page calls return an html page without styling. It has the style sheets links properly at the top of the page

2条回答
  •  遇见更好的自我
    2021-02-12 15:14

    Try adding the following to your gem file

    group :test do
      gem "capybara"
      gem "launchy"
    end
    

    save_and_open_page won't work without this I don't believe.

    -- Updated --

    I've tested this for you and when I used the save and open method, I get the same error. In my set up, this is because my page is referencing:

    
    

    This happens in Firefox, Chrome and Safari. According to the inspector, none of the files are found.

    I haven't looked into this in too much detail and don't have an answer why it's not working. However there are a number of people struggling with this also:

    https://github.com/jnicklas/capybara/issues/485

    And, a bit more information about capybara and asset precompilation:

    https://github.com/jnicklas/capybara/pull/609

    And what might be a fix here:

    https://groups.google.com/forum/#!msg/ruby-capybara/SBCor8UUj7w/hv97EgUQ1P4J

    However, if you just want to see your page you could try this: delete scrap save_and_open_page and change your tests to use javascript. This way, my pages open fine.

     require 'spec_helper'
    
     describe "Foo" do
       it "should fail if Bar is lactose intolerant", :js => true do
         # .....
       end
     end
    

    Try that and let me know if that helps.


    response (From Taylored Web Sites):

    I see the page for a few seconds, then it goes away. Is there a way for the browser window to not close?

提交回复
热议问题