Skip to content

Commit 2b53017

Browse files
authoredNov 9, 2021
Merge pull request #10 from umihico/feature/native-chrome
feat: use native chrome 89 *inspired by https://github.com/aws-samples/serverless-ui-testing-using-selenium
2 parents 0283eb5 + 03f3e25 commit 2b53017

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed
 

‎Dockerfile

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
FROM public.ecr.aws/lambda/python:3.9 as build
22
RUN yum install -y unzip && \
3-
curl -SL https://chromedriver.storage.googleapis.com/2.43/chromedriver_linux64.zip > /tmp/chromedriver.zip && \
4-
curl -SL https://github.com/adieuadieu/serverless-chrome/releases/download/v1.0.0-55/stable-headless-chromium-amazonlinux-2017-03.zip > /tmp/headless-chromium.zip && \
3+
curl -Lo "/tmp/chromedriver.zip" "https://chromedriver.storage.googleapis.com/89.0.4389.23/chromedriver_linux64.zip" && \
4+
curl -Lo "/tmp/chrome-linux.zip" "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F843831%2Fchrome-linux.zip?alt=media" && \
55
unzip /tmp/chromedriver.zip -d /opt/ && \
6-
unzip /tmp/headless-chromium.zip -d /opt/
6+
unzip /tmp/chrome-linux.zip -d /opt/
77

88
FROM public.ecr.aws/lambda/python:3.9
9-
RUN yum install -y https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
9+
RUN yum install atk cups-libs gtk3 libXcomposite alsa-lib \
10+
libXcursor libXdamage libXext libXi libXrandr libXScrnSaver \
11+
libXtst pango at-spi2-atk libXt xorg-x11-server-Xvfb \
12+
xorg-x11-xauth dbus-glib dbus-glib-devel -y
1013
RUN pip install selenium
11-
COPY --from=build /opt/headless-chromium /opt/
14+
COPY --from=build /opt/chrome-linux /opt/chrome
1215
COPY --from=build /opt/chromedriver /opt/
1316
COPY test.py ./
1417
CMD [ "test.handler" ]

‎README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ This is minimum demo of headless chrome and selenium on container image on AWS L
55
This image goes with these versions.
66

77
- Python 3.9
8-
- serverless-chrome v1.0.0-55
9-
- chromium 69.0.3497.81 (stable channel) for amazonlinux:2017.03
10-
- chromedriver 2.43
11-
- selenium 3.141.0 (latest)
8+
- chromium 89.0.4389.47
9+
- chromedriver 89.0.4389.23
10+
- selenium 4.0.0
1211

1312
### Running the demo
1413

‎test.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33

44
def handler(event=None, context=None):
55
options = webdriver.ChromeOptions()
6-
options.binary_location = "/opt/headless-chromium"
6+
options.binary_location = '/opt/chrome/chrome'
77
options.add_argument('--headless')
88
options.add_argument('--no-sandbox')
99
options.add_argument("--disable-gpu")
1010
options.add_argument("--window-size=1280x1696")
1111
options.add_argument("--single-process")
1212
options.add_argument("--disable-dev-shm-usage")
13+
options.add_argument("--disable-dev-tools")
14+
options.add_argument("--no-zygote")
15+
options.add_argument("--user-data-dir=/tmp/chrome-user-data")
16+
options.add_argument("--remote-debugging-port=9222")
1317
chrome = webdriver.Chrome("/opt/chromedriver",
1418
options=options)
15-
chrome.get("https://umihi.co/")
19+
chrome.get("https://example.com/")
1620
return chrome.find_element_by_xpath("//html").text

0 commit comments

Comments
 (0)