teampoltergeist / poltergeist

A PhantomJS driver for Capybara
MIT License
2.5k stars 415 forks source link

TypeError: 'undefined' is not an object (evaluating 'rect.top') #130

Closed bettysteger closed 12 years ago

bettysteger commented 12 years ago

i am getting the following error

  Failure/Error: click_button "Sign up"
    Capybara::Poltergeist::JavascriptError:
      One or more errors were raised in the Javascript code on the page:

      TypeError: 'undefined' is not an object (evaluating 'rect.top')

the problem was that i have required something in a css file that didn't exist: *= require_tree ./landing i got an error when going to localhost:3000: require_tree argument must be a directory (Sprockets::ArgumentError)

so i have solved this problem by added the right directory... but i got in the wrong direction with that error message!

tvdeyen commented 12 years ago

I have the same issue, but only on Travis CI with Ruby Enterprise Edition:

http://travis-ci.org/#!/magiclabs/alchemy_cms/jobs/2123243/L1069

The method that causes this error is always the same:

def login_into_alchemy
  visit '/alchemy/admin/login'
  fill_in('alchemy_user_session_login', :with => 'jdoe')
  fill_in('alchemy_user_session_password', :with => 's3cr3t')
  click_on('Login')
end

So nothing fancy in here. You can visit the page yourself: http://demo.alchemy-cms.com/admin/login

The strange thing about it is, that on my local machine all tests pass, even with REE.

tvdeyen commented 12 years ago

Just put a sleep 1 between visit and fill_in:

http://travis-ci.org/#!/magiclabs/alchemy_cms/jobs/2123618

As you can see this does not help. So no timing issue. What else?

tvdeyen commented 12 years ago

And this build contains a debug log:

http://travis-ci.org/#!/magiclabs/alchemy_cms/jobs/2134392/L633

ywen commented 12 years ago

I have the same issue. On Mac it's all good. Just not on a ubuntu box. :(

drnic commented 12 years ago

I have this issue on my mac.

$ phantomjs -v   
1.6.1
$ which phantomjs
/usr/local/bin/phantomjs

In my features/support/env.rb


require 'capybara/poltergeist'
Capybara.register_driver :poltergeist do |app|
  Capybara::Poltergeist::Driver.new(app, 
    timeout: 5, debug: true, phantomjs: "/usr/local/bin/phantomjs")
end
Capybara.javascript_driver = :poltergeist
jonleighton commented 12 years ago

@tvdeyen @ywen @drnic hi guys, please see the above commit I just added. I'm not sure if this will actually solve your problems, but it will at least prevent the JS throwing a TypeError. It also means that the Capybara retry mechanism will work properly. Please give it a try and let me know how it goes?

ywen commented 12 years ago

Just make sure this is in the master branch correct? I will give it a try maybe tomorrow. Thanks!

jonleighton commented 12 years ago

Yes, master branch.

ywen commented 12 years ago

Yay, the error is gone! Thanks

andyw8 commented 12 years ago

I'm having this problem on master. The test passes when using the Chrome driver, but with Poltergeist it fails with:

One or more errors were raised in the Javascript code on the page:

      TypeError: 'undefined' is not an object (evaluating 'rect.top')
          at /Users/andyw/.rvm/gems/ruby-1.9.3-p194/gems/poltergeist-0.7.0/lib/capybara/poltergeist/client/compiled/agent.js:311
          at /Users/andyw/.rvm/gems/ruby-1.9.3-p194/gems/poltergeist-0.7.0/lib/capybara/poltergeist/client/compiled/agent.js:99
          at /Users/andyw/.rvm/gems/ruby-1.9.3-p194/gems/poltergeist-0.7.0/lib/capybara/poltergeist/client/compiled/agent.js:15
          at phantomjs://webpage.evaluate():2
          at phantomjs://webpage.evaluate():3
          at phantomjs://webpage.evaluate():3
          at phantomjs://webpage.evaluate():3
jonleighton commented 12 years ago

@andyw8 from that stack trace, it doesn't look like you're using master.

andyw8 commented 12 years ago

Ah, my mistake. I'd specified the ref in the Gemfile but not the git repo so the ref was being ignored. All passing now.

nchandratre commented 11 years ago

@andyw8 I am facing same problem. Test fails with Poltergeist. How to resolve?

jonleighton commented 11 years ago

@nchandratre please post a new issue with details about your problem