This is an example of set up Selenium testing with AWS lambda layers Python3.6
- seleniumLayer - Selenium
- lambda
── /seleniumLayer/ # lambda layers
├── /selenium lambda layer of selenium 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 # serverless config
- Python3.6
- Selenium2.37
- ChromeDriver2.37
- Serverless Chrome v1.0.0.41
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
$ cd seleniumLayer
$ 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
Do this if you don't have serverless in your machine yet
npm config set prefix /usr/local
and then,
npm i -g serverless
Go to root directory of project
$ cd seleniumLayer
$ sls deploy
Go to root directory of project
$ cd lambda
$ sls deploy
Go to root directory of project
$ cd lambda
$ sls invoke --function hello