What is the best way to run selenium tests in AWS CI/CD pipeline What is the best way to run selenium tests in AWS CI/CD pipeline selenium selenium

What is the best way to run selenium tests in AWS CI/CD pipeline


I've used two approaches:

  1. set up Docker with the test-suite and debug locally. Then deploy Dockerfile using "docker" image of AWS CodeBuild.

  2. CodeBuild can use "selenium" image https://github.com/awslabs/serverless-automated-ui-testing/blob/master/automated-ui-testing.yaml#L480, instead of Dockerfile you provide instructions in codebuild.yml.

In both cases, the CodePipeline consists of 4 steps:

  • grab source (code and tests)
  • build project (using code)
  • deploy test-project
  • run selenium (using tests)

Each step produces output, that is used in next step. Deploy step generates URL which selenium can use. In my case "deploy" was deploying a CloudFormation stack, but it could also copy necessary files to S3 bucket or use some other approach.

My setup was similar but much more simpler than: https://aws.amazon.com/blogs/devops/using-aws-codepipeline-aws-codebuild-and-aws-lambda-for-serverless-automated-ui-testing/.

Challenges

The biggest problem is to get the correct combination of selenium, browser and webdriver. There are different guides on how to do it. Try what works for you, all implementations are messy, but I thought that Docker was more reliable.

Sample docker-compose:

version: '2'services:  hub:    image: selenium/hub:3.3.1    ports:       - "4444:4444"  chrome:    image: selenium/node-chrome:3.3.1    links:       - hub    environment:      HUB_PORT_4444_TCP_ADDR: hub      HUB_PORT_4444_TCP_PORT: 4444      DBUS_SESSION_BUS_ADDRESS: /dev/null  firefox:    image: selenium/node-firefox:3.3.1    links:      - hub    environment:      HUB_PORT_4444_TCP_ADDR: hub      HUB_PORT_4444_TCP_PORT: 4444  phantomjs:    image: selenium/node-phantomjs:3.3.1    links:      - hub    environment:      HUB_PORT_4444_TCP_ADDR: hub      HUB_PORT_4444_TCP_PORT: 4444      PHANTOMJS_OPTS: "--ignore-ssl-errors=true"  b3-test:    build: .    volumes:       - ./logs:/app/survey-tests/logs      - ./screenshots:/app/survey-tests/screenshots    environment:      - BTEST_DRIVER=REMOTE      - BTEST_REMOTE=http://hub:4444/wd/hub


After understanding your problem statement, it's clear you are looking for CI/CD tools along with parallel implementation of test cases to reduce the execution time.

Reducing test execution time is key for software development teams that wish to implement frequent delivery approaches (like continuous integration and delivery) 

First we shall understand CI/CD tools are Jenkins, Bamboo or Team City. On the other side, different ways in which we can implement parallel or distributed test case execution are of using Selenium Grid & Docker

Using Selenium Grid, one can run multiple tests on multiple machines in parallel, which reduces execution times from days to hours.

Docker helps a lot in setting up test labs using Grid in very easy and simple steps while helping to remove all complexities and Docker Specialities are

It’s much quicker to get up and running using the pre-made containers than to try and set Selenium up from scratch. You don’t need to install Java #winning.

You don’t need to install all the necessary browsers. Perhaps you don’t want to install Firefox or want to test with a specific older build of Chrome or one with specific plugin or capabilities?

CI/CD Tools : Jenkins vs. TeamCity vs. Bamboo

What is Jenkins?

Jenkins is the most popular open source CI/CD tool on the market today. Jenkins allows developers to automatically build, integrate, and test code as soon as they commit it to the source repository. This allows developers to catch bugs quickly and ultimately deploy much faster.

What is Bamboo?

Bamboo is a CI/CD server from Atlassian. Like other CI/CD servers, Bamboo allows developers to automatically build, integrate, and test source code, then prepare the app for deployment. Bamboo also works seamlessly with Atlassian’s other tools like Jira 

What is TeamCity?

TeamCity is another commercial CI/CD server, this time from the firm JetBrains. It is known for its incredibly simple setup and beautiful user interface. 

So please give a thought process based on your application and testing dependencies & requirements and what you want to achieve at end of the day - Your Goal.First work on the design & approach then please move towards implementation.