0

I am using below code in AWS Lambda Function

 from selenium import webdriver from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.chrome.options import Options def lambda_handler(event, context): options = Options() options.binary_location = '/opt/headless-chromium' options.add_argument('--headless') options.add_argument('--no-sandbox') options.add_argument('--start-maximized') options.add_argument('--start-fullscreen') options.add_argument('--single-process') options.add_argument('--disable-dev-shm-usage') driver = webdriver.Chrome('/opt/chromedriver', options=options) 

Error:

[ERROR] WebDriverException: Message: Service /opt/chromedriver unexpectedly exited. Status code was: 127

Traceback (most recent call last):   File "/var/task/lambda_function.py", line 27, in lambda_handler     driver = webdriver.Chrome('/opt/chromedriver', options=options)   File "/opt/python/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 70, in init     super(WebDriver, self).init(DesiredCapabilities.CHROME['browserName'], "goog",   File "/opt/python/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py", line 90, in init     self.service.start()   File "/opt/python/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 98, in start     self.assert_process_still_running()   File "/opt/python/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 110, in assert_process_still_running

Note : My Layer structure is below in zip file and using curl command to get linux drivers for lambda

curl -SL https://chromedriver.storage.googleapis.com/2.37/chromedriver_linux64.zip > chromedriver.zip curl -SL https://github.com/adieuadieu/serverless-chrome/releases/download/v1.0.0-41/stable-headless-chromium-amazonlinux-2017-03.zip > headless-chromium.zip 

enter image description here

9
  • If it is --headless, then there is no point in --start-maximized and --start-fullscreen. I don't know whether Chrome validates its parameters that far, but it's possible. I suggest you remove the two --start-* parameters. Commented Feb 18, 2022 at 5:53
  • I have removed both. But still same issue, I think python3.8 has some compatibility issue with curl command which I am using to get chrome driver and binary. Can you please suggest @TimRoberts Commented Feb 18, 2022 at 5:56
  • What happens if you run /opt/headless-chromium from a command line? Commented Feb 18, 2022 at 6:31
  • Is it possible to run it from command line? I was using Lambda console to run python code. Commented Feb 18, 2022 at 6:52
  • @TimRoberts Do you have any suggestion for me ? I am not getting compatibility documents from anywhere and I am not sure /opt/ path is correct or not. Commented Feb 18, 2022 at 16:55

1 Answer 1

0

I used python3.7 and used zip package which is available in below link

Working layer for me

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.