Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f447e39

Browse files
authored
Merge pull request #2693 from seleniumbase/docker-overhaul
Docker overhaul and more
2 parents e87d738 + e864526 commit f447e39

File tree

9 files changed

+76
-89
lines changed

9 files changed

+76
-89
lines changed

‎Dockerfile

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
11
# SeleniumBase Docker Image
2-
FROM ubuntu:18.04
2+
FROM ubuntu:22.04
33

4-
#=======================================
5-
# Install Python and Basic Python Tools
6-
#=======================================
7-
RUN apt-get -o Acquire::Check-Valid-Until=false -o Acquire::Check-Date=false update
8-
RUN apt-get install -y python3 python3-pip python3-setuptools python3-dev python-distribute
9-
RUN alias python=python3
10-
RUN echo "alias python=python3" >> ~/.bashrc
4+
#============================
5+
# Install Linux Dependencies
6+
#============================
7+
RUN apt-get update && apt-get install -y \
8+
fonts-liberation \
9+
libasound2 \
10+
libatk-bridge2.0-0 \
11+
libatk1.0-0 \
12+
libatspi2.0-0 \
13+
libcups2 \
14+
libdbus-1-3 \
15+
libdrm2 \
16+
libgbm1 \
17+
libgtk-3-0 \
18+
libnspr4 \
19+
libnss3 \
20+
libwayland-client0 \
21+
libxcomposite1 \
22+
libxdamage1 \
23+
libxfixes3 \
24+
libxkbcommon0 \
25+
libxrandr2 \
26+
xdg-utils \
27+
libu2f-udev \
28+
libvulkan1
1129

1230
#=================================
1331
# Install Bash Command Line Tools
@@ -17,33 +35,24 @@ RUN apt-get -qy --no-install-recommends install \
1735
unzip \
1836
wget \
1937
curl \
20-
libxi6 \
21-
libgconf-2-4 \
2238
vim \
2339
xvfb \
2440
&& rm -rf /var/lib/apt/lists/*
2541

2642
#================
2743
# Install Chrome
2844
#================
29-
RUN curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
30-
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list && \
31-
apt-get -yqq update && \
32-
apt-get -yqq install google-chrome-stable && \
33-
rm -rf /var/lib/apt/lists/*
45+
RUN curl -LO https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
46+
RUN apt-get install -y ./google-chrome-stable_current_amd64.deb
47+
RUN rm google-chrome-stable_current_amd64.deb
3448

35-
#=================
36-
# Install Firefox
37-
#=================
38-
RUN apt-get -qy --no-install-recommends install \
39-
$(apt-cache depends firefox | grep Depends | sed "s/.*ends:\ //" | tr '\n' ' ') \
40-
&& rm -rf /var/lib/apt/lists/* \
41-
&& cd /tmp \
42-
&& wget --no-check-certificate -O firefox-esr.tar.bz2 \
43-
'https://download.mozilla.org/?product=firefox-esr-latest&os=linux64&lang=en-US' \
44-
&& tar -xjf firefox-esr.tar.bz2 -C /opt/ \
45-
&& ln -s /opt/firefox/firefox /usr/bin/firefox \
46-
&& rm -f /tmp/firefox-esr.tar.bz2
49+
#=======================================
50+
# Install Python and Basic Python Tools
51+
#=======================================
52+
RUN apt-get -o Acquire::Check-Valid-Until=false -o Acquire::Check-Date=false update
53+
RUN apt-get install -y python3 python3-pip python3-setuptools python3-dev python-distribute
54+
RUN alias python=python3
55+
RUN echo "alias python=python3" >> ~/.bashrc
4756

4857
#===========================
4958
# Configure Virtual Display
@@ -58,9 +67,9 @@ RUN exec "$@"
5867
# Update Python Version
5968
#=======================
6069
RUN apt-get update -y
61-
RUN apt-get -qy --no-install-recommends install python3.8
70+
RUN apt-get -qy --no-install-recommends install python3.10
6271
RUN rm /usr/bin/python3
63-
RUN ln -s python3.8 /usr/bin/python3
72+
RUN ln -s python3.10 /usr/bin/python3
6473

6574
#=============================================
6675
# Allow Special Characters in Python Programs
@@ -78,30 +87,20 @@ COPY integrations /SeleniumBase/integrations/
7887
COPY requirements.txt /SeleniumBase/requirements.txt
7988
COPY setup.py /SeleniumBase/setup.py
8089
RUN find . -name '*.pyc' -delete
81-
RUN find . -name __pycache__ -delete
8290
RUN pip3 install --upgrade pip setuptools wheel
8391
RUN cd /SeleniumBase && ls && pip3 install -r requirements.txt --upgrade
8492
RUN cd /SeleniumBase && pip3 install .
8593

86-
#=====================
87-
# Download WebDrivers
88-
#=====================
89-
RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.34.0/geckodriver-v0.34.0-linux64.tar.gz
90-
RUN tar -xvzf geckodriver-v0.34.0-linux64.tar.gz
91-
RUN chmod +x geckodriver
92-
RUN mv geckodriver /usr/local/bin/
93-
RUN wget https://chromedriver.storage.googleapis.com/72.0.3626.69/chromedriver_linux64.zip
94-
RUN unzip chromedriver_linux64.zip
95-
RUN chmod +x chromedriver
96-
RUN mv chromedriver /usr/local/bin/
94+
#=======================
95+
# Download chromedriver
96+
#=======================
97+
RUN sbase get chromedriver --path
9798

9899
#==========================================
99100
# Create entrypoint and grab example tests
100101
#==========================================
101102
COPY integrations/docker/docker-entrypoint.sh /
102-
COPY integrations/docker/run_docker_test_in_firefox.sh /
103103
COPY integrations/docker/run_docker_test_in_chrome.sh /
104104
RUN chmod +x *.sh
105-
COPY integrations/docker/docker_config.cfg /SeleniumBase/examples/
106105
ENTRYPOINT ["/docker-entrypoint.sh"]
107106
CMD ["/bin/bash"]

‎examples/raw_games.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""SB Manager using UC Mode for evading bot-detection."""
2+
from seleniumbase import SB
3+
4+
with SB(uc=True, test=True, disable_csp=True) as sb:
5+
url = "https://steamdb.info/"
6+
sb.driver.uc_open_with_reconnect(url, 3)
7+
sb.uc_click("a.header-login span", 4)
8+
if not sb.is_text_visible("Sign in", "button#js-sign-in"):
9+
sb.driver.uc_open_with_reconnect(url, 3)
10+
sb.uc_click("a.header-login span", 4)
11+
sb.assert_text("Sign in", "button#js-sign-in", timeout=3)
12+
sb.driver.uc_click("button#js-sign-in", 2)
13+
sb.highlight("div.page_content form")
14+
sb.highlight('button:contains("Sign in")', scroll=False)
15+
sb.set_messenger_theme(location="top_center")
16+
sb.post_message("SeleniumBase wasn't detected", duration=4)

‎integrations/docker/ReadMe.md

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,42 @@
11
## Docker setup instructions for SeleniumBase
22

3-
#### 1. Install the Docker Toolbox:
3+
#### 1. Install the Docker Desktop:
44

55
You can get that from here:
6-
https://www.docker.com/products/docker-toolbox
6+
https://www.docker.com/products/docker-desktop/
77

88
You might also want to install the Docker Engine:
9-
https://docs.docker.com/engine/installation/
9+
https://docs.docker.com/engine/install/
1010

11-
#### 2. Create your SeleniumBase Docker environment:
11+
#### 2. Go to the SeleniumBase home directory on the command line, which is where [Dockerfile](https://github.com/seleniumbase/SeleniumBase/blob/master/Dockerfile) is located. (This assumes you've already cloned the SeleniumBase repo.)
1212

13-
docker-machine create --driver virtualbox seleniumbase
14-
15-
##### (If your Docker environment ever goes down for any reason, you can bring it back up with a restart.)
16-
17-
docker-machine restart seleniumbase
18-
19-
#### 3. Configure your shell:
20-
21-
eval "$(docker-machine env seleniumbase)"
22-
23-
#### 4. Go to the SeleniumBase home directory on the command line, which is where [Dockerfile](https://github.com/seleniumbase/SeleniumBase/blob/master/Dockerfile) is located. (This assumes you've already cloned the SeleniumBase repo.)
24-
25-
#### 5. Create your Docker image from your Dockerfile: (Get ready to wait awhile)
13+
#### 3. Create your Docker image from your Dockerfile: (Get ready to wait awhile)
2614

2715
docker build -t seleniumbase .
2816

29-
If running on an Apple M1 Mac, use this instead:
17+
If running on an Apple M1/M2 Mac, use this instead:
3018

3119
docker build --platform linux/amd64 -t seleniumbase .
3220

33-
#### 6. Run [the example test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py) with Chrome inside your Docker: (Once the test completes after a few seconds, you'll automatically exit the Docker shell)
21+
M1/M2 Mac users should also see [StackOverflow.com/a/76586216/7058266](https://stackoverflow.com/a/76586216/7058266) to **Enable Rosetta in Docker Desktop**. (Otherwise **you will** encounter errors like this when Chrome tries to launch: `"Chrome failed to start: crashed."`)
3422

35-
docker run seleniumbase ./run_docker_test_in_chrome.sh
36-
37-
#### 7. Now run the same test with Firefox inside your Docker:
23+
#### 4. Run [the example test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py) with Chrome inside your Docker: (Once the test completes after a few seconds, you'll automatically exit the Docker shell)
3824

39-
docker run seleniumbase ./run_docker_test_in_firefox.sh
25+
docker run seleniumbase ./run_docker_test_in_chrome.sh
4026

41-
#### 8. You can also enter Docker and stay inside the shell:
27+
#### 5. You can also enter Docker and stay inside the shell:
4228

4329
docker run -i -t seleniumbase
4430

45-
#### 9. Now you can run the example test from inside the Docker shell:
31+
#### 6. Now you can run the example test from inside the Docker shell:
4632

4733
./run_docker_test_in_chrome.sh
4834

49-
#### 10. When you're satisfied, you may exit the Docker shell:
35+
#### 7. When you're satisfied, you may exit the Docker shell:
5036

5137
exit
5238

53-
#### 11. (Optional) Since Docker images and containers take up a lot of space, you may want to clean up your machine from time to time when they’re not being used:
39+
#### 8. (Optional) Since Docker images and containers take up a lot of space, you may want to clean up your machine from time to time when they’re not being used:
5440

5541
Details on that can be found here:
5642
http://stackoverflow.com/questions/17236796/how-to-remove-old-docker-containers
@@ -67,15 +53,10 @@ If you want to completely remove all of your Docker containers and images, use t
6753
docker rm -f $(docker ps -a -q)
6854
docker rmi -f $(docker images -q)
6955

70-
Finally, if you want to wipe out your SeleniumBase Docker virtualbox, use these commands:
71-
72-
docker-machine kill seleniumbase
73-
docker-machine rm seleniumbase
74-
7556
For more cleanup commands, check out:
7657
https://codefresh.io/blog/everyday-hacks-docker/
7758

78-
#### 13. (Optional) More reading on Docker can be found here:
59+
#### 9. (Optional) More reading on Docker can be found here:
7960
* https://docs.docker.com
8061
* https://docs.docker.com/get-started/
8162
* https://docs.docker.com/docker-for-mac/

‎integrations/docker/docker_config.cfg

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎integrations/docker/run_docker_test_in_firefox.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

‎mkdocs_build/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
regex>=2023年12月25日
55
pymdown-extensions>=10.7.1
6-
pipdeptree>=2.18.0
6+
pipdeptree>=2.18.1
77
python-dateutil>=2.8.2
88
Markdown==3.6
99
markdown2==2.4.13

‎requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pip>=24.0
22
packaging>=24.0
33
setuptools>=68.0.0;python_version<"3.8"
4-
setuptools>=69.2.0;python_version>="3.8"
4+
setuptools>=69.5.1;python_version>="3.8"
55
wheel>=0.42.0;python_version<"3.8"
66
wheel>=0.43.0;python_version>="3.8"
77
attrs>=23.2.0

‎seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.25.3"
2+
__version__ = "4.25.4"

‎setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
'pip>=24.0',
150150
'packaging>=24.0',
151151
'setuptools>=68.0.0;python_version<"3.8"',
152-
'setuptools>=69.2.0;python_version>="3.8"',
152+
'setuptools>=69.5.1;python_version>="3.8"',
153153
'wheel>=0.42.0;python_version<"3.8"',
154154
'wheel>=0.43.0;python_version>="3.8"',
155155
'attrs>=23.2.0',

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /