Skip to content

Commit 2365193

Browse files
ehbellodiemol
andauthored
Support for Selenium nodes with Opera browser (#995)
* Adds files to build Opera images for Selenium * Enable tests for Opera images * Update the README.md to describe Opera images Co-authored-by: Diego Molina <[email protected]>
1 parent df46eb1 commit 2365193

File tree

15 files changed

+339
-9
lines changed

15 files changed

+339
-9
lines changed

Makefile

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,23 @@ MAJOR := $(word 1,$(subst ., ,$(VERSION)))
88
MINOR := $(word 2,$(subst ., ,$(VERSION)))
99
MAJOR_MINOR_PATCH := $(word 1,$(subst -, ,$(VERSION)))
1010

11-
all: hub chrome firefox chrome_debug firefox_debug standalone_chrome standalone_firefox standalone_chrome_debug standalone_firefox_debug
11+
all: hub chrome firefox opera chrome_debug firefox_debug opera_debug standalone_chrome standalone_firefox standalone_opera standalone_chrome_debug standalone_firefox_debug standalone_opera_debug
1212

1313
generate_all: \
1414
generate_hub \
1515
generate_nodebase \
1616
generate_chrome \
1717
generate_firefox \
18+
generate_opera \
1819
generate_chrome_debug \
1920
generate_firefox_debug \
21+
generate_opera_debug \
2022
generate_standalone_firefox \
2123
generate_standalone_chrome \
24+
generate_standalone_opera \
2225
generate_standalone_firefox_debug \
23-
generate_standalone_chrome_debug
26+
generate_standalone_chrome_debug \
27+
generate_standalone_opera_debug
2428

2529
build: all
2630

@@ -53,6 +57,12 @@ generate_firefox:
5357
firefox: nodebase generate_firefox
5458
cd ./NodeFirefox && docker build $(BUILD_ARGS) -t $(NAME)/node-firefox:$(VERSION) .
5559

60+
generate_opera:
61+
cd ./NodeOpera && ./generate.sh $(VERSION) $(NAMESPACE) $(AUTHORS)
62+
63+
opera: nodebase generate_opera
64+
cd ./NodeOpera && docker build $(BUILD_ARGS) -t $(NAME)/node-opera:$(VERSION) .
65+
5666
generate_standalone_firefox:
5767
cd ./Standalone && ./generate.sh StandaloneFirefox node-firefox Firefox $(VERSION) $(NAMESPACE) $(AUTHORS)
5868

@@ -77,6 +87,18 @@ generate_standalone_chrome_debug:
7787
standalone_chrome_debug: chrome_debug generate_standalone_chrome_debug
7888
cd ./StandaloneChromeDebug && docker build $(BUILD_ARGS) -t $(NAME)/standalone-chrome-debug:$(VERSION) .
7989

90+
generate_standalone_opera:
91+
cd ./Standalone && ./generate.sh StandaloneOpera node-opera Opera $(VERSION) $(NAMESPACE) $(AUTHORS)
92+
93+
standalone_opera: opera generate_standalone_opera
94+
cd ./StandaloneOpera && docker build $(BUILD_ARGS) -t $(NAME)/standalone-opera:$(VERSION) .
95+
96+
generate_standalone_opera_debug:
97+
cd ./StandaloneDebug && ./generate.sh StandaloneOperaDebug node-opera-debug Opera $(VERSION) $(NAMESPACE) $(AUTHORS)
98+
99+
standalone_opera_debug: opera_debug generate_standalone_opera_debug
100+
cd ./StandaloneOperaDebug && docker build $(BUILD_ARGS) -t $(NAME)/standalone-opera-debug:$(VERSION) .
101+
80102
generate_chrome_debug:
81103
cd ./NodeDebug && ./generate.sh NodeChromeDebug node-chrome Chrome $(VERSION) $(NAMESPACE) $(AUTHORS)
82104

@@ -89,6 +111,12 @@ generate_firefox_debug:
89111
firefox_debug: generate_firefox_debug firefox
90112
cd ./NodeFirefoxDebug && docker build $(BUILD_ARGS) -t $(NAME)/node-firefox-debug:$(VERSION) .
91113

114+
generate_opera_debug:
115+
cd ./NodeDebug && ./generate.sh NodeOperaDebug node-opera Opera $(VERSION) $(NAMESPACE) $(AUTHORS)
116+
117+
opera_debug: generate_opera_debug opera
118+
cd ./NodeOperaDebug && docker build $(BUILD_ARGS) -t $(NAME)/node-opera-debug:$(VERSION) .
119+
92120
tag_latest:
93121
docker tag $(NAME)/base:$(VERSION) $(NAME)/base:latest
94122
docker tag $(NAME)/hub:$(VERSION) $(NAME)/hub:latest
@@ -209,12 +237,16 @@ release: tag_major_minor
209237

210238
test: test_chrome \
211239
test_firefox \
240+
test_opera \
212241
test_chrome_debug \
213242
test_firefox_debug \
243+
test_opera_debug \
214244
test_chrome_standalone \
215245
test_firefox_standalone \
246+
test_opera_standalone \
216247
test_chrome_standalone_debug \
217-
test_firefox_standalone_debug
248+
test_firefox_standalone_debug \
249+
test_opera_standalone_debug
218250

219251

220252
test_chrome:
@@ -241,6 +273,18 @@ test_firefox_standalone:
241273
test_firefox_standalone_debug:
242274
VERSION=$(VERSION) NAMESPACE=$(NAMESPACE) ./tests/bootstrap.sh StandaloneFirefoxDebug
243275

276+
test_opera:
277+
VERSION=$(VERSION) NAMESPACE=$(NAMESPACE) ./tests/bootstrap.sh NodeOpera
278+
279+
test_opera_debug:
280+
VERSION=$(VERSION) NAMESPACE=$(NAMESPACE) ./tests/bootstrap.sh NodeOperaDebug
281+
282+
test_opera_standalone:
283+
VERSION=$(VERSION) NAMESPACE=$(NAMESPACE) ./tests/bootstrap.sh StandaloneOpera
284+
285+
test_opera_standalone_debug:
286+
VERSION=$(VERSION) NAMESPACE=$(NAMESPACE) ./tests/bootstrap.sh StandaloneOperaDebug
287+
244288

245289
.PHONY: \
246290
all \
@@ -251,17 +295,23 @@ test_firefox_standalone_debug:
251295
ci \
252296
firefox \
253297
firefox_debug \
298+
opera \
299+
opera_debug \
254300
generate_all \
255301
generate_hub \
256302
generate_nodebase \
257303
generate_chrome \
258304
generate_firefox \
305+
generage_opera \
259306
generate_chrome_debug \
260307
generate_firefox_debug \
308+
generate_opera_debug \
261309
generate_standalone_chrome \
262310
generate_standalone_firefox \
311+
generate_standalone_opera \
263312
generate_standalone_chrome_debug \
264313
generate_standalone_firefox_debug \
314+
generate_standalone_opera_debug \
265315
hub \
266316
nodebase \
267317
release \

NodeOpera/Dockerfile.txt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
USER root
2+
3+
4+
#============================================
5+
# Opera
6+
#============================================
7+
# can specify versions by OPERA_VERSION;
8+
# e.g. opera-stable=60.0.3255.109
9+
# opera-beta=60.0.3255.103
10+
# opera-developer=62.0.3323.0
11+
# opera=12.16.1860
12+
# opera-next=12.16.1860
13+
# latest (equivalent to opera-stable)
14+
# opera-beta (pull latest beta)
15+
#============================================
16+
ARG OPERA_VERSION="opera-stable"
17+
RUN wget -q -O - https://deb.opera.com/archive.key | apt-key add - \
18+
&& echo "deb https://deb.opera.com/opera-stable/ stable non-free" >> /etc/apt/sources.list.d/opera-stable.list \
19+
&& apt-get update -qqy \
20+
&& apt-get -qqy install \
21+
${OPERA_VERSION:-opera-stable} \
22+
&& dpkg-divert --divert /usr/lib/x86_64-linux-gnu/opera/libffmpeg.so.orig \
23+
--package ${OPERA_VERSION:-opera-stable} --rename --add \
24+
/usr/lib/x86_64-linux-gnu/opera/libffmpeg.so \
25+
&& ln -sf /usr/lib/chromium-browser/libffmpeg.so /usr/lib/x86_64-linux-gnu/opera/libffmpeg.so \
26+
&& rm /etc/apt/sources.list.d/opera-stable.list \
27+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
28+
29+
#=================================
30+
# Opera Launch Script Wrapper
31+
#=================================
32+
COPY wrap_opera_binary /opt/bin/wrap_opera_binary
33+
RUN /opt/bin/wrap_opera_binary
34+
35+
USER seluser
36+
37+
#=====================
38+
# Opera webdriver
39+
#=====================
40+
# can specify versions by OPERA_DRIVER_VERSION
41+
# Latest released version will be used by default
42+
#=====================
43+
ARG OPERA_DRIVER_VERSION
44+
RUN LATEST_VERSION=$(curl -s https://api.github.com/repos/operasoftware/operachromiumdriver/releases/latest | jq .name -r) \
45+
&& [ -z "$OPERA_DRIVER_VERSION" ] && OPERA_DRIVER_VERSION=$LATEST_VERSION \
46+
&& echo "Using operadriver version: "$OPERA_DRIVER_VERSION \
47+
&& wget --no-verbose -O /tmp/operadriver_linux64.zip https://github.com/operasoftware/operachromiumdriver/releases/download/v.${OPERA_DRIVER_VERSION}/operadriver_linux64.zip \
48+
&& rm -rf /opt/selenium/operadriver \
49+
&& unzip /tmp/operadriver_linux64.zip -d /tmp/ \
50+
&& mv /tmp/operadriver_linux64/operadriver /opt/selenium/operadriver-${OPERA_DRIVER_VERSION} \
51+
&& rm -rf /tmp/operadriver_linux64* \
52+
&& chmod 755 /opt/selenium/operadriver-${OPERA_DRIVER_VERSION} \
53+
&& sudo ln -fs /opt/selenium/operadriver-${OPERA_DRIVER_VERSION} /usr/bin/operadriver
54+
55+
COPY generate_config /opt/bin/generate_config
56+
57+
# Generating a default config during build time
58+
RUN /opt/bin/generate_config > /opt/selenium/config.json

NodeOpera/README-short.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Selenium Node configured to run Chromium based versions of Opera

NodeOpera/generate.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
VERSION=$1
3+
NAMESPACE=$2
4+
AUTHORS=$3
5+
6+
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" > ./Dockerfile
7+
echo "# NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED." >> ./Dockerfile
8+
echo "# PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE" >> ./Dockerfile
9+
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> ./Dockerfile
10+
echo FROM ${NAMESPACE}/node-base:${VERSION} >> ./Dockerfile
11+
echo LABEL authors="$AUTHORS" >> ./Dockerfile
12+
echo "" >> ./Dockerfile
13+
cat ./Dockerfile.txt >> ./Dockerfile

NodeOpera/generate_config

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
OPERA_VERSION=$(opera -version)
4+
5+
cat <<_EOF
6+
{
7+
"capabilities": [
8+
{
9+
"version": "$OPERA_VERSION",
10+
"browserName": "operablink",
11+
"maxInstances": $NODE_MAX_INSTANCES,
12+
"seleniumProtocol": "WebDriver",
13+
"applicationName": "$NODE_APPLICATION_NAME"
14+
}
15+
],
16+
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
17+
"maxSession": $NODE_MAX_SESSION,
18+
"host": "$NODE_HOST",
19+
"port": $NODE_PORT,
20+
"register": true,
21+
"registerCycle": $NODE_REGISTER_CYCLE,
22+
"nodePolling": $NODE_POLLING,
23+
"unregisterIfStillDownAfter": $NODE_UNREGISTER_IF_STILL_DOWN_AFTER,
24+
"downPollingLimit": $NODE_DOWN_POLLING_LIMIT,
25+
"debug": $GRID_DEBUG
26+
}
27+
_EOF

NodeOpera/wrap_opera_binary

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
WRAPPER_PATH=$(readlink -f /usr/lib/*-linux-gnu/opera/opera)
4+
BASE_PATH="$WRAPPER_PATH-base"
5+
mv "$WRAPPER_PATH" "$BASE_PATH"
6+
7+
cat > "$WRAPPER_PATH" <<_EOF
8+
#!/bin/bash
9+
10+
# Note: exec -a below is a bashism.
11+
exec -a "\$0" "$BASE_PATH" --no-sandbox "\$@"
12+
_EOF
13+
chmod +x "$WRAPPER_PATH"

NodeOperaDebug/README-short.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_This image is only intended for development purposes!_ Runs a Selenium Grid Node with a VNC Server to allow you to visually see the browser being automated.

0 commit comments

Comments
 (0)