blackboard / lambda-selenium

Use Selenium Webdriver and Chrome inside AWS Lambda
MIT License
229 stars 52 forks source link

chrome binary for lambda? #44

Closed andreabisello closed 5 years ago

andreabisello commented 5 years ago

hi for running this project on lambda is required a particular version of the chrome binary? where have you found the binary contained in the lambda node release? thanks

dejanvasic85 commented 5 years ago

here here! Can someone answer this one? PLease...

wesmcouch commented 5 years ago

Which binary do you need? We have chrome 62, and 68 are confirmed to be good versions. These are the full versions of chrome that work in Lambda.

If you want to download them, use the aws cli with one of these commands aws s3api get-object --bucket bb-test-resources --key chrome-68.0.3440.75.tar.gz --request-payer requester chrome-68.0.3440.75.tar.gz aws s3api get-object --bucket bb-test-resources --key chrome-62.0.3202.94.tar.gz --request-payer requester chrome-62.0.3202.94.tar.gz

These binaries are custom built and require quite a few settings to get running, this repo is a bit behind with what we have running currently.

wesmcouch commented 5 years ago

Here is a list of required arguments that need to be sent to the chromedriver --disable-gpu --single-process --no-sandbox --data-path=/tmp/data-path --homedir=/tmp/homedir --disk-cache-dir=/tmp/cache-dir --allow-file-access-from-files --disable-web-security --disable-extensions --ignore-certificate-errors --disable-ntp-most-likely-favicons-from-server --disable-ntp-popular-sites --disable-infobars --disable-dev-shm-usage

wesmcouch commented 5 years ago

At runtime, you should extract the tar to /tmp directory so that it is in the correct location. LD_LIBRARY_PATH environment variable should be /tmp/chrome-68.0.3440.75/libs:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib

tsu-denim commented 5 years ago

That binary can be found here as well... https://github.com/tsu-denim/chromium-full-gtk2-lambda https://github.com/tsu-denim/chromium-full-gtk2-lambda/releases

andreabisello commented 5 years ago

thanks

tsu-denim commented 5 years ago

I usually just rename the binary to just 'chrome' so I don't have to change the configs for chromedriver and LD_LIBRARY_PATH after upgrading... https://github.com/tsu-denim/strafer-duty/blob/master/pipeline/integration_tests/protractor.conf.js#L102

andreabisello commented 5 years ago

Here is a list of required arguments that need to be sent to the chromedriver --disable-gpu --single-process --no-sandbox --data-path=/tmp/data-path --homedir=/tmp/homedir --disk-cache-dir=/tmp/cache-dir --allow-file-access-from-files --disable-web-security --disable-extensions --ignore-certificate-errors --disable-ntp-most-likely-favicons-from-server --disable-ntp-popular-sites --disable-infobars --disable-dev-shm-usage

what about disk-cache-dir ? chrome on lambda has cache?

wesmcouch commented 5 years ago

Yeah, you must specify this or Chrome will try to put it in some directory that isn't writable in lambda. Before each test at the start of the lambda function you want to clear /tmp directory to refresh the environment

tsu-denim commented 5 years ago

Here is an example in Python...

https://github.com/tsu-denim/strafer-duty/blob/master/functions/lib/binary_service.py

Like Wes said, you should run both a function to wipe out /tmp and killing leftover processes before launching Chromedriver and Chrome. Chrome is pig for cache and will fill up tmp in no time, especially for modern client driven React/angular single page applications. Chromedriver tends to stick around when it is supposed to exit, so you want to check for stuff like that too. We found this through a lot of trial and error and it keeps things running in a predictable manner.