diff options
author | gebele <gebele@in-silico.ch> | 2013-10-16 14:16:31 +0200 |
---|---|---|
committer | gebele <gebele@in-silico.ch> | 2013-10-16 14:16:31 +0200 |
commit | e7a5deb10818d6b21a9380df24fa379517ee74e3 (patch) | |
tree | 610cd8d8d68fd19abb9925492357ea94b7884bae | |
parent | 80e2484f74eb75c89dca6d74b18cd4cd773b2a35 (diff) |
updated
-rw-r--r-- | _posts/2012-08-27-testing-website-with-capybara-webkit-and-testunit.md | 48 |
1 files changed, 16 insertions, 32 deletions
diff --git a/_posts/2012-08-27-testing-website-with-capybara-webkit-and-testunit.md b/_posts/2012-08-27-testing-website-with-capybara-webkit-and-testunit.md index a360e39..b8dfd53 100644 --- a/_posts/2012-08-27-testing-website-with-capybara-webkit-and-testunit.md +++ b/_posts/2012-08-27-testing-website-with-capybara-webkit-and-testunit.md @@ -1,6 +1,6 @@ --- layout: post -title: "Testing website with capybara-webkit and test/unit" +title: "Testing website with capybara-webkit and minitest" description: "" category: Development tags: [Headless browser, Testing] @@ -8,69 +8,53 @@ tags: [Headless browser, Testing] {% include JB/setup %} --- -# Setup for headless browser tests with test/unit and capybara-webkit. +# Setup for headless browser tests with minitest and capybara-webkit. -You need to install capybara and capybara-webkit as gem. Capybara-webkit requires two system libraries **qt4** and **xvfb**. To install execute: +You need to install selenium-webdriver and capybara-webkit as gem. Capybara-webkit requires two system libraries **qt** and **xvfb**. To install execute: - `apt-get install qt4-dev-tools`<br> + `apt-get install libqtwebkit-dev`<br> `apt-get install xvfb` -as sudo. This works for Debian Squeeze. If **libqt4-dev** is not auto-installed you have to install it manually. - `apt-get install libqt4-dev` +as sudo. This works for Debian Wheezy. # Install the gems: - `gem install capybara`<br> + `gem install selenium-webdriver`<br> `gem install capybara-webkit` To run the headless browser you have to execute: - `Xvfb :1 -screen 0 1024x768x16 -nolisten inet6 &`<br> - `export 'DISPLAY=localhost:1.0'` + `DISPLAY=localhost:1.0 xvfb-run ruby TEST.rb`<br> -you can ignore warnings like: +or you integrate it to your test. - *SELinux: Disabled on system, not enabling in X server<br> - [dix] Could not init font path element /usr/share/fonts/X11/cyrillic, removing from list!<br> - [dix] Could not init font path element /usr/share/fonts/X11/100dpi/:unscaled, removing from list!<br> - [dix] Could not init font path element /usr/share/fonts/X11/75dpi/:unscaled, removing from list!<br> - [dix] Could not init font path element /usr/share/fonts/X11/Type1, removing from list!<br> - [dix] Could not init font path element /usr/share/fonts/X11/100dpi, removing from list!<br> - [dix] Could not init font path element /usr/share/fonts/X11/75dpi, removing from list!<br> - [dix] Could not init font path element /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType, removing from list!<br> - libudev: udev_monitor_enable_receiving: bind failed: Operation not permitted<br> - config/udev: failed to bind the udev monitor<br> - [config] failed to initialise udev<br>* - - -You can integrate this command to your test. For the following example `export 'DISPLAY=localhost:1.0'` is already in ~/.bashrc. +For the following example `export 'DISPLAY=localhost:1.0'` is already in ~/.bashrc. # Example test: ` require 'rubygems' - require 'test/unit' + require 'minitest/autorun' require 'capybara/dsl' require 'capybara-webkit' - Capybara.default_driver = :webkit - Capybara.default_wait_time = 5 + Capybara.default_driver = :selenium + Capybara.default_wait_time = 20 Capybara.javascript_driver = :webkit Capybara.run_server = false + Capybara.app_host = 'https://services.in-silico.ch' - class LazarWebTest < Test::Unit::TestCase + class LazarWebTest < MiniTest::Test include Capybara::DSL - @@uri = "http://lazar.in-silico.ch" - def test_00_start - `Xvfb :1 -screen 0 1024x768x16 -nolisten inet6 &` + `Xvfb :1 -screen 0 1024x768x16 2>/dev/null &` sleep 2 end def test_01_visit - visit(@@uri) + visit('/') puts page.source end |