Ubuntu Server: How to Install Chrome

Install Google without interface

1. Install chrome on the command line of Ubuntu server version

sudo apt-get install libxss1 libappindicator1 libindicator7
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb # Might show "errors", fixed by next line
sudo apt-get install -f
google-chrome --version # check the version

2. Drivers of different browsers

Chrome:https://sites.google.com/a/chromium.org/chromedriver/downloads

Firefox:https://github.com/mozilla/geckodriver/releases

Edge:https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

Safari:https://webkit.org/blog/6900/webdriver-support-in-safari-10/

3. Test whether the installation is successful

from selenium import webdriver
 
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--no-sandbox')
client = webdriver.Chrome(chrome_options=chrome_options, executable_path='your path')   
client.get("https://www.baidu.com")
print (client.page_source.encode('utf-8'))
client.quit()

4. Error in running selenium, permission denied. Add executable permissions to driver files

command: sudo chmod +x chromedriver

Read More: