Giter Club home page Giter Club logo

Comments (10)

jarrett avatar jarrett commented on August 19, 2024 3

Short answer: try deleting public/assets.

Longer answer:

I got this error today calling page.execute_script from Capybara. I'm serving jQuery from the asset pipeline, not from a CDN. After some investigation, I found:

  • Calling sleep 30 before page.execute_script made no difference.
  • bundle update made no difference.
  • save_and_open_page showed that the JS was included from the <head> element.
  • The jQuery code was included in compiled public/assets/application-[hash].js.
  • However, recent changes to custom JavaScript files were not included in the compiled JS.

Based on that last observation, I guessed that there was a weird interaction between Poltergeist and precompiled assets. On this hunch, I deleted public/assets. That resolved the issue.

from poltergeist.

twalpole avatar twalpole commented on August 19, 2024 2

@jonatasrancan Because PhantomJS (used by Poltergeist) is basically equivalent to 7 year old version of Safari, and in dev mode you`re using a real browser. It’s time to move to a more modern Capybara driver.

from poltergeist.

jonleighton avatar jonleighton commented on August 19, 2024

Does it work with other drivers? (e.g. selenium or capybara-webkit)

from poltergeist.

bias avatar bias commented on August 19, 2024

Nope, same issue with capybara-webkit. Hence, it could just be a config issue with the rails test env or cucumber env but I've looked into doing whatever I could with these with no luck.

Do you know if anyone uses jQuery with poltergeist?

How would I even start figuring out how to solve this?

from poltergeist.

jonleighton avatar jonleighton commented on August 19, 2024

Okay, this doesn't look like an actual bug in Poltergeist. It sounds like you need some help configuring your test environment, so I suggest you post to a help forum like Stack Overflow.

from poltergeist.

robd avatar robd commented on August 19, 2024

I found this was a problem with cdn loaded versions of jquery from ajax.googleapis.com or code.jquery.com. It was fixed when I downloaded and served the jquery files as part of my app.

from poltergeist.

sethers avatar sethers commented on August 19, 2024

I ran into this same issue recently. The problem was we were pulling assets from a CDN (Amazon Cloudfront). Amazon recently disabled SSLV3. Poltegeist version 1.5.1 or before uses SSLV3 as its default ssl protocol. As a result, no assets from Amazon cloudfront would load. The easy fix is to set the ssl setting '--ssl-protocol=any' when calling poltergeist. This issue has been resolved in the next version of Poltergeist, that has not yet been released. See Issue 544.

from poltergeist.

jayshepherd avatar jayshepherd commented on August 19, 2024

For me, dropping the https: in the cdn href made the difference. I was having this same issue on Master.

from poltergeist.

rwehresmann avatar rwehresmann commented on August 19, 2024

I'm having the same issue here, and couldn't figure out how to solve yet. I'm loading jquery from gem 'jquery-rails', it works fine when I run the server, but in my feature tests not.

from poltergeist.

jonatasrancan avatar jonatasrancan commented on August 19, 2024

I faced the same problem

Failure/Error: click_on 'Login'

     Capybara::Poltergeist::JavascriptError:
       One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details).

       ReferenceError: Can't find variable: $

Only on the test environment.
And after some investigation, I found out that trying to pass a default value on a param, was causing the problem.

I had this function:

drawInput: function(inputName, inputClass, value, rowIndex, columnIndex, readonly = false)

And the problem was the readonly = false.
After changing it to drawInput: function(inputName, inputClass, value, rowIndex, columnIndex, readonly), the tests started working without problem.

I know that default value on function params exist since ES6/ES2015, but what I don't get is why that worked on development and on tests it failed.

from poltergeist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.