add poltergeist dom_click support

This commit is contained in:
John Bintz 2013-02-25 13:19:44 -05:00
parent 4c637ec6d1
commit 3692dcb96c
2 changed files with 22 additions and 1 deletions

View File

@ -63,7 +63,7 @@ I normally do things:
gem 'bintz-integration_testing_setup', :git => 'git://github.com/johnbintz/bintz-integration_testing_setup.git'
```
`bundle install`, then run `bundle exec bints-integration_testing_setup`. It's best to do this on a pristine
`bundle install`, then run `bundle exec bintz-integration_testing_setup`. It's best to do this on a pristine
project, but it may work on one that already has some stuff in it.
## Gem setup
@ -369,6 +369,14 @@ end
* Testing using external services, like [Feed Validator](http://feedvalidator.org/): Force the application to start up
by `visit`ing a safe page that doesn't do anything, or is wrapped by a VCR call. Then build the URL
to give to the remote service using `Capybara.app_host`, like you would with `Rack::Test`.
* Sometimes Poltergeist and PhantomJS don't click the right element. This is due to the WebKit renderer being
silly sometimes. If you're having intermittent problems with a `click` on an element, use `dom_click` instead:
``` ruby
find_submit.dom_click
```
This will use a DOM click in drivers that support DOM event firing, and a regular `click` on other browsers (like Selenium).
## Writing less better organized code

View File

@ -9,3 +9,16 @@ require 'persistent_selenium/driver'
# you can override the driver with the DRIVER environment variable
ENV['DRIVER'] ||= 'persistent_selenium'
# if PhantomJS is having problems clicking something, use dom_click
class Capybara::Node::Element
def dom_click
synchronize do
begin
trigger('click')
rescue NotImplementedError, Capybara::NotSupportedByDriverError
click
end
end
end
end