/Selenium-UI-testing-with-AWS-Lambda-Layers

Selenium UI testing with AWS Lambda Layers

Primary LanguagePython

Selenium UI testing with AWS Lambda Layers

This is an example of set up Selenium testing with AWS lambda layers Python3.6

File Structure

  • seleniumLayer - Selenium
  • lambda
── /seleniumLayer/            # Lambda Layer of Python Lib
  ├── /python/   # Python libs
  │ └── /lib/    
  │   └── /python3.6/*    
  ├── /chromedriver/    # Lambda Layer of headless Chrome 
  │ ├── /chromedriver   # Chrome Driver
  │ └── /headless-chromium      # Headless Chrome binary
  └── /serverless.yaml     
── /lambda/            # Lambda function
  ├── /handler.py      # source code of Lambda function 
  └── /serverless.yaml   

Stack

Install

Go to root directory of project

# download Selenium 2.37
$ pip3.6 install -t seleniumLayer/selenium/python/lib/python3.6/site-packages selenium=2.37

# download chrome driver
$ mkdir chromedriver
$ cd chromedriver
$ curl -SL https://chromedriver.storage.googleapis.com/2.37/chromedriver_linux64.zip > chromedriver.zip
$ unzip chromedriver.zip
$ rm chromedriver.zip

# download chrome binary
$ curl -SL https://github.com/adieuadieu/serverless-chrome/releases/download/v1.0.0-41/stable-headless-chromium-amazonlinux-2017-03.zip > headless-chromium.zip
$ unzip headless-chromium.zip
$ rm headless-chromium.zip

Deploy Lambda Layers

Go to root directory of project

$ cd seleniumLayer
$ sls deploy 

Deploy Lambda Function

Go to root directory of project

$ cd lambda
$ sls deploy 

Start Testing

Go to root directory of project

$ cd lambda
$ sls invoke --function hello