-
-
Notifications
You must be signed in to change notification settings - Fork 426
page.body empty after first spec on qt5.4 #724
Comments
Hey @Intrepidd. This actually looks related to #713. Adding a random query string to the URL results in the expected behavior:
Note that I added some extra debugging locally to identify the content-type. Without the randomness in the query string, the content-type is empty. I'm not sure if this is a Rails or webkit bug. However, I've seen unexpected cache behavior in the browser as well. This makes me think Rails may be misbehaving. |
Disabling the browser cache resolves this issue. I need to write some additional tests but I'll commit a fix for this soon. Thanks! |
Fixed in master. Thanks for reproducing this! |
Yes ! This fixed so many weird bugs in my specs |
Would this be possible to release capybara-webkit 1.4.2 ? It would help a lot as bundler deals weirdly with native extensions when using git |
It's me again ! Have you considered releasing 1.4.2 with this fix ? |
Yes! There is another pull request that I'm wrapping up at the moment, but once that's out we'll release this. Thanks for your patience. |
capybara-webkit 1.5.0 has been released, which includes the fix for this issue. |
Thank you for your work ! This tool is becoming greater and greater. |
@mhoran I'm still seeing this issue on 1.5.1 for remote sites. How do disable the cache for webkit? |
@jaredjenkins there's an update to this, but it's currently unreleased. Can you try installing the |
@jferris and @mhoran - As @jaredjenkins described, I'm still seeing this issue for remote sites (in particular lvh.me which uses the localhost loopback) Any thoughts on if this is still a legitimate issue? Here's an example. Thanks! This is an app that makes heavy use of subdomains (which are managed by the apartment gem). The request invite page is just a simple form with a name field, email field, and a submit button.
The
This fails for the JS test
|
I'm thinking this is likely related to #841 (which is in turn related to this original issue.) However, we added a compatibility spec against Selenium and to the best of my knowledge, our behavior is the same. |
@mhoran - Thanks for the quick response. Wanted to clarify the following -
That sounds like If so is there any fix/workaround for the above behavior? If I remove any dependence on subdomains and just test with the default, all errors go away, so I suspect it's definitely due to the remote host. Thanks again. |
Hey @abhchand (apologies for the late response). You are correct; we have not noted any differences between capybara-webkit and Selenium when it comes to caching behavior. One workaround would be to add a "cache-bust" query parameter to the URL. This should force a reload, but is not ideal. You may also be able to visit the URL, and I suspect (based on prior experience) that the second attempt may load as expected. |
This bug still exists. I'm using a Could you please reopen it? Reduction: https://github.com/adamhooper/capybara-webkit-bug-724 |
It seems, in my reduction at least, that the issue is that Capybara-Webkit is sending IMO this is still a bug. Considering its purpose, class AvoidRackStatic304Responses
def initialize(app)
@app = app
end
def call(env)
env['HTTP_IF_MODIFIED_SINCE'] = nil
@app.call(env)
end
end Then use it in your Rack config, above your use(AvoidRackStatic304Responses) # https://github.com/thoughtbot/capybara-webkit/issues/724 (As you can see, I'm not using Rails.) |
Thanks for digging into this. I was pretty sure it had to do with If-Modified-Since, and we previously attempted to disable the cache because of that. However, our previous approach didn't work, and introduced other bugs. Perhaps we can find another way. |
To me, the most obvious fix is to create a new browser instance per test. I'm not sure of whether a 304 response ought to have an empty body or not, but I am sure that the clicks in one test shouldn't affect the next test. Of course, that'll make things slow. Slow is better than wrong, though. After that come hacky speedups, like the obligatory |
We create new instances of It may be possible to use |
Shouldn't optimization come second, after implementation? |
It looks like |
It's also possible the |
Restarting the process may be so slow that implementation becomes a moot point, because nobody would use the driver. Unfortunately, it's difficult to focus on 100% accuracy in a virtual browser, because the surface area is so huge and it's not always completely clear what "correct" means in various scenarios. The best we've been able to shoot for is reasonable accuracy and reasonable speed.
I think we actually decided not to clear the cache in between tests, because it caused Rails to build assets for every scenario or something?
Crazy idea: would we salt the etag or something with a unique ID per test run to make sure caches are discarded for new sessions? I'll try to put together some more unit tests related to caching this week and see where it goes from there. |
We had previously disabled the cache completely, which resulted in issues between steps in a single test run. However, I don't think I ever found a way to only clear the cache at the end of the test (on reset), which should have been fine. With a name like
I'm not sure salting the etag would resolve the issue. The real trouble is when the browser is reset, the "Last-Modified" time is cached by the
The repro provided by @adamhooper works great. |
I am coming here from #841. I can confirm from my own logs that capybara-webkit is caching redirects between cucumber scenarios:
Cleaned webkit_debug output:
Here we can see that CurrentUrl changed to test_for_redirects without the browser making a request. The previous scenarios have returned a 302 for the /foobar.
|
Hi guys, thanks for keeping the conversations going here. Does it make sense to provide an option to disable browser caching entirely? In our specs, we sometimes want to test if it runs as expected without browser caching. Currently, I have to roll back to before aeafb90, which is 1.5.2. Thanks! |
Seems like even on 1.5.2 with cache entirely disabled, it still caches requests unreliably with Qt5 (sometimes it does, sometimes not). I will see if I can reproduce this issue, but wonder if this is caching behavior is just unreliable with Qt5? Thanks! |
QtWebKit definitely has some internal caches that we're not clearing. We haven't figured out yet if those are at the instance level, class level, or process level. We're also not sure if there are public methods for clearing them, or if the caches are within the Qt, QtWebKit, or WebKit layers. It's odd that they cache inconsistently. It could have something to do with the request order or an async issue in how we clear our caches.
I've hard a hard time figuring out the caching behavior, but it seems consistent whenever I identify a particular behavior. |
Thanks, @jferris. It's good to know the caching behavior is consistent. I think we can get around with it in the specs given its consistency. Appreciated your response! 👍 |
We just figured out a workaround for this issue this morning (for rails). We have a single focused test run that is getting a spurious 304s due to etag headers (not last-modified). Adding the following line to # inside of your config block
config.middleware.delete Rack::ETag |
I'm experiencing something weird.
With qt 5.4 (
brew install qt5
), when I run several specs,page.body
will be empty in all specs expect the first one. Some assertions will pass though, for exampleexpect(page).to have_css('body#test')
I'm also seing some test fail when they are ran with other tests but not when run alone.
Not seing this behavior with qt 4.8 (
brew install qt
)Here's a repo with a reproducible example : https://github.com/Intrepidd/capykit
just
bundle
and run the specs, they displaypage.body.size
.With Qt5.4 you'll see something like
Whereas on qt4.8 the (expected) result is :
The text was updated successfully, but these errors were encountered: