Skip to content

Commit

Permalink
Fix selenium browsing in dev container
Browse files Browse the repository at this point in the history
  • Loading branch information
jik-ai committed Apr 15, 2023
1 parent 6a93537 commit 414bd4c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .devcontainer/Dockerfile
Expand Up @@ -10,6 +10,18 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# They are installed by the base image (python) which does not have the patch.
RUN python3 -m pip install --upgrade setuptools

# We don't need the standalone Chromium
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true

# Install Google Chrome Stable and fonts
# Note: this installs the necessary libs to make the browser work with Puppeteer.
RUN apt-get update && apt-get install gnupg wget -y && \
wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
apt-get update && \
apt-get install google-chrome-stable -y --no-install-recommends && \
rm -rf /var/lib/apt/lists/*

# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
# COPY requirements.txt /tmp/pip-tmp/
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
Expand Down
6 changes: 6 additions & 0 deletions autogpt/web.py
Expand Up @@ -34,6 +34,12 @@ def scrape_text_with_selenium(url):
options.add_argument(
"user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.5615.49 Safari/537.36"
)
options.add_argument("--headless") # Runs Chrome in headley -ss mode.
options.add_argument('--no-sandbox') # # Bypass OS security model
options.add_argument('start-maximized')
options.add_argument('disable-infobars')
options.add_argument("--disable-extensions")

driver = webdriver.Chrome(
executable_path=ChromeDriverManager().install(), options=options
)
Expand Down

2 comments on commit 414bd4c

@pretannikai
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixed it. This should make it back into the stable branch, somehow. I'm not sure what's going on with recent changes, but 'stable' has been far from stable lately.

@m8l91
Copy link

@m8l91 m8l91 commented on 414bd4c Apr 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this just adds a new error for me running inside of docker.

Command browse_website returned: Error: Message: invalid argument (Session info: headless chrome=112.0.5615.121) Stacktrace: #0 0x55b6b71c1fe3 #1 0x55b6b6f00bc1 #2 0x55b6b6eeb446 #3 0x55b6b6ee97f3 #4 0x55b6b6ee9c3d #5 0x55b6b6f02b16 #6 0x55b6b6f778c5 #7 0x55b6b6f5e8c2 #8 0x55b6b6f77232 #9 0x55b6b6f5e693 #10 0x55b6b6f3103a #11 0x55b6b6f3217e #12 0x55b6b7183dbd #13 0x55b6b7187c6c #14 0x55b6b71914b0

Please sign in to comment.