JackYumCha / QA

Question and Answer
0 stars 0 forks source link

Commands to Install Chrome and ChromeDriver in Ubuntu 16.04 #11

Open JackYumCha opened 6 years ago

JackYumCha commented 6 years ago
  1. Install Chrome from Command Line: https://www.linuxbabe.com/ubuntu/install-google-chrome-ubuntu-16-04-lts

1) Add “deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main” to “/etc/apt/sources.list” OR echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list

2) Download Google Chrome Signing Key: wget https://dl.google.com/linux/linux_signing_key.pub 2) Add the new key to keyring for package manager
sudo apt-key add linux_signing_key.pub 3) Update package manager and install chrome sudo apt update sudo apt install google-chrome-stable

  1. Install Zip UnZip 1) Update apt-get update 2) Install Zip UnZip apt-get install zip unzip

  2. Install Selenium Chrome Driver https://gist.github.com/ziadoz/3e8ab7e944d02fe872c3454d17af31a5 1) Download Chrome Driver wget -N http://chromedriver.storage.googleapis.com/2.37/chromedriver_linux64.zip 2) unzip Chrome Driver unzip chromedriver_linux64.zip 3) change mode chmod +x chromedriver 4) move chromedriver and create hardlink, then chromedriver can be found in the ubuntu “PATH” sudo mv -f chromedriver /usr/local/share/chromedriver sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver

  3. Install .Net Core 2 in Ubuntu 16.04 https://github.com/dotnet/docs/blob/master/docs/core/linux-prerequisites.md 1) Register the Microsoft Product key as trusted. curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg 2) Set up the desired version host package feed. sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list' sudo apt-get update 3) Install .NET Core sudo apt-get install dotnet-sdk-2.1.4 4) Run the dotnet --version command to prove the installation succeeded dotnet --version

With the setup above, google-chrome and selenium should work for both python and C# .Net Core 2.1.4. In C#, the --no-sandbox argument must be added as well to run in linux.

Schedule a Task via crontab https://crontab.guru/

----- the following steps are not required

  1. Install Python 0) Test python version python3 --version Python 2 and 3 were preinstalled.

  2. Install pip 1) Download get-pip.py curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py 2) Install pip python get-pip.py python3 get-pip.py

  3. Install Selenium for Python3 1) install selenium pip3 install selenium

  4. Important Tip 1) The following codes are necessary. --no-sandbox is very important for sudo mode of google chrome. chromeOptions = Options() chromeOptions.add_argument('--headless') chromeOptions.add_argument('--disable-gpu') chromeOptions.add_argument('--no-sandbox') driver = webdriver.Chrome(chrome_options=chromeOptions)

  5. Install Xvfb (it is found not necessary for linux when with --headless and --disable-gpu) 1) Instal Xvfb sudo apt-get install xvfb xserver-xephyr vnc4server 2) Install Virtual Display sudo pip install pyvirtualdisplay 3) Optional: sudo apt-get install python-pil scrot sudo pip install pyscreenshot