Installing Robot Framework on [x]Ubuntu 15.04 + PyCharm plugin

Installing Robot Framework

Install Selenium for Python and selenium2library for Robot Framework:

pip install selenium robotframework-selenium2library

Installing Ride GUI for Robot

Official guide: https://github.com/robotframework/RIDE/wiki/Installation-Instructions#installing-from-source

Step by step

Installing wxPython required by Ride (thanks to this SO answer):

sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-doc wx2.8-examples wx2.8-headers wx2.8-i18n

Installing plugins

Now I’m going to install Robot Framework plugin for PyCharm.

Normally you may find a correct version by navigating to File->Settings->Plugins->Browse repositories

Download Robot Framework plugin for PyCharm here: plugins.jetbrains.com/plugin/7415
I’m still using PyCharm version 3.4, so I had to download an archive with 0.10.2 version supported by my PyCharm.
After download completed, in PyCharm open File->Settings->Plugins

Python docstring

Small tutorial on how to correctly format docstrings in Python: Example on how to document your Python docstrings

I love to document code and I use PyCharm for Python development. And I always forget the syntax of method arguments type/description. I think the tutorial in the link above is quite explanatory, but I’ll update this post in case I find something new.

Make Celery ignore Django settings

I wanted to run an instance of Celery on my Linux machine. I installed it in a separate virtual environment (celery-test), but when I tried to run a sample application, I’ve got an error

ImportError: No module named xxx.settings

It was obvious that the problem was that I had Django installed system wide, so even from its own virtualenv my Celery could see Django settings. So I checked if I have references to Django in my environment variables:

printenv | grep xxx
DJANGO_SETTINGS_MODULE=xxx.settings

Let’s get rid of Django references for this particular virtualenv. Virtual environments have hooks for different types of events like preactivate or postdeactivate. They are stored in separate files in the virtualenv folder:

ls $VIRTUAL_ENV/bin

In my case I decided to delete Django environment variables after I activate my Celery virtualenv and set them back when I deactivate it. To do that I had to put the following command to $VIRTUAL_ENV/bin/postactivate :

unset DJANGO_SETTINGS_MODULE

And modify $VIRTUAL_ENV/bin/postdeactivate to set variables back:

DJANGO_SETTINGS_MODULE=xxx.settings

Now don’t forget to re-activate the virtualenv and the Celery should run fine:

deactivate  # deactivate virtualenv
workon celery-test  # activate virtualenv

celery worker -A tasks  # run celery

 

Robot Framework notes

So, I had a chance to try Robot Framework for testing our project. In this post I’ll collect some quick notes and impressions from using the tool.

Good

  • The structure of tests is quite intuitive and straightforward.
  • GUI and the test cases style can be good for testers not familiar with programming (but someone still has to program keywords).

Not good

  • Too GUI based as for developers. Integration with IDE would be handier. Although there are plugins for IDE’s, but I still have to use Robot Framework GUI and the IDE together.
  • Extremely slow application startup, scrolling, test case tree navigation, etc. (V 1.2.3)
  • Have to periodically close/reopen (V 1.2.3).
    • When it doesn’t print results in bottom-right part.
    • When git repository is updated.
  • Insufficient logging/debugging. When test fails or exception is thrown, it becomes a programmer problem to put enough information to exception/log/console.
  • “If it doesn’t work – close it and open again”. Just like Windows.

Personal summary

  • I found it adding unnecessary complexity as an additional GUI tool instead of being an additional library/framework.
  • In case you’re choosing a test framework for your project: good alternative as for me is py.test. It is more programmer-friendly having the same level of integration with Selenium, better integration with IDE; keywords is a nice abstraction, but py.test fixtures are not worse. Both have to have a proper code architecture and structure; then test suites can be good structured and intuitive. If in your project you already use Robot, this paragraph is not relevant.
  • GUI application is very-very slow and full of bugs. In newer versions some issues are fixed. V1.4 doesn’t have the scroll issue, V1.3 doesn’t have to be restarted after every test.

Results of working one iteration (3 weeks) as a tester

  • Installed RobotFramework, Ride for RobotFramework, the test project in local environment (on Ubuntu 14.04).
  • Researched the Ride updates. Current used version is 1.2.x; V1.4 has issue with long start (freezes on Loading window for three minutes); v1.3 is more stable than 1.2.
  • Researched current test project architecture; created a library (class) for working with web driver elements.
  • Researched the possibility to use polling instead of sleep(), including the proof of concept on some test cases.
  • StackOverflow question: Send a keyword to another keyword as a parameter
  • StackOverflow question #2: Send a non-serializable parameter to a keyword

TODO

Submit a bug to Ride Github.

PyCharm notes

Most of the notes should be applicable to the latest PyCharm version, but by historical reasons in the office I use PyCharm 3.4, so some of the notes might be related to it.

Auto-expanding import blocks

To make the import blocks expanded by default go to File -> Settings -> Editor -> Code Folding  and uncheck the Imports  check-box.

Explanation: by default the import section in the beginning of Python files is collapsed and for me having it expanded is much more convenient. Because modifying the import section is a common task that is often done manually. And clicking on a small expand/collapse icon is a bit annoying.

Adding a virtual environment (virtualenv) interpreter

Navigate to File -> Settings -> Project Interpreter , click the cog icon in the top-right corner and select Add Local . In the appeared file selection window navigate to your virtual environment directory select a Python executable (for example python2.7), which usually sits in the bin subfolder.