Selenium WebDriver – Managing Selenium Grid Infrastructure using Arquillian Cube

In the previous article, we saw how easily we could set up the selenium-grid infrastructure using docker.

By using docker-compose file, we can setup the containers for the selenium grid. Then we can start our automated functional tests using the grid. Once the execution is done, we can issue a simple command to bring the entire selenium grid infrastructure down. However these docker containers have to be managed (starting/stopping etc) by us either manually or some custom script.

Can this be simplified further?

Yes, That is what we are going to see in this article!

Arquillian Cube:

Arquillian provides a nice extension – Arquillian-Cube – by which we can integrate docker and Arquillian, so that docker containers life cycle can be managed directly by Arquillian itself.

Arquillian Drone + Cube:

I am going to use one of my existing Arquillian drone project for this article.

I add below maven dependencies in my maven project.

 

Then I define the infrastructure information we need in a docker-compose.yml file as shown here.

Then I add the docker server, compose file and drone information in the Arquillian.xml

That’s it! We are set to control the docker-containers directly as part of our automated tests.

Did you notice? One cool thing here is – I do not have to modify anything in the test. That is the power of Arquillian. It helps us to keep the config completely away from the script. In future, If you do not want to use docker or selenium grid in future, you just need to update the arquillian.xml. Nothing else.  This is cool..Why would I not love Arquillian, then? 🙂

Now If I start my test, Arquillian first launches all the required containers, waits for the containers to be up and running, then it starts my tests.

I tried to record the simple test to show you all how it works – I have my eclipse IDE open where I have my arquillian drone tests + cube. My putty is connected to the remote ubuntu server where docker server is running. I keep on issuing ‘sudo docker ps -a‘ on putty to show all the containers in the remote server.

 

You could see in putty that initially there were no containers. Before the test starts 3 containers were created as given in the docker-compose file.then the test starts. Once the test finishes, there is no sign of any docker containers running in the machine.

Summary:

Docker has already saved us a lot of effort in setting up infrastructure quickly. Arquillian by managing docker’s containers life cycle, it makes our job even more easier. Our Arquillian test itself launches the required containers for the test, runs the test and shuts the containers down!!

 

Happy Testing & Subscribe 🙂

 

Share This:

10 thoughts on “Selenium WebDriver – Managing Selenium Grid Infrastructure using Arquillian Cube

  1. Simply superb. For someone like me who has only heard Docker as a buzzword.. it helps me gain meaningful insight into capabilities which Docker & Arquillian provides.

  2. very interesting thank you for this post, implementing on the same machine worked very good. using a remote docker server is something i have not been able to do yet.

    1. I was using it for remote docker only. Forget Arquillian Cube. Were you able to connect to remote docker from your local? Check the connectivity.

  3. Thank you,
    i have fixed the connectivity issue and it is working good in eclipse, but when running with maven is creates the docker containers and fails. i am investigating the await strategy issue. i could see you have encountered this before and have used
    chrome:
    await:
    strategy: sleeping
    sleepTime: 2 s

    i hope i am in the right direction.
    can you tell me where did you use this property ?
    thanks again,
    Ariel

  4. Hi, when using this format of docker-compose.yml, does it take the latest version of the hub and nodes? i ask since i can see the have a new version now (3.11.0-bismuth).

    thanks,
    Ariel

  5. where to keep the Arquillian.xml file .and I am getting an error while adding the dependency in pom”Project build error: ‘dependencies.dependency.version’ for org.arquillian.cube:arquillian-cube-docker:pom is missing.”

    1. arquillian.xml can be placed either inside project root directory or src/test/resources directory.

Leave a Reply to KirtiPatra Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.