Integration of Travis with Selenium - is it possible? How would you do that? Checkout!
S0-E19/E30 :)
Travis and Docker
If you don't already know, I'm a big fan of the docker, and how the service has impacted developers society as such that each developer can take any new fancy-pancy tool and use it without having to get bored about the configuration of new server.
You may ask yourself - how is that related to Travis and Selenium ? Well... I'm going to try to use Travis and Docker Selenium image to run those tests :)
But did you knew there is possibility to make use of Docker within Travis?
Until yesterday I didn't know. But when I've found I've thought to myself - I have to check it!
So Let's check how to begin Travis-docker integration first shall we?
Travis file.
Travis as you can check in documentation should contain few key things. First of all:
language: python
Building a Python Project with Travis gives you a more advanced look at possibilities for Python-language project.
So a simple .travis.yml
will look like this:
language: python
python:
- "2.7"
- "3.6"
# command to install dependencies
install:
- pip install -r requirements.txt
# command to run tests
script:
- pytest # or py.test for Python versions 3.5 and below
And docker will need to be handled like this As described here :
language: python
python:
- "2.7"
services:
- docker
before_install:
- docker pull selenium/node-firefox:3.8.1-francium
- docker pull selenium/hub:3.8.1-francium
- docker run -d -p 4444:4444 --name selenium-hub selenium/hub:3.8.1-francium
- docker run -d --link selenium-hub:hub --name selenium-node-firefox -v /dev/shm:/dev/shm selenium/node-firefox:3.8.1-francium
# command to install dependencies
install:
- pip install -r requirements.txt
script:
- python tests.py
Tests on Grammarly Selenium Automation Project!
So for our testing, I've used our Grammarly mini project to check if Travis will use it with Selenium-IDE and will use tests.
And it DID! checkout result for python2.7 here
Adjustment for python3.6
I've also found that pip did not setup accurately project with requirements.txt
because those requirements were for python2.7.
Let's fix this by changing a bit requirements.txt
and check if tests on Travis will work :)
argparse==1.2.1
beautifulsoup4==4.6.0
page-objects==1.1.0
selenium==3.9.0
wsgiref
As you can see I've removed specific number of version for wsgiref
library because it's the one that failed this travis job
This commit adds this fix and adds a Build-Status from Travis to README.md
The results are here
And as you can see this fix did not fix the problem :( So I've decided to remove a wsgiref
library from requirements and test again.
Unfortunately as you can see, it also failed :) Because I forgot about very appealing redundant printing that was coded in python2.
So I got rid of it. Now take a look at this travis build. Taking into consideration that tests are not properly coded (using Python's time.sleep
instead of Selenium Wait
) sometimes This builds will fail -until I'll finally fix the problem :)
Acknowledgements
- Travis example by Fabric
- Building a Python project -Travis Ci
- Using Docker in Builds - Travis CI
- Gui and headless browser testing
- Travis worker on Github
- Travis Ci Client CLI
Thanks!
That's it :) Comment, share or don't :)
If you have any suggestions what I should blog about in the next articles - please give me a hint :)
See you tomorrow! Cheers!
Comments
comments powered by Disqus