Code Monkey home page Code Monkey logo

poltergeist's People

Contributors

afn avatar ajedi32 avatar amatsuda avatar aprescott avatar beanieboi avatar botandrose-machine avatar calasyr avatar dbrans avatar dnesteryuk avatar gongo avatar jbaudanza avatar jcoglan avatar jhawthorn avatar jonleighton avatar jonrowe avatar laserlemon avatar mjtko avatar mrdg avatar pedrocarrico avatar plehoux avatar route avatar s0meone avatar sferik avatar simi avatar sobrinho avatar thedelchop avatar twalpole avatar unmanbearpig avatar yaauie avatar yob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

poltergeist's Issues

Not loading jQuery

I'm at a loss how to get my jQuery loaded into my cucumber test with poltergeist.

This is the type of error I'm seeing

      ReferenceError: Can't find variable: jQuery

Is app/assets/javascripts/application.js somehow not being loaded?

Someone else has a similar issue posted on stackoverflow with webkit, but they haven't had any answers and the question has been up for half a year.

Index elements by page id as well as node id

Consider the following:

visit '/foo'
el = find('#bar')
page.execute_script "window.location = 'http://example.com/'"
el.text

The call to el.text will still think we're on the same page, resulting in a ReferenceError in the Javascript code. We should handle this by indexing elements by a page id as well as a node id.

Error with page.driver.debug

I have an issue using page.driver.debug in my tests.

I double-checked if I am providing an inspector: true key-value pair to the test. Here's what it looks like (though not sure how this might help):

scenario 'User removes product from favorites', js: true, inspector: true do
  favorite = Factory :favorite, user: user

  visit("/products/#{favorite.variant.permalink}/")

  click_link 'Remove from favorites'

  page.should     have_content('Add to favorites')
  page.should_not have_content('Remove from favorites')
end

And here's an error:

Failure/Error: page.driver.debug
     NoMethodError:
       private method `open' called for nil:NilClass
     # /home/gmile/.rvm/gems/ruby-1.9.3-p125@christ/gems/poltergeist-0.6.0/lib/capybara/poltergeist/driver.rb:107:in `debug'
     # ... the rest of stack trace is related to rspec and app specific files ...

I will be providing any additional info if needed.

P.S. just in case this might be a relevant info: I am using Ubuntu 11.10 and phantomjs 1.5

Run phantomjs only once

Is there a possibility to run phantomjs only once during a the whole test suite? I suppose that'd speed up test suites a lot. If it is possible, it is should be considered to only cleane up browser state between tests instead of re-running browser over and over again.

Handle elements that have gone

A capybara query like:

page.should have_no_selector('#foo', :text => 'bar')

Causes capybara to:

  1. Find the element
  2. Get its text

If the element is removed from the DOM between 1 and 2, it will cause an error.

We should handle this, and other similar scenarios, as gracefully as possible.

click_link and click_button just do nothing

Hi,
I'm currently trying out poltergeist, but I can't seem to get it to work correctly. I just used it to run a few request specs which pass when using the standard :rack_test-driver, but all of these scenarios failed. It seems that click_link and click_button don't work. After calling click_link the site just does not change. The debug-trace is as follows:

{"name"=>"visit", "args"=>["http://127.0.0.1:57696/"]}
{"response"=>"success"}
{"name"=>"find", "args"=>[".//a[./@href][(((./@id = 'Anmelden' or normalize-space(string(.)) = 'Anmelden') or ./@title = 'Anmelden') or .//img[./@alt = 'Anmelden'])]", nil]}
{"response"=>[0]}
{"name"=>"visible", "args"=>[0]}
{"response"=>true}
{"name"=>"click", "args"=>[0]}
{"response"=>true}

However, fill_in for example works just fine.

I also cloned the poltergeist repository and ran the tests. I have 15 failures, all of them have to do with Capybara::Session. I don't know if this is related to this issue in any way.

My environment is the following:

Mac OS X 10.6.8
PhantomJS 1.4.1 (installed the pre-built static binary)
poltergeist (0.2.0)
capybara (1.1.2)

Thanks!

Problems with text fields enhanced by TinyMCE

Hi, me again ;-)
I'm having problems when I'm trying to fill_in a text field which is enhanced by the TinyMCE rich text editor. It just remains empty.
The thing is that the text field is irrelevant for the test case, it just prevents a validation from passing. Maybe there is a workaround which can be used?

Thanks for your support!
Fabian

Propagate javascript errors

If a Javascript error is raised on the page, that should be propagated to Capybara as an exception. Maybe. Need to think about this and look into whether it's possible to provide the backtrace.

set default browser size

Howdy, thanks for poltergeist! I love it. Faster and less ceremony than capybara-webkit.

I've have some tests that require the screen size to be larger than the default 1024x768, but after digging through the source and the phantom.js docs, I haven't been able to figure out a way to set this once. Instead, I've had to monkeypatch capybara to perform a page.driver.resize call after every single click_link, click_button, visit, etc. Ick.

Any ideas?

Hanging at socket read

Hi,

It seems to hang for me at the point of calling socket.read on line 116 of web_socket_server (https://github.com/jonleighton/poltergeist/blob/master/lib/capybara/poltergeist/web_socket_server.rb#L116)

Phantomjs is installed and working correctly - I am able to do the quickstart exercises (http://code.google.com/p/phantomjs/wiki/QuickStart) with no probs....

I clone the repo and ran the tests in an effort to diagnose the issue - the tests hang as well one test in. At this stage, 3 instances of phantomjs hav been opened....

A colleague of mine runs the same code with no issue, the only obvious difference is os version. We both use the latest phantomjs homebrew package. He's using Lion 10.7.3 - Im on Snow Leopard 10.6.8.)

Crashes with TTF fonts on OS X

https://gist.github.com/2405155

I have a simple feature (see Gist) and when I run the test I get the error randomly (some times in one Scenario and other in another) . In the Gist example, if I run the failing test again, the tes pass correctly.

uname -a => Linux jarandapc 3.0.6-gentoo #2 SMP PREEMPT Wed Nov 9 21:42:08 CET 2011 x86_64 Intel(R) Pentium(R) CPU G860 @ 3.00GHz GenuineIntel GNU/Linux

Any idea?

`page.should have_disabled_field 'Selector'` is not working

field = page.find_field("Bairro")

puts field.inspect
puts field[:disabled].inspect                                                                                                     

page.should have_disabled_field 'Bairro'

output:

#<Capybara::Element tag="input">
"disabled"

1) Addresses fetch city and state from neighborhood
     Failure/Error: page.should have_disabled_field 'Bairro'
       expected "Logradouro * Número Bloco Sala/Apartamento Bairro * CEP * Complemento Condomínio Loteamento Distrito Cidade Estado" to have disabled field "Bairro"

field[:disabled] returns "disabled" but matcher do not works.

Note: it's works on selenium and rack-test :)

Problem with ?submitting a form?

I just gave poltergeist a try and I'm pretty excited.
This one is a bit harder to reproduce and I'm still trying to come up with a minimal exception.
I tried to test a Drupal Commons installation (code over here).

What works on selenium, akephalos, capybara-webkit seems to not do anything on poltergeist.

visit("/admin/user/user/create")
  within('form#user-register') do
    page.fill_in 'edit-name', :with => username
    page.fill_in 'edit-mail', :with => "mail#{rand(10000)}@example.com"
    page.fill_in 'edit-pass-pass1', :with => password
    page.fill_in 'edit-pass-pass2', :with => password
    page.fill_in 'edit-profile-name', :with => "John"
    page.fill_in 'edit-profile-last-name', :with => "Doe"
  end
  click_button('Create new account')
  page.find("div.messages.status").text.should include('Created a new user account')

This crashes because it can't seem to find the div.messages.status and the user doesn't actually seem to get created. I can't get the driver to take a proper screenshot, it only seems to capture a part of the page ( example: example )

Here's the debug output:

{"args"=>["http://development.local/admin/user/user/create"], "name"=>"visit"}
{"response"=>"success"}
{"args"=>[".//form[@id = 'user-register']", nil], "name"=>"find"}
{"response"=>[0]}
{"args"=>[0], "name"=>"visible"}
{"response"=>true}
{"args"=>[".//*[self::input | self::textarea][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'radio' or ./@type = 'checkbox' or ./@type = 'hidden' or ./@type = 'file')][((./@id = 'edit-name' or ./@name = 'edit-name') or ./@id = //label[normalize-space(string(.)) = 'edit-name']/@for)] | .//label[normalize-space(string(.)) = 'edit-name']//.//*[self::input | self::textarea][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'radio' or ./@type = 'checkbox' or ./@type = 'hidden' or ./@type = 'file')]", 0], "name"=>"find"}
{"response"=>[1]}
{"args"=>[1], "name"=>"visible"}
{"response"=>true}
{"args"=>[1], "name"=>"tag_name"}
{"response"=>"INPUT"}
{"args"=>[1, :type], "name"=>"attribute"}
{"response"=>"text"}
{"args"=>[1, "derpington"], "name"=>"set"}
{"response"=>true}
{"args"=>[".//*[self::input | self::textarea][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'radio' or ./@type = 'checkbox' or ./@type = 'hidden' or ./@type = 'file')][((./@id = 'edit-mail' or ./@name = 'edit-mail') or ./@id = //label[normalize-space(string(.)) = 'edit-mail']/@for)] | .//label[normalize-space(string(.)) = 'edit-mail']//.//*[self::input | self::textarea][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'radio' or ./@type = 'checkbox' or ./@type = 'hidden' or ./@type = 'file')]", 0], "name"=>"find"}
{"response"=>[2]}
{"args"=>[2], "name"=>"visible"}
{"response"=>true}
{"args"=>[2], "name"=>"tag_name"}
{"response"=>"INPUT"}
{"args"=>[2, :type], "name"=>"attribute"}
{"response"=>"text"}
{"args"=>[2, "[email protected]"], "name"=>"set"}
{"response"=>true}
{"args"=>[".//*[self::input | self::textarea][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'radio' or ./@type = 'checkbox' or ./@type = 'hidden' or ./@type = 'file')][((./@id = 'edit-pass-pass1' or ./@name = 'edit-pass-pass1') or ./@id = //label[normalize-space(string(.)) = 'edit-pass-pass1']/@for)] | .//label[normalize-space(string(.)) = 'edit-pass-pass1']//.//*[self::input | self::textarea][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'radio' or ./@type = 'checkbox' or ./@type = 'hidden' or ./@type = 'file')]", 0], "name"=>"find"}
{"response"=>[3]}
{"args"=>[3], "name"=>"visible"}
{"response"=>true}
{"args"=>[3], "name"=>"tag_name"}
{"response"=>"INPUT"}
{"args"=>[3, :type], "name"=>"attribute"}
{"response"=>"password"}
{"args"=>[3, "samplepass"], "name"=>"set"}
{"response"=>true}
{"args"=>[".//*[self::input | self::textarea][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'radio' or ./@type = 'checkbox' or ./@type = 'hidden' or ./@type = 'file')][((./@id = 'edit-pass-pass2' or ./@name = 'edit-pass-pass2') or ./@id = //label[normalize-space(string(.)) = 'edit-pass-pass2']/@for)] | .//label[normalize-space(string(.)) = 'edit-pass-pass2']//.//*[self::input | self::textarea][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'radio' or ./@type = 'checkbox' or ./@type = 'hidden' or ./@type = 'file')]", 0], "name"=>"find"}
{"response"=>[4]}
{"args"=>[4], "name"=>"visible"}
{"response"=>true}
{"args"=>[4], "name"=>"tag_name"}
{"response"=>"INPUT"}
{"args"=>[4, :type], "name"=>"attribute"}
{"response"=>"password"}
{"args"=>[4, "samplepass"], "name"=>"set"}
{"response"=>true}
{"args"=>[".//*[self::input | self::textarea][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'radio' or ./@type = 'checkbox' or ./@type = 'hidden' or ./@type = 'file')][((./@id = 'edit-profile-name' or ./@name = 'edit-profile-name') or ./@id = //label[normalize-space(string(.)) = 'edit-profile-name']/@for)] | .//label[normalize-space(string(.)) = 'edit-profile-name']//.//*[self::input | self::textarea][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'radio' or ./@type = 'checkbox' or ./@type = 'hidden' or ./@type = 'file')]", 0], "name"=>"find"}
{"response"=>[5]}
{"args"=>[5], "name"=>"visible"}
{"response"=>true}
{"args"=>[5], "name"=>"tag_name"}
{"response"=>"INPUT"}
{"args"=>[5, :type], "name"=>"attribute"}
{"response"=>"text"}
{"args"=>[5, "John"], "name"=>"set"}
{"response"=>true}
{"args"=>[".//*[self::input | self::textarea][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'radio' or ./@type = 'checkbox' or ./@type = 'hidden' or ./@type = 'file')][((./@id = 'edit-profile-last-name' or ./@name = 'edit-profile-last-name') or ./@id = //label[normalize-space(string(.)) = 'edit-profile-last-name']/@for)] | .//label[normalize-space(string(.)) = 'edit-profile-last-name']//.//*[self::input | self::textarea][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'radio' or ./@type = 'checkbox' or ./@type = 'hidden' or ./@type = 'file')]", 0], "name"=>"find"}
{"response"=>[6]}
{"args"=>[6], "name"=>"visible"}
{"response"=>true}
{"args"=>[6], "name"=>"tag_name"}
{"response"=>"INPUT"}
{"args"=>[6, :type], "name"=>"attribute"}
{"response"=>"text"}
{"args"=>[6, "Doe"], "name"=>"set"}
{"response"=>true}
{"args"=>[".//input[./@type = 'submit' or ./@type = 'image' or ./@type = 'button'][((./@id = 'Create new account' or ./@value = 'Create new account') or ./@title = 'Create new account')] | .//input[./@type = 'image'][./@alt = 'Create new account'] | .//button[(((./@id = 'Create new account' or ./@value = 'Create new account') or normalize-space(string(.)) = 'Create new account') or ./@title = 'Create new account')] | .//input[./@type = 'image'][./@alt = 'Create new account']", nil], "name"=>"find"}
{"response"=>[7]}
{"args"=>[7], "name"=>"visible"}
{"response"=>true}
{"args"=>[7], "name"=>"click"}
{"response"=>true}
{"args"=>["/Users/mseeger/Desktop/derp.png"], "name"=>"render"}
Oct 30 09:42:04 macbookpro.box phantomjs[8131] <Error>: CGContextSetShouldAntialias: invalid context 0x0
Oct 30 09:42:04 macbookpro.box phantomjs[8131] <Error>: CGContextSetShouldSmoothFonts: invalid context 0x0
Oct 30 09:42:04 macbookpro.box phantomjs[8131] <Error>: CGContextSetFillColorSpace: invalid context 0x0
Oct 30 09:42:04 macbookpro.box phantomjs[8131] <Error>: CGContextSetFillColor: invalid context 0x0
{"response"=>true}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}
{"args"=>[".//div[contains(concat(' ', @class, ' '), ' messages ') and contains(concat(' ', @class, ' '), ' status ')]", nil], "name"=>"find"}
{"response"=>[]}

Resizing necessary?

I am trying to run a few of my current tests using poltergeist and most of them actually work great.
Something that doesn't properly work is large forms that don't seem to properly fit into the default 1024x768 "window" that poltergeist uses.

The tests fail, mostly because a click on e.g. a submit button at the bottom of a page seems to hit something a bunch of pixels higher up. I can fix this by just calling page.driver.resize(1600, 1200)

Is there any disadvantage when just running on a large resolution? Memory consumption?

Can not access multiple browser windows like selenium can.

I'm trying to use poltergeist on Refinery CMS which has the following error:

Failure/Error: new_window = page.driver.browser.window_handles.last
     NoMethodError:
       undefined method `window_handles' for #<Capybara::Poltergeist::Browser:0x007fb41ad5d100>

This comes from here:
https://github.com/resolve/refinerycms/blob/master/pages/spec/requests/refinery/admin/pages_spec.rb#L155-L167

Basically we have a "preview page" functionality which opens with target='_blank' (new window).

This is not a fault of Poltergeist but instead a feature request which, if I get a chance, I'll tackle. However, I'm more than happy for someone else to ;-)

Thanks!

ThreadError

I got the following error when i tried out poltergeist.

 @javascript
  Scenario: Update a space                                          # features/add_update_spaces.feature:59
    Given I am a broker                                             # features/step_definitions/common_steps.rb:3
    And I have a space                                              # features/step_definitions/common_steps.rb:36
{"name"=>"visit", "args"=>["http://127.0.0.1:53891/backdoor/347"]}
    And I am logged in                                              # features/step_definitions/authentication_steps.rb:19
      killed thread (ThreadError)
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/poltergeist-0.2.0/lib/capybara/poltergeist/server_manager.rb:75:in `run'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/poltergeist-0.2.0/lib/capybara/poltergeist/server_manager.rb:75:in `thread_execute'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/poltergeist-0.2.0/lib/capybara/poltergeist/server_manager.rb:51:in `block in send'
      /Users/karl/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/timeout.rb:58:in `timeout'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/poltergeist-0.2.0/lib/capybara/poltergeist/server_manager.rb:46:in `send'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/poltergeist-0.2.0/lib/capybara/poltergeist/server.rb:19:in `send'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/poltergeist-0.2.0/lib/capybara/poltergeist/browser.rb:124:in `command'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/poltergeist-0.2.0/lib/capybara/poltergeist/browser.rb:19:in `visit'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/poltergeist-0.2.0/lib/capybara/poltergeist/driver.rb:31:in `visit'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/capybara-1.1.2/lib/capybara/session.rb:157:in `visit'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/capybara-1.1.2/lib/capybara/dsl.rb:161:in `visit'
      /Users/karl/workspace/viewthespace/features/step_definitions/authentication_steps.rb:20:in `block in <top (required)>'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/cucumber-1.1.3/lib/cucumber/core_ext/instance_exec.rb:48:in `instance_exec'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/cucumber-1.1.3/lib/cucumber/core_ext/instance_exec.rb:48:in `block in cucumber_instance_exec'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/cucumber-1.1.3/lib/cucumber/core_ext/instance_exec.rb:69:in `cucumber_run_with_backtrace_filtering'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/cucumber-1.1.3/lib/cucumber/core_ext/instance_exec.rb:36:in `cucumber_instance_exec'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/cucumber-1.1.3/lib/cucumber/rb_support/rb_step_definition.rb:62:in `invoke'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/cucumber-1.1.3/lib/cucumber/step_match.rb:25:in `invoke'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/cucumber-1.1.3/lib/cucumber/ast/step_invocation.rb:59:in `invoke'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/cucumber-1.1.3/lib/cucumber/ast/step_invocation.rb:38:in `accept'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/cucumber-1.1.3/lib/cucumber/ast/tree_walker.rb:99:in `block in visit_step'
      /Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/cucumber-1.1.3/lib/cucumber/ast/tree_walker.rb:163:in `broadcast'

I am using:

osx 10.6.8
ruby 1.9.2p290
capybara 1.1.2
rails 3.1.3
phantomjs 1.4.1

thx

Just hangs with cucumber

So I have this in my support/env.rb file:

  require 'capybara/poltergeist'
  Capybara.register_driver :poltergeist do |app|
    Capybara::Poltergeist::Driver.new(app, timeout: 5, debug: true)
  end
  Capybara.javascript_driver = :poltergeist

I have this feature:

@javascript @focus
Feature: Claim Creation
  Background: It must create the needed records and then visit the new claim page
    Given the following users exist:
      | Full Name    | Role               | Company        |
      | The Admin    | Name: admin        | Name: ACD, INC |
      | Client Staff | Name: client_staff | Name: ABC, LLC |
    And the following carrier exists:
      | Name       |
      | Fixit, Inc |
    And I visit the new claim page

  Scenario: Sucessfully create new claim
    Given I see the breadcrumbs "New Claim", "Enter Info" and "Add Files"
    And "Enter Info" is the current breadcrumb

These steps:

Then /^I see the breadcrumbs (.+)$/ do |crumbs|
  # New Claim, Enter Info and Add Files
  within '#menu' do
    crumbs.gsub(/\"/, '').gsub(/(,|\sand)/, ' -').split('-').each do |crumb|
      page.should have_content crumb.strip
    end
  end
end

When /^"([^"]*)" is the current breadcrumb$/ do |breadcrumb|
  # //li/.. is like calling .parent('li') in jquery
  page.find_link('Enter Info').find(:xpath,"//li/..").should have_css '.active'
end

But all I get is this, it just freezes there and does nothing:

Going to http://127.0.0.1:53486/claims/new loads the page just fine....

Any ideas?

Detect phantomjs version from Ruby

Currently we're checking the phantomjs version from Javascript when it's launched. Might be better to just run phantomjs --version before launching it and throw a ruby exception.

Browser is not updating the page when a script change its state

I wrote the following scenario only to illustrate the bug.

scenario 'show the results for one company', :js => true do
  visit root_path

  body = page.driver.body
  current_url = page.driver.current_url

  page.find('#search').set("Foo")
  page.execute_script("$('#search-form').submit();")

  # the URL should have the GET params for the search
  page.driver.current_url.should_not == current_url

  # And the body should return a different result set of companies
  page.driver.body.should_not == body
end

Encoding problems with 1.8?

Not sure 1.8 is a targeted plattform:

And I fill in "edit-choice-0-chtext" with "Yes you can!"          # features/step_definitions/common_steps.rb:63
And I fill in "edit-choice-1-chtext" with "No way José!"          # features/step_definitions/common_steps.rb:63
And I press "Save"                                                # features/step_definitions/common_steps.rb:67
Then I should see a headline with "Can i haz cheeseburger?" in it # features/step_definitions/content_creation_steps.rb:28
And I should see the poll option "No way José"                    # features/step_definitions/poll_steps.rb:1
  expected xpath "//div[@class='poll']/.//input[@type='radio' and text()='No way Jos\303\251']" to return something (RSpec::Expectations::ExpectationNotMetError)
  ./features/step_definitions/poll_steps.rb:2:in `/^I should see the poll option "([^"]*)"$/'
  features/polls.feature:17:in `And I should see the poll option "No way José"'

Not sure if it's something I am doing wrong or some missing encoding call along the way

Works in selenium + akephalos2

Missing faye-websocket gem on bundle install

I got this when i tried to install poltergeist today:

karl:viewthespace karl$ bundle install
Updating git://github.com/jonleighton/poltergeist.git
Could not find gem 'sfl (~> 2.0) ruby', which is required by gem 'poltergeist (>= 0) ruby', in any of the sources.

thx!

Raising Capybara::Poltergeist::ClickFailed even when the click is possible

Hi @jonleighton,

I'm receiving that error:

1) ContributionImprovements create a new contribution_improvement
     Failure/Error: within_tab 'Itens de Custo' do
     Capybara::Poltergeist::ClickFailed:
       Click at co-ordinates [234.5, -247] failed. Poltergeist detected another element with CSS selector '' at this position. It may be overlapping the element you are trying to click.
     # ./spec/support/capybara.rb:20:in `click_link'
     # (eval):2:in `click_link'
     # ./spec/support/helpers.rb:87:in `block in within_tab'
     # ./spec/support/helpers.rb:86:in `within_tab'
     # ./spec/requests/contribution_improvements_spec.rb:76:in `block (2 levels) in <top (required)>'

  2) ContributionImprovements update an existent contribution_improvement
     Failure/Error: within_tab 'Itens de Custo' do
     Capybara::Poltergeist::ClickFailed:
       Click at co-ordinates [234.5, -247] failed. Poltergeist detected another element with CSS selector '' at this position. It may be overlapping the element you are trying to click.
     # ./spec/support/capybara.rb:20:in `click_link'
     # (eval):2:in `click_link'
     # ./spec/support/helpers.rb:87:in `block in within_tab'
     # ./spec/support/helpers.rb:86:in `within_tab'
     # ./spec/requests/contribution_improvements_spec.rb:194:in `block (2 levels) in <top (required)>'

I can't reproduce that issue in isolation but this is a real issue :P

The failing scenario looks like that:

within_tab 'Itens de Custo' do                                                                                                          
  ...
end

The helper:

def within_tab(locator)
  within ".ui-tabs" do
    click_link locator

    within ".ui-tabs-panel:not(.ui-tabs-hide)" do
      yield 
    end
  end
end

Reducing the complexity:

  1) ContributionImprovements update an existent contribution_improvement
     Failure/Error: click_link 'Itens de Custo'
     Capybara::Poltergeist::ClickFailed:
       Click at co-ordinates [234.5, -247] failed. Poltergeist detected another element with CSS selector '' at this position. It may be overlapping the element you are trying to click.
     # ./spec/support/capybara.rb:20:in `click_link'
     # (eval):2:in `click_link'
     # ./spec/requests/contribution_improvements_spec.rb:194:in `block (2 levels) in <top (required)>'
click_link 'Itens de Custo'

I tried a sleep to check for a strange timeout but didn't work:

sleep 10

click_link 'Itens de Custo'

But, if I render the page, the scenario magically pass!

page.driver.render('/tmp/file.png')

click_link 'Itens de Custo'

It's consistent, all the time I ran these two scenarios, they fail.

All the time I ran with sleep, they also fail.

All the time I ran with page.driver.render, they pass.

I guess this is the useful piece of debug:

{"name"=>"find", "args"=>[".//a[./@href][(((./@id = 'Itens de Custo' or normalize-space(string(.)) = 'Itens de Custo') or ./@title = 'Itens de Custo') or .//img[./@alt = 'Itens de Custo'])]"]}
{"response"=>{"page_id"=>4, "ids"=>[88]}}
{"name"=>"visible", "args"=>[4, 88]}
{"response"=>true}
{"name"=>"visible", "args"=>[4, 88]}
{"response"=>true}
{"name"=>"click", "args"=>[4, 88]}
{"error"=>{"name"=>"Poltergeist.ClickFailed", "args"=>[nil, {"x"=>234.5, "y"=>-247}]}}
{"name"=>"reset", "args"=>[]}
{"response"=>true}

Calling page.render before the click_link:

{"name"=>"render", "args"=>["/tmp/file.png", false]}
{"response"=>true}
{"name"=>"find", "args"=>[".//a[./@href][(((./@id = 'Itens de Custo' or normalize-space(string(.)) = 'Itens de Custo') or ./@title = 'Itens de Custo') or .//img[./@alt = 'Itens de Custo'])]"]}
{"response"=>{"page_id"=>4, "ids"=>[91]}}
{"name"=>"visible", "args"=>[4, 91]}
{"response"=>true}
{"name"=>"visible", "args"=>[4, 91]}
{"response"=>true}
{"name"=>"click", "args"=>[4, 91]}
{"response"=>true}

Note: seems like the position of link changes after calling render.

What you think?

Do you need some information about my application (I can send in private)?

Note: it works fine on selenium and the rendered image is exactly what I expect to see at this moment.

Compute click position in middle of element

Currently we try to click the very top-left pixel of an element. This can cause subtle issues with elements that may have e.g. negative margins etc, which cause the very top-left to be obscured wile the majority of the element is visible. Instead we should more intelligently compute the position of the middle of the element, as this is (presumably) the least likely position to be obscured. This needs to take scroll position into account - e.g. if the middle of the element is off the page, but part of it is on the page, then we should compute the middle position of the part of the element that is on the page.

elementFromPoint doesn't work correctly when html popup is used

We are using DOM popup boxes interface.
document.elementFromPoint return the overlay for every pixel in a popup.
And there is no way to disable the clickTest check.
That's why every test that tries to click a link inside modal popup box is going to fail with something like this:

      Capybara::Poltergeist::ClickFailed:
        Click at co-ordinates [198.5, 631] failed. Poltergeist detected another element with CSS selector 'html body div#fancybox-overlay' at this position. It may be overlapping the element you are trying to click.

Example html page, where I tried to simulate what poltergeist does internally:
https://gist.github.com/2653659
Normally I expect the script inside this page to log link inside popup in colsole, but actually logs an overlay.

Any thought on how this could be fixed or clickTest function could be disabled for particular click call in rspec example.

Events fired on fill_in

I tried switching from capybara-webkit to poltergeist and stumbled over some differences, especially which events get fired.

When I execute fill_in on a textarea, CW fires:

  • focus
  • keydown/keyup for every letter inserted
  • change
  • blur

Poltergeist fires:

  • change

This doesn't really simulate real user interaction and resulted in some broken tests in my suite.

Ability to ignore JavaScript errors

I have an app which utilizes a third-party javascript plugin. Commonly, the plugin may fail somewhere internally from time to time. This fail doesn't affect my app and is usually ignored by browsers like Chrome and Firefox (still posting message about failure to console). Yet phantomjs seems to have an explicit behavior as to these.

Here's an example of failure:

Failure/Error: visit '/admin'
     Capybara::Poltergeist::JavascriptError:
       One or more errors were raised in the Javascript code on the page:

       TypeError: 'undefined' is not a function

         http://127.0.0.1:54868/assets/admin/all.js:27371
         http://127.0.0.1:54868/assets/admin/all.js:1047
         http://127.0.0.1:54868/assets/admin/all.js:1165
         http://127.0.0.1:54868/assets/admin/all.js:436
         http://127.0.0.1:54868/assets/admin/all.js:924

So it is possible using Potergeist to make phantomjs skip raises on those errors, only $stderring them?

Sorry for posting a question-like issue, but I was unable to find a related Google Group :-(

HTTP caching

Look into enabling the cache in PhantomJS and see if this affects test performance.

Client/server get out of sync if when multiple page load events occur

There's a bug in one the ad hoc state machines in browser.coffee that can cause the client and server to get out of sync when multiple page load events happen in response to a click (this probably happens when the server redirects to another URL).

What's happening is that in this case the server sends an additional, spurious "success" response, and the client interprets this as the response to the last command it issued. In my case, it was being interpreted as the response to a "find" command, which led to some very confusing errors!

For the benefit of anyone searching for this, the Ruby error was:

undefined method `map' for "success":String (NoMethodError)

I had some serious bug deja vu when I finally tracked this down. It's basically the same bug as capybara-webkit issue 39 ( thoughtbot/capybara-webkit#39 ).

I made a one-line workaround for this: https://github.com/bwbuchanan/poltergeist/commit/ce13a75801fe7d49b14276e9041b5b63446f4f79

But the real solution is to build a robust state machine around page loading. Ideally, it would handle the case where a redirect happens by waiting until the final page load completes before returning success to the client. This maybe means waiting for a few msec after receiving the onPageLoaded event to see if webkit immediately sends a new onPageLoading event.

PhantomJS quits immediately after startup

I'm running on Windows 7 64bit and it seems like PhantomJS just quits immediately after being spawned in client.rb:

@pid = Kernel.spawn("#{path} #{PHANTOMJS_SCRIPT} #{port}")

It returns a pid, but a process does not exist with that pid, making me assume it is somehow killed after starting up.
Running PhantomJS with an example hello world script works well.

Is there a way to log out PhantomJS errors?

fill_in TypeError: 'undefined' is not a function

Hi,

I seem to be having issue with fill_in running the last version of phantom 1.5.0 and poltergeist (0.6.0).

     Failure/Error: fill_in "subro_line_items_attributes_0_number", with: line_item.number
     Capybara::Poltergeist::BrowserError:
       There was an error inside the PhantomJS portion of Poltergeist:

       TypeError: 'undefined' is not a function

         /Users/cj/Dropbox/sd/acd/redline/vendor/gems/ruby/1.9.1/gems/poltergeist-0.6.0/lib/capybara/poltergeist/client/compiled/agen
t.js:163
         /Users/cj/Dropbox/sd/acd/redline/vendor/gems/ruby/1.9.1/gems/poltergeist-0.6.0/lib/capybara/poltergeist/client/compiled/agen
t.js:68
         /Users/cj/Dropbox/sd/acd/redline/vendor/gems/ruby/1.9.1/gems/poltergeist-0.6.0/lib/capybara/poltergeist/client/compiled/agen
t.js:11
         phantomjs://webpage.evaluate():2
         phantomjs://webpage.evaluate():1
         phantomjs://webpage.evaluate():1
         /Users/cj/Dropbox/sd/acd/redline/vendor/gems/ruby/1.9.1/gems/poltergeist-0.6.0/lib/capybara/poltergeist/client/compiled/web_
page.js:153
         /Users/cj/Dropbox/sd/acd/redline/vendor/gems/ruby/1.9.1/gems/poltergeist-0.6.0/lib/capybara/poltergeist/client/compiled/web_
page.js:182
         /Users/cj/Dropbox/sd/acd/redline/vendor/gems/ruby/1.9.1/gems/poltergeist-0.6.0/lib/capybara/poltergeist/client/compiled/web_
page.js:28
         /Users/cj/Dropbox/sd/acd/redline/vendor/gems/ruby/1.9.1/gems/poltergeist-0.6.0/lib/capybara/poltergeist/client/compiled/node
.js:17
         /Users/cj/Dropbox/sd/acd/redline/vendor/gems/ruby/1.9.1/gems/poltergeist-0.6.0/lib/capybara/poltergeist/client/compiled/brow
ser.js:52
         /Users/cj/Dropbox/sd/acd/redline/vendor/gems/ruby/1.9.1/gems/poltergeist-0.6.0/lib/capybara/poltergeist/client/compiled/brow
ser.js:41
         /Users/cj/Dropbox/sd/acd/redline/vendor/gems/ruby/1.9.1/gems/poltergeist-0.6.0/lib/capybara/poltergeist/client/compiled/brow
ser.js:50
         /Users/cj/Dropbox/sd/acd/redline/vendor/gems/ruby/1.9.1/gems/poltergeist-0.6.0/lib/capybara/poltergeist/client/compiled/brow
ser.js:92
         /Users/cj/Dropbox/sd/acd/redline/vendor/gems/ruby/1.9.1/gems/poltergeist-0.6.0/lib/capybara/poltergeist/client/compiled/main
.js:24
         /Users/cj/Dropbox/sd/acd/redline/vendor/gems/ruby/1.9.1/gems/poltergeist-0.6.0/lib/capybara/poltergeist/client/compiled/conn
ection.js:14
         /Users/cj/Dropbox/sd/acd/redline/vendor/gems/ruby/1.9.1/gems/poltergeist-0.6.0/lib/capybara/poltergeist/client/compiled/brow
ser.js:1
     # (eval):2:in `fill_in'
     # ./spec/requests/line_items.rb:41:in `block (3 levels) in <top (required)>'

check() doesn't work

I have the feeling that .check() doesn't work for me on poltergeist:

I modified the set() method a bit to get feedback, I also changed

if value && !checked? || !value && checked?

to

if value != checked?

Here's the modified method:

 def set(value)
  if tag_name == 'input'
    type = self[:type]
    if type == 'radio'
      click
    elsif type == 'checkbox'
      if value != checked?                      
        puts "Checkbox state before click: '#{checked?}'."
        click
        puts "Checkbox state after click: '#{checked?}'."
      end
    elsif type == 'file'
      command :select_file, value
    else
      command :set, value
    end
  elsif tag_name == 'textarea'
    command :set, value
  end
end

Here is the output when trying to uncheck a checkbox:

Checkbox state before click: 'true'.
Checkbox state after click: 'true'.

So the click doesn't really seem to do the trick as far as I can see

Add a way to close the browser

If users want to spawn additional sessions in their tests, they should have a way to close them as well, which would kill the phantomjs process.

JRuby is not supported

Last time I tried there seemed to be some issues with lack of support for certain socket method(s).

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.