Project

General

Profile

TestingSelenium » History » Version 8

Andreas Kohlbecker, 03/15/2011 12:05 PM

1 1 Andreas Kohlbecker
2
3
## Functional Website Testing with Selenium
4
5
6 2 Andreas Kohlbecker
We will use [Jenkins CI":http://jenkins-ci.org/ in order to run "SeleniumHQ](http://seleniumhq.org/) tests headlessly on a Debian  server.
7 1 Andreas Kohlbecker
8
9
10
### Install SeleniumHQ
11
12
13
The Selenium Server is needed in order to run either Selenium RC style scripts or Remote Selenium Webdriver ones.
14
15
16
1. download the Selenium Standalone Server from http://code.google.com/p/selenium/
17
18
19
20
### Install xvfb
21
 
22
23 2 Andreas Kohlbecker
The following installation instructions have been copied from the great guidance on this topic http://www.danstraw.com/running-selenium-tests-on-debian-headlessly-using-iceweasel-and-firefox/2010/11/24/, though we found that we need to install additional packages we decided repeat and extend this guidance here.
24 1 Andreas Kohlbecker
25
26
To install xvfb:
27
28
~~~
29 6 Andreas Kohlbecker
sudo apt-get install xvfb apt-get libgl1-mesa-dri
30 1 Andreas Kohlbecker
~~~
31
And then to check everything’s OK:
32
33
~~~
34
Xvfb :99
35
~~~
36
Where :99 is the display number. We set it to 99 to avoid any conflict with other displays, should they be attached. The command line should just hang without any comments until you press CTRL-C to close.
37 2 Andreas Kohlbecker
38
39
40
### Install iceweasel (firefox)
41
42
43
To install iceweasel, which is currently the debian version of firefox:
44
45
~~~
46
sudo apt-get install iceweasel
47
~~~
48
And then, once you’re installed, to test that it works OK. 
49
50
1. Start Xvfb in one window as above, 
51
52
1. then in a second terminal window:
53
54
~~~
55
export DISPLAY=:99
56
firefox
57
~~~
58
you should see nothing – firefox should just sit there until you CTRL+C.
59
60
The “export DISPLAY=:99″ line is telling firefox to use display # 99, which we started above.
61
62
63 6 Andreas Kohlbecker
we want to take take a screenshot in order to check that everything is ok. We will use ImagMagick to take screen shots in addition we also install the x11-utils in order get the `xwininfo` tool.
64 1 Andreas Kohlbecker
65 2 Andreas Kohlbecker
66 6 Andreas Kohlbecker
See also:
67
68 5 Andreas Kohlbecker
* http://www.debianroot.de/server/website-screenshots-von-der-linux-consolen-mit-cutycapt-1196.html
69 1 Andreas Kohlbecker
70
* http://linuxwiki.de/BildschirmFoto
71
72
~~~
73 6 Andreas Kohlbecker
apt-get install imagemagick x11-utils
74
~~~
75
76
Now take a screenshot of the `root` window:
77
78
79
~~~
80
export DISPLAY=:99
81
import -window root example.png
82
~~~
83
84 8 Andreas Kohlbecker
The screenshot would look like this:
85
86 7 Andreas Kohlbecker
87
[!examplepng|50%!]     
88
89
90 6 Andreas Kohlbecker
If you want to get a list of all windows currently managed by Xvfb :
91
92
~~~
93
xwininfo -root -tree
94 2 Andreas Kohlbecker
~~~