Difference between revisions of "Robotframework"
(24 intermediate revisions by 2 users not shown) | |||
Line 13: | Line 13: | ||
#Install robotframework: | #Install robotframework: | ||
+ | yum install make automake gcc gcc-c++ kernel-devel git-core –y | ||
+ | yum install python-devel -y | ||
+ | curl -o /tmp/ezsetup.py https://sources.rhodecode.com/setuptools/raw/bootstrap/ez_setup.py | ||
+ | python /tmp/ezsetup.py | ||
+ | /usr/bin/easy_install pip | ||
+ | rm setuptools-*.tar.gz | ||
+ | pip install -i https://pypi.rhodecode.com/ --upgrade pip | ||
+ | pip install robotframework | ||
+ | pip install virtualenv | ||
+ | |||
Install additional robot framework libraries: | Install additional robot framework libraries: | ||
− | sudo pip install robotframework-sshlibrary | + | pip install robotframework-selenium2library |
− | + | pip install robotframework-ftplibrary | |
+ | pip install robotframework-sshlibrary | ||
+ | |||
+ | You can check if the SSH library installed successfully with: | ||
+ | |||
+ | python -c "import SSHLibrary" | ||
+ | |||
+ | If you find you have problems with the SSH library, reinstalling the support libraries for the SSH library through yum might help: | ||
+ | |||
+ | sudo pip uninstall pycrypto | ||
+ | sudo yum erase python-crypto | ||
+ | sudo yum clean all | ||
+ | sudo yum install python-crypto | ||
+ | sudo yum install python-paramiko | ||
+ | |||
+ | Note that selenium needs a browser to drive, so you'll need to install a graphical GUI, you can do this by: | ||
+ | |||
+ | yum -y groupinstall "Desktop" "Desktop Platform" "X Window System" "Fonts" | ||
+ | yum -y groupinstall "Graphical Administration Tools" | ||
+ | yum -y groupinstall "Internet Browser" | ||
+ | yum -y groupinstall "General Purpose Desktop" | ||
+ | |||
+ | If you want to start it up automatically, then instructions are [http://www.idevelopment.info/data/Unix/Linux/LINUX_AddGNOMEToCentOSMinimalInstall.shtml here] | ||
+ | |||
+ | else just type: | ||
+ | |||
+ | startx | ||
+ | |||
+ | After command line logging in. | ||
+ | |||
+ | You also ought to create a user to run under - you can use the graphical admin user prgram from the above, and then login as that. | ||
+ | |||
+ | ==Robotframework Demos== | ||
+ | |||
+ | There are ssh, ftp and web (selenium) demos at: | ||
+ | |||
+ | http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.8.4#demonstrations | ||
+ | |||
+ | https://bitbucket.org/robotframework/webdemo/wiki/Home#rst-header-starting-demo-application | ||
+ | |||
+ | https://robotframework-sshlibrary.googlecode.com/git-history/2.0/doc/SSHLibrary.html | ||
+ | |||
+ | http://sourceforge.net/projects/rf-ftp-py/files/1.2/FtpLibraryExample.txt/download | ||
+ | |||
+ | == SME Server Test Automation on GitHub == | ||
+ | |||
+ | The git repository with an intial set of tests for SME Server is now on GitHub | ||
+ | here: | ||
+ | |||
+ | https://github.com/MarcoHess/smeserver-test-automation | ||
+ | |||
+ | ===Loading and Trying it=== | ||
+ | |||
+ | The best way to try these tests is to clone the repository from GitHub with: | ||
+ | |||
+ | git clone https://github.com/MarcoHess/smeserver-test-automation.git | ||
+ | |||
+ | Alternatively you can also download a ZIP file with the whole repository with this link: | ||
+ | |||
+ | https://github.com/MarcoHess/smeserver-test-automation/archive/master.zip | ||
+ | |||
+ | ===Setting up the tests=== | ||
+ | |||
+ | The "resource.robot" file in the top "sme" directory contains a number of variables and macros that are used by the test scripts. | ||
+ | |||
+ | The key ones that you need to change are: | ||
+ | |||
+ | ${SERVER NAME} sme9-64 | ||
+ | ${SERVER DOMAIN} through-ip.com | ||
+ | ${VALID PASSWORD} Admin-Test-1234 | ||
+ | |||
+ | Note that the URL must be same as the FQDN for the server, as it uses this as a test on the title of the logged server manager web page. | ||
+ | |||
+ | The tests assume that the ${SERVER NAME}.${SERVER DOMAIN} resolve to the correct IP of that server. I typically setup entries for test servers with a host name entry on my main server. | ||
+ | |||
+ | ===Running the tests=== | ||
+ | |||
+ | The tests are setup in an hierarchical fashion. To run all tests: | ||
+ | |||
+ | pybot sme | ||
+ | |||
+ | To run a subset of the tests use: | ||
+ | |||
+ | pybot sme/02__server-manager | ||
+ | |||
+ | or for the ftp tests: | ||
+ | |||
+ | pybot sme/03__remote_access/02__ftp/ | ||
+ | |||
+ | and ssh by | ||
+ | |||
+ | pybot sme/03__remote_access/03__ssh/ | ||
+ | |||
+ | ===Contributing Tests=== | ||
+ | |||
+ | With the main test repository on GitHub it is very easy to 'fork' a copy of the repository, | ||
+ | start adding, fixing or modifying tests and then send a 'Pull Request' to merge your updates | ||
+ | into the main repository. | ||
+ | |||
+ | Here is an outline of that process: https://help.github.com/articles/fork-a-repo | ||
+ | |||
+ | == Additional Tools == | ||
+ | |||
+ | There are a number of tools that are useful in developing tests. This section lists a number of these: | ||
+ | |||
+ | === RIDE IDE === | ||
+ | The Robotframework has its own IDE called RIDE. It is particularly useful for running individual tests | ||
+ | during development. More info here https://github.com/robotframework/RIDE/wiki . It be easily installed with: | ||
+ | |||
+ | pip install robotframework-ride | ||
+ | |||
+ | and then run RIDE with: | ||
+ | |||
+ | ride.py sme | ||
+ | |||
+ | === XPath Checker Firefox Plugin === | ||
+ | It sometimes is quite tricky to locate the right element in a web page to check or click. One method | ||
+ | that selenium supports is [http://en.wikipedia.org/wiki/XPath XPaths]. | ||
+ | |||
+ | In order to develop these, I found the Firefox plugin 'XPaths Checker' particularly useful. | ||
+ | |||
+ | https://addons.mozilla.org/en-US/firefox/addon/xpath-checker/ |
Latest revision as of 02:19, 28 March 2014
Robotframework
Page documenting the setup and possible The use of robotframework for regression testing of SMEServer.
Page Initial creation by Brian J Read - 3rd March 2014
Installation
Initial installation is on the back of a Centos 6.5 (64 bit in my case) install. I use Virtual Box under Linux Mint 16.
- Install Centos 6.5
- login as root
- Install robotframework:
yum install make automake gcc gcc-c++ kernel-devel git-core –y yum install python-devel -y curl -o /tmp/ezsetup.py https://sources.rhodecode.com/setuptools/raw/bootstrap/ez_setup.py python /tmp/ezsetup.py /usr/bin/easy_install pip rm setuptools-*.tar.gz pip install -i https://pypi.rhodecode.com/ --upgrade pip pip install robotframework pip install virtualenv
Install additional robot framework libraries:
pip install robotframework-selenium2library pip install robotframework-ftplibrary pip install robotframework-sshlibrary
You can check if the SSH library installed successfully with:
python -c "import SSHLibrary"
If you find you have problems with the SSH library, reinstalling the support libraries for the SSH library through yum might help:
sudo pip uninstall pycrypto sudo yum erase python-crypto sudo yum clean all sudo yum install python-crypto sudo yum install python-paramiko
Note that selenium needs a browser to drive, so you'll need to install a graphical GUI, you can do this by:
yum -y groupinstall "Desktop" "Desktop Platform" "X Window System" "Fonts" yum -y groupinstall "Graphical Administration Tools" yum -y groupinstall "Internet Browser" yum -y groupinstall "General Purpose Desktop"
If you want to start it up automatically, then instructions are here
else just type:
startx
After command line logging in.
You also ought to create a user to run under - you can use the graphical admin user prgram from the above, and then login as that.
Robotframework Demos
There are ssh, ftp and web (selenium) demos at:
https://bitbucket.org/robotframework/webdemo/wiki/Home#rst-header-starting-demo-application
https://robotframework-sshlibrary.googlecode.com/git-history/2.0/doc/SSHLibrary.html
http://sourceforge.net/projects/rf-ftp-py/files/1.2/FtpLibraryExample.txt/download
SME Server Test Automation on GitHub
The git repository with an intial set of tests for SME Server is now on GitHub here:
https://github.com/MarcoHess/smeserver-test-automation
Loading and Trying it
The best way to try these tests is to clone the repository from GitHub with:
git clone https://github.com/MarcoHess/smeserver-test-automation.git
Alternatively you can also download a ZIP file with the whole repository with this link:
https://github.com/MarcoHess/smeserver-test-automation/archive/master.zip
Setting up the tests
The "resource.robot" file in the top "sme" directory contains a number of variables and macros that are used by the test scripts.
The key ones that you need to change are:
${SERVER NAME} sme9-64 ${SERVER DOMAIN} through-ip.com ${VALID PASSWORD} Admin-Test-1234
Note that the URL must be same as the FQDN for the server, as it uses this as a test on the title of the logged server manager web page.
The tests assume that the ${SERVER NAME}.${SERVER DOMAIN} resolve to the correct IP of that server. I typically setup entries for test servers with a host name entry on my main server.
Running the tests
The tests are setup in an hierarchical fashion. To run all tests:
pybot sme
To run a subset of the tests use:
pybot sme/02__server-manager
or for the ftp tests:
pybot sme/03__remote_access/02__ftp/
and ssh by
pybot sme/03__remote_access/03__ssh/
Contributing Tests
With the main test repository on GitHub it is very easy to 'fork' a copy of the repository, start adding, fixing or modifying tests and then send a 'Pull Request' to merge your updates into the main repository.
Here is an outline of that process: https://help.github.com/articles/fork-a-repo
Additional Tools
There are a number of tools that are useful in developing tests. This section lists a number of these:
RIDE IDE
The Robotframework has its own IDE called RIDE. It is particularly useful for running individual tests during development. More info here https://github.com/robotframework/RIDE/wiki . It be easily installed with:
pip install robotframework-ride
and then run RIDE with:
ride.py sme
XPath Checker Firefox Plugin
It sometimes is quite tricky to locate the right element in a web page to check or click. One method that selenium supports is XPaths.
In order to develop these, I found the Firefox plugin 'XPaths Checker' particularly useful.
https://addons.mozilla.org/en-US/firefox/addon/xpath-checker/