Search…
ENGLISH
How can I use Selenium?
Chrome WebDriver

From August 2021, the use of the Free plan's Chrome process becomes a reason for blocking the service policy and may cause the sanctioning of the use of the service.

Follow the instructions below to install Selenium, Chrome, ChromeDriver.

Install Selenium

1
pip3 install selenium
Copied!

Install Chrome

1
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
2
echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list
3
apt-get update
4
apt-get install -y google-chrome-stable
Copied!

Install ChromeDriver

It is necessary to install the ChromeDriver of a version that is compatible with the Chrome version installed in the previous step. Please follow the instructions below to check the Chrome version and install the correct version of the ChromeDriver.

Check the Chrome version

1
google-chrome --version
Copied!

Check the ChromeDriver version to be installed

Download the ChromeDriver

You can download the ChromeDriver via the following terminal command. Replace the text [ChromeDriver Version] with the version number you checked in the previous step.
1
wget -N https://chromedriver.storage.googleapis.com/[ChromeDriver Version]/chromedriver_linux64.zip
Copied!
What is expected to seem like when the download is completed

Install the ChromeDriver

Enter the following command to complete the installation of the downloaded ChromeDriver.
1
unzip chromedriver_linux64.zip
2
chmod +x chromedriver
3
mv -f chromedriver /usr/local/share/chromedriver
4
ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
5
ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
6
rm chromedriver_linux64.zip
7
apt-get update
8
apt-get install -y libgconf-2-4
Copied!

Python code example

1
from selenium import webdriver
2
from selenium.webdriver.chrome.options import Options
3
4
options = Options()
5
options.add_argument("--headless")
6
options.add_argument("--no-sandbox")
7
8
driver = webdriver.Chrome(options=options)
9
driver.get('https://google.com')
10
driver.quit()
Copied!
When using the headless option as above, it is normal that a new window of the Chrome browser does not appear. Since the goormIDE container is an environment without a display, you must use the headless option when using Selenium.
Last modified 2mo ago