{"id":1,"date":"2024-12-03T17:33:02","date_gmt":"2024-12-03T17:33:02","guid":{"rendered":"https:\/\/www.glencoulson.com\/?p=1"},"modified":"2024-12-03T19:36:09","modified_gmt":"2024-12-03T19:36:09","slug":"hello-world","status":"publish","type":"post","link":"https:\/\/www.glencoulson.com\/index.php\/2024\/12\/03\/hello-world\/","title":{"rendered":"How to Install and setup Selenium with chrome on Linux (Debian)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Using Selenium, you can run predefined code to navigate multiple pages, closing tickets, notating projects, or adding tasks.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this guide will see how to install and set up selenium with chrome on linux and Other Debian-based systems.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Basic Requirements<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We will use a python program to automate. Before this, make sure that you have installed the following Package.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Python3 installed on your Ubuntu\/Debian rig.\nPIP3 installed on your Ubuntu\/Debian rig.\nGoogle chrome installed on your Ubuntu\/Debian system.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now we will start the installation process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 1: Create Python3 Virtual Environment<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First of all we install virtualenv using pip3 command type the following command in terminal.<br>$ sudo pip3 install virtualenv<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It\u2019s OK to use sudo for this initial command even though your debian distribution may warn against it\u2026 notice from here forward we drop off the sudo.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A benefit of installing virtualenv will create isolated python3 environment, which will ensure that you don\u2019t wreck your old programs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Modules you import for this project will save in the current project directory, not globally.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After virtualenv download you need to create project directory at any location. To create directory use<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ mkdir -p selenium_chrome\/drivers<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">cd to created folder directory selenium_chrome using change directory command.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ cd selenium_chrome<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now we will setup or create Python Virtual environment in the current project directory using the below command:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Command Syntax<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ virtualenv .virtualenvirnomentname<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In mycase (for demo purposes)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ virtualenv .dem_environment<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create Virtual Environment<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After completing above step now we want to activate the Python virtual environment to activate pass command:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Command Syntax<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ source .virtualenvironmentname\/bin\/activate<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In mycase<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ source .dem_environment\/bin\/activate<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 2: How to Install Selenium Python Library<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is pretty simple to install selenium on Python Because selenium is available on the Python PyPI repository So, you need to leverage the pip command:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ pip3 install selenium<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The important thing is getting a non-global instance going because selenium and python are changing all the time and dependency hell happens occasionally breaking installation as one piece is upgraded and not the other. Once you get a working instance going you can keep that instance chugging away as your global installation can update\/upgrade with the system.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Selenium is installed successfully, and Now we will install Chrome driver.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 3: Installing the Chrome Driver<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A single pip3 command will make short work of installing your Chrome driver.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">pip3 install webdriver-manage<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Paste the following code into a script:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">import time<br>from selenium import webdriver<br>from selenium.webdriver.common.keys import Keys<br>from selenium.webdriver.chrome.options import Options<br>chromeOptions = Options()<br>chromeOptions.headless = True<br>browser = webdriver.Chrome(executable_path=\u201d.\/drivers\/chromedriver\u201d, options=ch&gt;<br>browser.get(\u201chttps:\/\/www.glencoulson.com\u201d)<br>print(\u201cTitle: %s\u201d % browser.title)<br>browser.quit()<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using Selenium, you can run predefined code to navigate multiple pages, closing tickets, notating projects, or adding tasks. In this guide will see how to install and set up selenium with chrome on linux and Other Debian-based systems. Basic Requirements We will use a python program to automate. Before this, make sure that you have [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/posts\/1","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"count":2,"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"predecessor-version":[{"id":14,"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/posts\/1\/revisions\/14"}],"wp:attachment":[{"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glencoulson.com\/index.php\/wp-json\/wp\/v2\/tags?post=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}