capybara-webkit

Find elements by data attributes

北战南征 提交于 2019-11-30 00:45:55
问题 I'm improving my tests with RSpec and capybara-webkit , trying to delete all the css and xpath selectors like find('#edit_user > div:nth-child(7) > div > div > button').click and I'm looking for the best option to replace them. I was going to use the css class of the elements but some "pro" capybara tester said this is not the best option. So my question is: can I use the data attributes in my tests? If I have an element <button name="button" type="submit" class="button last" data-test="edit

How do poltergeist/PhantomJS and capybara-webkit differ?

蓝咒 提交于 2019-11-29 20:50:39
What are the differences between PhantomJS and capybara-webkit? What are the advantages of capybara-webkit over PhantomJS? Which of the two is the most efficient tool? Others ... poltergeist is the capybara driver for PhantomJS, a headless browser which is built on WebKit. capybara-webkit is a capybara driver which uses WebKit directly. poltergeist/PhantomJS has some big advantages over capybara-webkit: In my experience poltergeist/PhantomJS always times out when it should, whereas capybara-webkit sometimes hangs. Its error messages are much clearer. For example, it will actually tell you if

Deprecation warning from Capybara

99封情书 提交于 2019-11-29 13:58:11
问题 I am upgrading from rails 3.2.19 to rails 4.1.5, using rspec-rails 2.14.0.rc1 and capybara 2.4.1. All tests pass, and I only have one deprecation warning left: [DEPRECATION] Capybara::Webkit::Driver#accept_js_confirms! is deprecated. Please use Capybara::Session#accept_confirm instead. The line of code that is causing this is page.driver.accept_js_confirms! How do I change this line in order to eliminate the deprecation warning? 回答1: Given that the exception says: Please use Capybara::Session

webkit_server hangs periodically when run from Capybara in Ruby

假如想象 提交于 2019-11-29 12:44:59
问题 I am having a problem where an instance of webkit_server with Capybara and capybara-webkit running headless connected to a local Xvfb screen hangs when visiting a URL. It seems to happen after several minutes of repeatedly visiting different URLs and executing finders. (I'm using capybara for a screen scraping application in vanilla Ruby, not for testing.) I've confirmed that when it hangs the site is still accessible (for example, through curl or wget on the command line). I've also tried

Capybara webkit invalid response error, how to debug?

◇◆丶佛笑我妖孽 提交于 2019-11-29 02:06:10
I'm trying to write a request spec for a web page. This page works in development without error. But running in capybara webkit I get this error after trying to submit the form: Failure/Error: Unable to find matching line from backtrace Capybara::Driver::Webkit::WebkitInvalidResponseError: Unable to load URL: https://127.0.0.1:33416/sign_in In an effort to find out the cause I've started stripping out markup and JavaScript on the page. To the point where it is an empty form with a plain submit button. I still get the above error! The test is now literally: it "should be able create a new foo",

How to test a Select2 element with capybara DSL?

╄→尐↘猪︶ㄣ 提交于 2019-11-29 01:21:11
I have a Select2 element on a page that loads results via ajax. Would like to test this with capybara/rspec (using the poltergeist driver), but since the Select2 element actually starts out as a hidden field, and then populates a <ul> once results are processed, none of the normal select , fill_in or choose helpers will work. What I have now is something like it "should have a search field for events" do click_link "Select an Event" # this works as expected within('.select2-container') do # works find('.select2-search input').set(event.description[0,5]) # won't work! find(:xpath, "li[text()='#

How do poltergeist/PhantomJS and capybara-webkit differ?

…衆ロ難τιáo~ 提交于 2019-11-28 16:57:50
问题 What are the differences between PhantomJS and capybara-webkit? What are the advantages of capybara-webkit over PhantomJS? Which of the two is the most efficient tool? Others ... 回答1: poltergeist is the capybara driver for PhantomJS, a headless browser which is built on WebKit. capybara-webkit is a capybara driver which uses WebKit directly. poltergeist/PhantomJS has some big advantages over capybara-webkit: In my experience poltergeist/PhantomJS always times out when it should, whereas

ERROR: Error installing capybara-webkit:

你。 提交于 2019-11-28 15:41:05
Any suggestions on how to fix? gem install capybara-webkit -v '0.11.0' Building native extensions. This could take a while... ERROR: Error installing capybara-webkit: ERROR: Failed to build gem native extension. /home/durrantm/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb sh: qmake: not found Gem files will remain installed in /home/durrantm/.rvm/gems/ruby-1.9.3-p194/gems/capybara-webkit-0.11.0 for inspection. Results logged to /home/durrantm/.rvm/gems/ruby-1.9.3-p194/gems/capybara-webkit-0.11.0/./gem_make.out If you are in Ubuntu do sudo apt-get install qt4-dev-tools libqt4-dev libqt4-core

Check why ruby script hangs

﹥>﹥吖頭↗ 提交于 2019-11-27 16:56:36
问题 Sometimes my specs can just hang and I have to kill the corresponding ruby process. It's quite common when I run integration specs written with capybara and webkit driver. Is it possible to inspect given ruby's process and see where it hangs? Which method, operation, file, line number etc. 回答1: tl;dr Use gdb (e.g. Linux): echo 'call (void)rb_backtrace()' | gdb -p $(pgrep -f ruby) or use lldb (e.g. OS X): echo 'call (void)rb_backtrace()' | lldb -p $(pgrep -f ruby) You can debug Ruby script by

Capybara webkit invalid response error, how to debug?

那年仲夏 提交于 2019-11-27 16:28:58
问题 I'm trying to write a request spec for a web page. This page works in development without error. But running in capybara webkit I get this error after trying to submit the form: Failure/Error: Unable to find matching line from backtrace Capybara::Driver::Webkit::WebkitInvalidResponseError: Unable to load URL: https://127.0.0.1:33416/sign_in In an effort to find out the cause I've started stripping out markup and JavaScript on the page. To the point where it is an empty form with a plain