Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make tests run in display mode #298

Merged
merged 2 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM clojure:lein-2.9.3
RUN apt-get -yqq update && \
apt-get -yqq upgrade && \
apt-get -yqq install gnupg2 && \
apt-get -yqq install curl unzip && \
apt-get -yqq install xvfb curl unzip && \
apt-get -yqq install fonts-ipafont-gothic xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic && \
apt-get install -y ca-certificates jq libfontconfig libgconf-2-4 && \
rm -rf /var/lib/apt/lists/*
Expand Down Expand Up @@ -52,11 +52,14 @@ RUN PHANTOMJS_VERSION=phantomjs-2.1.1-linux-x86_64 && \
# which seems to be a recent bug.
ENV OPENSSL_CONF=/opt/openssl.cnf

WORKDIR /etaoin
COPY ./ ./
RUN lein deps
COPY ./ /etaoin
RUN cd /etaoin && lein deps && rm -rf /etaoin

WORKDIR /
RUN rm -rf /etaoin
ENV DISPLAY :99
RUN printf '#!/bin/sh\nXvfb :99 -screen 0 1280x1024x24 &\nexec "$@"\n' > /tmp/entrypoint \
&& chmod +x /tmp/entrypoint \
&& mv /tmp/entrypoint /entrypoint.sh

ENV ETAOIN_TEST_DRIVERS="[:firefox :chrome :phantom]"

ENTRYPOINT ["/entrypoint.sh"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ docker-build:
.PHONY: docker-test
docker-test:
docker run --rm \
-v $(CURDIR)/:/etaoin \
-v ${CURDIR}:/etaoin \
-w /etaoin ${IMAGE}:latest \
lein test
6 changes: 4 additions & 2 deletions test/etaoin/api_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
[:firefox :chrome :phantom :safari])

(def default-opts
{:chrome {:args ["--headless" "--no-sandbox"]}
:firefox {:args ["--headless"]}
{:chrome {:args ["--no-sandbox"]}
:firefox {}
:safari {:path-driver "/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver"}
:edge {:args ["--headless"]}})

Expand Down Expand Up @@ -425,6 +425,8 @@
(is (= new-handle target-handle))
(is (not= init-url target-url))))

;; need refactoring not working for headless & firefox
#_
(deftest test-maximize
(when-not-headless *driver*
(let [{:keys [x y]} (get-window-position *driver*)
Expand Down
7 changes: 3 additions & 4 deletions test/etaoin/api_test2.clj
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@


;; TODO: https://github.com/igrishaev/etaoin/issues/296
#_
(deftest test-chrome-profile
(let [profile-path (str (Files/createTempDirectory
"chrome-profile"
(into-array FileAttribute [])))]
(with-chrome-headless {:profile profile-path :args ["--no-sandbox"]} driver
"chrome-profile"
(into-array FileAttribute [])))]
(with-chrome {:profile profile-path :args ["--no-sandbox"]} driver
(go driver "chrome://version")
(is profile-path
(get-element-text driver :profile_path)))))
Expand Down