Skip to content

Commit

Permalink
added selenium & chrome support
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderward committed Apr 20, 2021
1 parent 46419e5 commit c732405
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
14 changes: 9 additions & 5 deletions dev_env/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def offline():
Prompt.error("Docker Engine is offline. Please start before continuing.")
sys.exit(1)

self.execute("docker info", {}, display_stdout=False, show_notice=False, on_error_fn=offline)
self.execute("docker info", {}, display_stdout=False, show_notice=False, on_error_fn=offline,
display_stderr=False)

def create_secret(self):
import secrets
Expand All @@ -71,7 +72,7 @@ def cleanup(self):
proc.terminate()

def execute(self, cmd, env_dict, display_stdout=True, on_error_fn=None, show_env=False, show_notice=True,
exit_on_fail=True, threaded=False):
exit_on_fail=True, threaded=False, display_stderr=True):
env = os.environ.copy()
normalized_dict = {}
for key, value in env_dict.items():
Expand All @@ -92,8 +93,10 @@ def execute(self, cmd, env_dict, display_stdout=True, on_error_fn=None, show_env
proc.start()
self.BACKGROUND_PROCS.append(proc)
else:
with subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
bufsize=0, env=env) as proc:
args = dict(stdout=subprocess.PIPE, bufsize=0, env=env)
if not display_stderr:
args.update(dict(stderr=subprocess.DEVNULL))
with subprocess.Popen(cmd, **args) as proc:
for line in proc.stdout:
formatted = line.rstrip().decode('utf-8', 'ignore')
output += formatted
Expand Down Expand Up @@ -131,7 +134,7 @@ class Runner(HelperMixin, ABC):
REQUIRED_PORTS = [] # Verifies to see if ports are available

def execute(self, cmd, env_dict=None, display_stdout=True, on_error_fn=None, show_env=False, show_notice=True,
exit_on_fail=True, threaded=False):
exit_on_fail=True, threaded=False, display_stderr=True):
if not env_dict:
env_dict = {}
return super().execute(cmd,
Expand All @@ -140,6 +143,7 @@ def execute(self, cmd, env_dict=None, display_stdout=True, on_error_fn=None, sho
show_notice=show_notice,
threaded=threaded,
exit_on_fail=exit_on_fail,
display_stderr=display_stderr,
on_error_fn=on_error_fn if on_error_fn else self.on_fail, show_env=show_env)

def check_ports(self, raise_exception=True):
Expand Down
13 changes: 13 additions & 0 deletions dev_env/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ RUN apt-get update && apt-get -y install \
graphviz pandoc \
gunicorn

ENV CHROME_VERSION "google-chrome-stable"
RUN sed -i -- 's&deb http://deb.debian.org/debian jessie-updates main&#deb http://deb.debian.org/debian jessie-updates main&g' /etc/apt/sources.list \
&& apt-get update && apt-get install wget -y
ENV CHROME_VERSION "google-chrome-stable"

This comment has been minimized.

Copy link
@gregelin

gregelin Apr 21, 2021

Contributor

@alexanderward You have ENV CHROME_VERSION set twice. Is the sed command changing or reseting `CHROME_VERSION

RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list \
&& apt-get update && apt-get -qqy install ${CHROME_VERSION:-google-chrome-stable}

# Chromium for Headless Selenium tests
RUN wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`/chromedriver_linux64.zip \
&& unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/
ENV DISPLAY=:99

# Put the Python source code here.
WORKDIR /usr/src/app

Expand Down
1 change: 1 addition & 0 deletions siteapp/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def setUpClass(cls):

if HEADLESS:
options.add_argument('--headless')
options.add_argument('--no-sandbox')

# Set up selenium Chrome browser for Windows or Linux
if DOS:
Expand Down

0 comments on commit c732405

Please sign in to comment.