Blog Back to all posts View all authors

How To Make Odoo Test Using Selenium - Odoo Tutorial For Beginners

by Gennadii Semenyshyn
January 22. 2019

There are many ways to test your Odoo application. Some are highly effective, others will give you only a headache. What to choose then?! No worries, Odoo support is coming! The solution I can recommend you in this development tutorial are automated testing tools such as Selenium.

Let's talk about Selenium 

It is free to use a package of libraries in combination with web drivers for browser simulation. You can use Selenium to show what the user will see if they will provide specific input. It can be used to represent the performance of different browsers such as Google Chrome, Mozilla Firefox, Edge. Also, on a bright side is that there are several languages available for Selenium (Python or C#). Selenium is a good choice for unit tests of websites (luckily for this Odoo tutorial - Odoo is one of such applications!).

After teaming up with Selenium, you need to create a GitLab tests runner which will be able to run the Odoo website and then test it. For this purpose, you may use Docker as it overall easy to set up in GitLab and is not too difficult to use. Furthermore, it's quite isolated system and may be checked for problems with ease.

Before Odoo test...

In this case, I'm using Python:2.7 Image for Docker, Chromedriver and Python to test our Odoo 10 website.
1. Get all packages with Linux command ‘apt-get update’ and install all the requirement for Odoo to run properly ‘pip install -r odoo-server/requirements.txt’.
2. Install Chromedriver along with the Selenium via ‘apt-get install -y chromedriver’ and ‘pip install selenium’.

Time for the actual Odoo Testing Tutorial for beginners!

1. To test Odoo while it is running on your device, add ‘&>/dev/null &’ to default Odoo startup command. This way you make sure that you are able to execute any other commands WHILE Odoo is running in the background.
2. Let Odoo server to "think" because it doesn't start immediately. To achieve this, we can use a command like ‘sleep 20s’ to postpone actual tests while Odoo is still booting up.
3. Put all tests in a separate folder called “tests” in the Git repository so you may issue a default bash script loop to execute all the tests in given folder with this command: ‘for f in tests/*.py; do python "$f"; done’.

Now we have all the tests up and running!

A bonus for ambitious Odoo unit testing beasts

Also, you may make your tests create screenshots so that you may look at what runner was able to “see” while passing tests. To retrieve it from your device, append to your CI configuration file this little guy:
artifacts:
paths:
- tests/*.png

 

That is all. Stay safe and test your apps frequently to achieve nice and clean performance. What are your tips on Odoo unit testing?

SEE ALSO

How OutSystems Can Improve Your Work

contact us

Have an idea ? Let’s talk

Office in Rzeszow
Office in Warsaw
CONTACT US
CONTACT INFORMATION

GET IN TOUCH

Fill up the form and we will contact you shortly

Name
E-Mail
Message

Company information

Fill up the form and we will contact you shortly.

ServoCode Sp. z o.o.

Jasionka 954E, 36-002 Jasionka, Poland

NIP: 8133719852

REGON: 364182909

KRS: 0000611643

We are using cookies to provide statistics that help us give you the best experience of our site. You can find out more or switch them off if you prefer. However, by continuing to use the site without changing settings, you are agreeing to our use of cookies. Read more

close