Project

General

Profile

TestingSelenium » History » Revision 8

Revision 7 (Andreas Kohlbecker, 03/15/2011 12:04 PM) → Revision 8/37 (Andreas Kohlbecker, 03/15/2011 12:05 PM)

 

 ## Functional Website Testing with Selenium 


 We will use [Jenkins CI":http://jenkins-ci.org/ in order to run "SeleniumHQ](http://seleniumhq.org/) tests headlessly on a Debian    server. 



 ### Install SeleniumHQ 


 The Selenium Server is needed in order to run either Selenium RC style scripts or Remote Selenium Webdriver ones. 


 1. download the Selenium Standalone Server from http://code.google.com/p/selenium/ 



 ### Install xvfb 
 

 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. 


 To install xvfb: 

 ~~~ 
 sudo apt-get install xvfb apt-get libgl1-mesa-dri 
 ~~~ 
 And then to check everything’s OK: 

 ~~~ 
 Xvfb :99 
 ~~~ 
 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. 



 ### Install iceweasel (firefox) 


 To install iceweasel, which is currently the debian version of firefox: 

 ~~~ 
 sudo apt-get install iceweasel 
 ~~~ 
 And then, once you’re installed, to test that it works OK.  

 1. Start Xvfb in one window as above,  

 1. then in a second terminal window: 

 ~~~ 
 export DISPLAY=:99 
 firefox 
 ~~~ 
 you should see nothing – firefox should just sit there until you CTRL+C. 

 The “export DISPLAY=:99″ line is telling firefox to use display # 99, which we started above. 


 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. 


 See also: 

 * http://www.debianroot.de/server/website-screenshots-von-der-linux-consolen-mit-cutycapt-1196.html 

 * http://linuxwiki.de/BildschirmFoto 

 ~~~ 
 apt-get install imagemagick x11-utils 
 ~~~ 

 Now take a screenshot of the `root` window: 


 ~~~ 
 export DISPLAY=:99 
 import -window root example.png 
 ~~~ 

 The screenshot would look You should see something like this: 


 

 [!examplepng|50%!]      


 If you want to get a list of all windows currently managed by Xvfb : 

 ~~~ 
 xwininfo -root -tree 
 ~~~