{"id":13677389,"url":"https://github.com/smithclay/lambdium","last_synced_at":"2025-04-09T17:26:55.377Z","repository":{"id":48827473,"uuid":"93454787","full_name":"smithclay/lambdium","owner":"smithclay","description":"headless chrome + selenium webdriver in AWS Lambda using the serverless application model","archived":false,"fork":false,"pushed_at":"2022-09-08T07:00:16.000Z","size":550,"stargazers_count":257,"open_issues_count":12,"forks_count":40,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-02T11:58:21.129Z","etag":null,"topics":["aws-lambda","chromium","lambda","selenium","selenium-webdriver","serverless","serverless-application-model"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smithclay.png","metadata":{"files":{"readme":"README-SAR.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-05T23:05:53.000Z","updated_at":"2024-12-11T03:23:39.000Z","dependencies_parsed_at":"2023-01-18T00:45:27.268Z","dependency_job_id":null,"html_url":"https://github.com/smithclay/lambdium","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smithclay%2Flambdium","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smithclay%2Flambdium/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smithclay%2Flambdium/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smithclay%2Flambdium/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smithclay","download_url":"https://codeload.github.com/smithclay/lambdium/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248076326,"owners_count":21043750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","chromium","lambda","selenium","selenium-webdriver","serverless","serverless-application-model"],"created_at":"2024-08-02T13:00:41.407Z","updated_at":"2025-04-09T17:26:55.356Z","avatar_url":"https://github.com/smithclay.png","language":"JavaScript","readme":"## lambdium\n### serverless application repository quickstart\n\nLambdium allows you to run a Selenium Webdriver script written in Javascript inside of an AWS Lambda function bundled with a special version of Google Chrome (headless chrome).\n\nFor example, this script uses Selenium to automate visiting the google.com homepage and print the title to the console:\n\n```\nconsole.log('About to visit google.com...');\n$browser.get('http://www.google.com/ncr');\n$browser.wait($driver.until.titleIs('Google'), 1000);\n$browser.getTitle().then(function(title) {\n    console.log(\"title is: \" + title);\n});\nconsole.log('Finished running script!');\n``` \n\nAfter running this script inside of of the AWS Lambda function running lambdium, you can look at Cloudwatch logs to read the output of the script:\n\n```\n23:37:332018-03-12T23:37:33.682Z\t567babb5-264e-11e8-ae20-e37b20048a93\tAbout to visit google.com...\n23:37:33 2018-03-12T23:37:33.682Z\t567babb5-264e-11e8-ae20-e37b20048a93\tFinished running script!\n23:37:36 2018-03-12T23:37:36.860Z\t567babb5-264e-11e8-ae20-e37b20048a93\ttitle is: Google\n```\n\n### running your first selenium script\n\nlambdium requires you to invoke it using a special event trigger: a JSON document with a single property called `Base64Script`, which is a Base64-encoded selenium script written in Javascript. The example which visits google.com looks like this:\n\n```\n{\n    \"Base64Script\": \"Ly8gU2FtcGxlIHNlbGVuaW11bS13ZWJkcml2ZXIgc2NyaXB0IHRoYXQgdmlzaXRzIGdvb2dsZS5jb20KLy8gVGhpcyB1c2VzIHRoZSBzZWxlbml1bS13ZWJkcml2ZXIgMy40IHBhY2thZ2UuCi8vIERvY3M6IGh0dHBzOi8vc2VsZW5pdW1ocS5naXRodWIuaW8vc2VsZW5pdW0vZG9jcy9hcGkvamF2YXNjcmlwdC9tb2R1bGUvc2VsZW5pdW0td2ViZHJpdmVyL2luZGV4Lmh0bWwKLy8gJGJyb3dzZXIgPSB3ZWJkcml2ZXIgc2Vzc2lvbgovLyAkZHJpdmVyID0gZHJpdmVyIGxpYnJhcmllcwovLyBjb25zb2xlLmxvZyB3aWxsIG91dHB1dCB0byBBV1MgTGFtYmRhIGxvZ3MgKHZpYSBDbG91ZHdhdGNoKQoKY29uc29sZS5sb2coJ0Fib3V0IHRvIHZpc2l0IGdvb2dsZS5jb20uLi4nKTsKJGJyb3dzZXIuZ2V0KCdodHRwOi8vd3d3Lmdvb2dsZS5jb20vbmNyJyk7CiRicm93c2VyLmZpbmRFbGVtZW50KCRkcml2ZXIuQnkubmFtZSgnYnRuSycpKS5jbGljaygpOwokYnJvd3Nlci53YWl0KCRkcml2ZXIudW50aWwudGl0bGVJcygnR29vZ2xlJyksIDEwMDApOwokYnJvd3Nlci5nZXRUaXRsZSgpLnRoZW4oZnVuY3Rpb24odGl0bGUpIHsKICAgIGNvbnNvbGUubG9nKCJ0aXRsZSBpczogIiArIHRpdGxlKTsKfSk7CmNvbnNvbGUubG9nKCdGaW5pc2hlZCBydW5uaW5nIHNjcmlwdCEnKTs=\"\n}\n```\n\nTo encode another script, you can paste the contents of a script in an online converter like [https://www.base64encode.org/](https://www.base64encode.org/) or using the following commands, which are also available as a simple shell script in `scripts/invoke.sh`:\n\n```\nSELENIUM_SCRIPT=/path/to/your/script\nBASE64_ENCODED=`cat $SELENIUM_SCRIPT | openssl base64`\nPAYLOAD_STRING='{\"Base64Script\": \"'$BASE64_ENCODED'\"}'\necho $PAYLOAD_STRING\n```\n\nWith the payload constructed, you can then invoke the function directly in the AWS Console by defining a test event or using the AWS CLI with the payload written to a file defined in the $PAYLOAD_FILE enviornment variable. Replace the function name with the name of the function deployed by the serverless application repository (it should be `lambdium` by default).\n\n```\naws lambda invoke --invocation-type RequestResponse --function-name lambdium --payload file://$PAYLOAD_FILE --log-type Tail $OUTPUT_FILE\n``` \n\n### troubleshooting\n\nErrors and failures will be written to Cloudwatch. The `DEBUG_ENV` environment variable outputs additional information about the filesystem and inputted Base64 script.\n\nThe maximum payload size is 4kb and the default timeout is 10 seconds, so this won't work with very large scripts or scripts that run a long time.\n\nMore details are available on the official Github page, https://github.com/smithclay/lambdium.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmithclay%2Flambdium","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmithclay%2Flambdium","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmithclay%2Flambdium/lists"}