How to Run Selenium BDD Tests in Parallel With AWS Lambda

How to Run Selenium BDD Tests in Parallel With AWS Lambda

By getting familiar with the basics of Lambda Layers architecture and designing test sets, you are now ready to learn more about the Lambda handlers.

In our first article about Selenium BDD Tests in Parallel with AWS Lambda, we introduce parallelization in the Cloud and give you some insights into automating testing to accelerate your software development process. By getting familiar with the basics of Lambda Layers architecture and designing test sets, you are now ready to learn more about the Lambda handlers.

Lambda Handlers

Now’s the time to run our tests on AWS. We need to create two Lambda handlers. The first one will find all scenarios from the test layer and run the second lambda in parallel for each scenario. In the end, it will generate one test report and upload it to the AWS S3 bucket.

Let’s start with the middle part. To connect to AWS, we need to use the boto3 library – AWS SDK for Python. It enables us to create, configure, and manage AWS services. We also import here behave main function, which will be called to run behave tests from the code, not from the command line.

import json
2
3
import logging
4
5
import os
6
7
from datetime import datetime
8
9
from subprocess import call
10
11

12
13
import boto3
14
15
from behave.__main__ import main as behave_main
16
17

18
19
REPORTS_BUCKET = 'aws-selenium-test-reports'
20
21
DATETIME_FORMAT = '%H:%M:%S'
22
23

24
25
logger = logging.getLogger()
26
27
logger.setLevel(logging.INFO)
28
29

30
31

32
33
def get_run_args(event, results_location):
34
35
    test_location = f'/opt/{event["tc_name"]}'
36
37
    run_args = [test_location]
38
39
    if 'tags' in event.keys():
40
41
        tags = event['tags'].split(' ')
42
43
        for tag in tags:
44
45
            run_args.append(f'-t {tag}')
46
47
    run_args.append('-k')
48
49
    run_args.append('-f allure_behave.formatter:AllureFormatter')
50
51
    run_args.append('-o')
52
53
    run_args.append(results_location)
54
55
    run_args.append('-v')
56
57
    run_args.append('--no-capture')
58
59
    run_args.append('--logging-level')
60
61
    run_args.append('DEBUG')
62
63
    return run_args

cloud aws selenium quality assurance lambda bdd bdd tests

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Multi-cloud Spending: 8 Tips To Lower Cost

Mismanagement of multi-cloud expense costs an arm and leg to business and its management has become a major pain point. Here we break down some crucial tips to take some of the management challenges off your plate and help you optimize your cloud spend.

How to Run Selenium BDD Tests in Parallel with AWS Lambda

Have you ever felt annoyed by the long waiting time to receive test results? This solution might save your time and money—parallelization in the cloud.

Guide to AWS [email protected] A/B Testing

The introduction of [email protected] in 2017 has opened up novel possibilities for server-side A/B testing. While there are some caveats, the approach promises to greatly speed up and improve A/B testing on CDNs.

Cloud Performance Testing: Benefits and Approach - TopDevelopers.co

Learn about the benefits of Cloud Performance Testing along with the correct approaches for an effective solution, while developing web and mobile apps.

Top 10 AWS Cloud Migration Tools and Services

Take a look at some of the top cloud migration services you can use to migrate your services from on-premises to AWS Cloud. You need to understand the general terms of this field.