TestingSelenium » History » Version 11
Andreas Kohlbecker, 03/15/2011 12:13 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 | 11 | Andreas Kohlbecker | sudo apt-get install xvfb apt-get libgl1-mesa-dri xfonts-cyrillic xfonts-100dpi xfonts-75dpi |
30 | 1 | Andreas Kohlbecker | ~~~ |
31 | And then to check everything’s OK: |
||
32 | |||
33 | ~~~ |
||
34 | Xvfb :99 |
||
35 | ~~~ |
||
36 | 9 | Andreas Kohlbecker | 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. If you get some output like the following you shouldn't be bothered, this is OK. |
37 | 1 | Andreas Kohlbecker | |
38 | 9 | Andreas Kohlbecker | |
39 | ~~~ |
||
40 | SELinux: Disabled on system, not enabling in X server |
||
41 | [dix] Could not init font path element /usr/share/fonts/X11/cyrillic, removing from list! |
||
42 | [dix] Could not init font path element /usr/share/fonts/X11/100dpi/:unscaled, removing from list! |
||
43 | [dix] Could not init font path element /usr/share/fonts/X11/75dpi/:unscaled, removing from list! |
||
44 | [dix] Could not init font path element /usr/share/fonts/X11/100dpi, removing from list! |
||
45 | [dix] Could not init font path element /usr/share/fonts/X11/75dpi, removing from list! |
||
46 | ~~~ |
||
47 | 2 | Andreas Kohlbecker | |
48 | |||
49 | ### Install iceweasel (firefox) |
||
50 | |||
51 | |||
52 | To install iceweasel, which is currently the debian version of firefox: |
||
53 | |||
54 | ~~~ |
||
55 | sudo apt-get install iceweasel |
||
56 | ~~~ |
||
57 | And then, once you’re installed, to test that it works OK. |
||
58 | |||
59 | 1. Start Xvfb in one window as above, |
||
60 | |||
61 | 1. then in a second terminal window: |
||
62 | |||
63 | ~~~ |
||
64 | export DISPLAY=:99 |
||
65 | firefox |
||
66 | ~~~ |
||
67 | you should see nothing – firefox should just sit there until you CTRL+C. |
||
68 | |||
69 | The “export DISPLAY=:99″ line is telling firefox to use display # 99, which we started above. |
||
70 | |||
71 | |||
72 | 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. |
73 | 1 | Andreas Kohlbecker | |
74 | 2 | Andreas Kohlbecker | |
75 | 6 | Andreas Kohlbecker | See also: |
76 | |||
77 | 5 | Andreas Kohlbecker | * http://www.debianroot.de/server/website-screenshots-von-der-linux-consolen-mit-cutycapt-1196.html |
78 | 1 | Andreas Kohlbecker | |
79 | * http://linuxwiki.de/BildschirmFoto |
||
80 | |||
81 | ~~~ |
||
82 | 6 | Andreas Kohlbecker | apt-get install imagemagick x11-utils |
83 | ~~~ |
||
84 | |||
85 | Now take a screenshot of the `root` window: |
||
86 | |||
87 | |||
88 | ~~~ |
||
89 | export DISPLAY=:99 |
||
90 | import -window root example.png |
||
91 | ~~~ |
||
92 | |||
93 | 8 | Andreas Kohlbecker | The screenshot would look like this: |
94 | |||
95 | 7 | Andreas Kohlbecker | |
96 | [!examplepng|50%!] |
||
97 | |||
98 | |||
99 | 6 | Andreas Kohlbecker | If you want to get a list of all windows currently managed by Xvfb : |
100 | |||
101 | ~~~ |
||
102 | xwininfo -root -tree |
||
103 | 2 | Andreas Kohlbecker | ~~~ |