The use of Selenium technology in the CentOS7 container of the docker image on the Tencent Cloud Server of the CentOS6.8 system (in the Linux environment)

1. Explanation

Sometimes it may be necessary to create a CentOS7 container through docker on CentOS6.8 to test the application of Selenium technology. The following is what I have successfully explored.

2. Linux related commands during operation

1. Preliminary preparation

1.1 Search CentOS7 mirror

docker search centos:centos7

1.2 Pull the corresponding version

docker pull kriation/centos7

1.3 Start running the container

docker run -itd --privileged --name centos7 -v /test:/cent/test 镜像ID /bin/bash

2. Download related packages under CentOS

2.1 Install the decompression tool

yum install -y unzip

2.2 Install compilation tools

yum install -y make

2.3 Install the wget tool

yum install -y wget

3. Install python3.7 version

3.1 Add EPEL repository

yum install epel-release

3.2 Install the necessary packages

yum install -y gcc openssl-devel bzip2-devel libffi-devel zlib-devel

3.3 Jump to the /usr/src directory

cd /usr/src

3.4 Download python3.7 source code

wget https://www.python.org/ftp/python/3.7.12/Python-3.7.12.tgz

3.5 Decompression

tar xzf Python-3.7.12.tgz

3.6 Jump to the installation package

cd Python-3.7.12

3.7 Compile and install python3.7

first step

./configure --enable-optimizations

second step

make altinstall

3.7 Create soft links

Create a soft link to python3.7

ln -s /usr/local/bin/python3.7 /usr/local/bin/python3

Create a soft link to pip3

ln -s /usr/local/bin/pip3.7 /usr/bin/pip3

3.8 Verify that the installation is successful

python3 --version

3.9 Update pip3 to the highest version

pip3 install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple/

3.10 Download Selenium third-party library

The names of the third-party libraries required by python are all in requirements.txt to avoid the version mismatch of the third-party libraries (in addition, you must first upload requirements.txt to the mounted place in the server through xftp, and enter the mounted file Folder, and then execute the command, otherwise it will not work)

pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/

4. Install Google browser and driver

4.1 Install Google Chrome

yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm

4.2. View the version of Google Chrome

google-chrome --version

4.3 Install the driver compression package corresponding to the version of Google Chrome

wget https://chromedriver.storage.googleapis.com/113.0.5672.63/chromedriver_linux64.zip

4.4 Unzip the downloaded file

unzip chromedriver_linux64.zip

4.5 Mobile download files

mv chromedriver /usr/bin/

4.6 Give file execution permission

chmod +x /usr/bin/chromedriver

4.7 View Google Chrome version

chromedriver --version

Finally, you're done, you can test it yourself

Guess you like

Origin blog.csdn.net/qq_46106857/article/details/130712876