From e7a5deb10818d6b21a9380df24fa379517ee74e3 Mon Sep 17 00:00:00 2001 From: gebele Date: Wed, 16 Oct 2013 14:16:31 +0200 Subject: updated --- ...ng-website-with-capybara-webkit-and-testunit.md | 48 ++++++++-------------- 1 file 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`
+ `apt-get install libqtwebkit-dev`
`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`
+ `gem install selenium-webdriver`
`gem install capybara-webkit` To run the headless browser you have to execute: - `Xvfb :1 -screen 0 1024x768x16 -nolisten inet6 &`
- `export 'DISPLAY=localhost:1.0'` + `DISPLAY=localhost:1.0 xvfb-run ruby TEST.rb`
-you can ignore warnings like: +or you integrate it to your test. - *SELinux: Disabled on system, not enabling in X server
- [dix] Could not init font path element /usr/share/fonts/X11/cyrillic, removing from list!
- [dix] Could not init font path element /usr/share/fonts/X11/100dpi/:unscaled, removing from list!
- [dix] Could not init font path element /usr/share/fonts/X11/75dpi/:unscaled, removing from list!
- [dix] Could not init font path element /usr/share/fonts/X11/Type1, removing from list!
- [dix] Could not init font path element /usr/share/fonts/X11/100dpi, removing from list!
- [dix] Could not init font path element /usr/share/fonts/X11/75dpi, removing from list!
- [dix] Could not init font path element /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType, removing from list!
- libudev: udev_monitor_enable_receiving: bind failed: Operation not permitted
- config/udev: failed to bind the udev monitor
- [config] failed to initialise udev
* - - -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 -- cgit v1.2.3