How can I use Selenium?
Chrome WebDriver
Follow the instructions below to install Selenium, Chrome, ChromeDriver.
pip3 install selenium
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list
apt-get update
apt-get install -y google-chrome-stable
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.
google-chrome --version


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.wget -N https://chromedriver.storage.googleapis.com/[ChromeDriver Version]/chromedriver_linux64.zip

What is expected to seem like when the download is completed
Enter the following command to complete the installation of the downloaded ChromeDriver.
unzip chromedriver_linux64.zip
chmod +x chromedriver
mv -f chromedriver /usr/local/share/chromedriver
ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
rm chromedriver_linux64.zip
apt-get update
apt-get install -y libgconf-2-4
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("--headless")
options.add_argument("--no-sandbox")
driver = webdriver.Chrome(options=options)
driver.get('https://google.com')
driver.quit()
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 1yr ago