Skip to content
Blog » Getting Selenium to run on AWS Cloud 9

Getting Selenium to run on AWS Cloud 9

I have had to do this a few times now and after spending a lot of time retracing steps I thought I would write down these steps I followed. Ultimately I want to get my first AWS Device Farm script going but started with this. FWIW the AI chat bots did not do very well troubleshooting this setup and providing steps. Plain old google search for the win on this one.

Installing the chromedriver getting latest chromedriver version.
https://chromedriver.chromium.org/downloads

cd /tmp/
wget https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo mv chromedriver /usr/bin/chromedriver
chromedriver --version

This error messaged about mismatching versions

https://googlechromelabs.github.io/chrome-for-testing/

cd /tmp/
wget https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/120.0.6099.109/linux64/chromedriver-linux64.zip
unzip chromedriver-linux64.zip
sudo mv chromedriver-linux64/* /usr/bin
chromedriver --version

https://preethamdpg.medium.com/running-selenium-webdriver-with-python-on-an-aws-ec2-instance-be9780c97d47 helped me get to an answer that worked.

This code worked for my to confirm that I have the install working.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument(“–headless”)
options.add_argument(“–disable-gpu”)
options.add_argument(“–no-sandbox”)
options.add_argument(“enable-automation”)
options.add_argument(“–disable-infobars”)
options.add_argument(“–disable-dev-shm-usage”)
driver = webdriver.Chrome(options=options)
driver.get(“https://www.google.com/”)
element_text = driver.page_source
print(element_text)

Tags:

2 thoughts on “Getting Selenium to run on AWS Cloud 9”

  1. Exception managing chrome: No space left on device (os error 28)
    getting no space left on device so might need to upgrade to bigger machine on a t2.micro right now

Leave a Reply

Your email address will not be published. Required fields are marked *