{"id":2338,"date":"2020-04-03T17:22:53","date_gmt":"2020-04-03T17:22:53","guid":{"rendered":"https:\/\/www.h2kinfosys.com\/blog\/?p=2338"},"modified":"2026-08-29T07:16:30","modified_gmt":"2026-08-29T11:16:30","slug":"running-selenium-test-on-chrome-browser","status":"publish","type":"post","link":"https:\/\/www.h2kinfosys.com\/blog\/running-selenium-test-on-chrome-browser\/","title":{"rendered":"Running Selenium Test on Chrome Browser"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><span style=\"font-weight: 400;\">In this article, you will learn about <strong>Running Selenium Test on Chrome Browser<\/strong>&nbsp;<\/span><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">How to run Selenium Tests on Chrome Browser<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">How to download the latest version of ChromeDriver<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">How to setup ChromeDriver in different ways.<\/span><\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"font-weight: 400;\">Chrome driver implements the WebDriver protocol using an executable file called ChromeDriver.exe. The executable file starts a server on your system and all your tests are responsible to run your tests to communicate to this server.<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><b>How to download latest version of ChromeDriver<\/b><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">ChromeDriver is essential for <strong>Running Selenium Test on Chrome Browser<\/strong>. To download the latest version of ChromeDriver, visit the official ChromeDriver website, where you can find links to the most recent releases. Ensure compatibility with your installed version of Chrome by selecting the corresponding driver version. Follow the installation instructions provided on the site to set up ChromeDriver effectively.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"font-weight: 400;\">To work with ChromeDriver, first we have to download the latest version of ChromeDriver. To download the latest version of ChromeDriver we need to follow the below steps:<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><b>Step1:<\/b><span style=\"font-weight: 400;\"> Go to the official website of chrome driver (<\/span><a href=\"https:\/\/sites.google.com\/a\/chromium.org\/chromedriver\/\" rel=\"nofollow noopener\" target=\"_blank\"><span style=\"font-weight: 400;\">https:\/\/sites.google.com\/a\/chromium.org\/chromedriver\/<\/span><\/a><span style=\"font-weight: 400;\">) and download the latest version of <a href=\"https:\/\/sites.google.com\/a\/chromium.org\/chromedriver\/\" rel=\"nofollow noopener\" target=\"_blank\">ChromeDriver <\/a>based on your operating system.<\/span><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" width=\"758\" height=\"518\" src=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_84.png\" alt=\"\" class=\"wp-image-2339\" title=\"\" srcset=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_84.png 758w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_84-300x205.png 300w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_84-220x150.png 220w\" sizes=\"(max-width: 758px) 100vw, 758px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><b>Step2:<\/b><span style=\"font-weight: 400;\"> Click on Downloads link<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"763\" height=\"495\" src=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_85.png\" alt=\"\" class=\"wp-image-2340\" title=\"\" srcset=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_85.png 763w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_85-300x195.png 300w\" sizes=\"(max-width: 763px) 100vw, 763px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><b>Step3:<\/b><span style=\"font-weight: 400;\"> Click on<\/span> <a href=\"https:\/\/chromedriver.storage.googleapis.com\/index.html?path=81.0.4044.69\/\" rel=\"nofollow noopener\" target=\"_blank\"><b>ChromeDriver<\/b> <b>81.0.4044.69<\/b><\/a> <span style=\"font-weight: 400;\">link. You will be navigated to ChromeDriver Index Download page for Mac, Linux and Windows operating systems.<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><b>Note: <\/b><span style=\"font-weight: 400;\">Based on your Windows Operating System, you need to download the corresponding ChromeDriver. Here we are working on Windows Operating System, you need to download the Windows version Chrome driver. If your operating system is Mac or Linux you need to download the corresponding Chrome driver.<\/span><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"782\" height=\"285\" src=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_86.png\" alt=\"\" class=\"wp-image-2341\" title=\"\" srcset=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_86.png 782w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_86-300x109.png 300w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_86-768x280.png 768w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_86-780x285.png 780w\" sizes=\"(max-width: 782px) 100vw, 782px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><b>Step4:<\/b><span style=\"font-weight: 400;\"> Click on<\/span> <a href=\"https:\/\/chromedriver.storage.googleapis.com\/index.html?path=81.0.4044.69\/\" rel=\"nofollow noopener\" target=\"_blank\"><b>chromedriver_win32.zip<\/b><\/a> <span style=\"font-weight: 400;\">to<\/span> <span style=\"font-weight: 400;\">download<\/span> <span style=\"font-weight: 400;\">ChromeDriver for Windows Operating System.<\/span><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"749\" height=\"268\" src=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_87.png\" alt=\"\" class=\"wp-image-2342\" title=\"\" srcset=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_87.png 749w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_87-300x107.png 300w\" sizes=\"(max-width: 749px) 100vw, 749px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><b>Step5: <\/b> <span style=\"font-weight: 400;\">Unzip the downloaded file to retrieve <\/span><b>chromedriver.exe<\/b><span style=\"font-weight: 400;\">. To instantiate the driver, you need to note down the location where you extracted the ChromeDriver.<\/span><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"756\" height=\"208\" src=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_88.png\" alt=\"\" class=\"wp-image-2343\" title=\"\" srcset=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_88.png 756w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_88-300x83.png 300w\" sizes=\"(max-width: 756px) 100vw, 756px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><b>Chrome Browser Launch using Selenium WebDriver<\/b><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"font-weight: 400;\">Like any other driver launching Chrome driver launching is very easy.<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><b>WebDriver = new ChromeDriver();<\/b><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><b>Consider the below example to launch the ChromeDriver<\/b><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>package&nbsp; <\/b><span style=\"font-weight: 400;\">com.testing.selenium.Chrome;<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>import org<\/b><span style=\"font-weight: 400;\">.openqa.selenium.WebDriver;<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>import <\/b><span style=\"font-weight: 400;\">org.openqa.selenium.chrome.ChromeDriver;<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>public class <\/b><span style=\"font-weight: 400;\">ChromeDriver<\/span><b> {<\/b><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>public static void <\/b><span style=\"font-weight: 400;\">main(String[] args)<\/span> <span style=\"font-weight: 400;\">{<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><span style=\"font-weight: 400;\">WebDriver<\/span> <span style=\"font-weight: 400;\">driver<\/span><b>= new <\/b><span style=\"font-weight: 400;\">ChromeDriver();<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><span style=\"font-weight: 400;\">driver.get(&#8220;<\/span><a href=\"https:\/\/in.yahoo.com\/?p=us\" rel=\"nofollow noopener\" target=\"_blank\"><span style=\"font-weight: 400;\">https:\/\/in.yahoo.com\/?p=us<\/span><\/a><span style=\"font-weight: 400;\">&#8220;);<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/b><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>}<\/b><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"font-weight: 400;\">When you run the above program we get an exception <\/span><b>java.lang.IllegalStateException.<\/b><b><i>&nbsp;<\/i><\/b><span style=\"font-weight: 400;\">Which gives&nbsp;\u201c<\/span><b>T<\/b><b>he executable driver must be set by webdriver.chrome.driver path.\u201d<\/b><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"font-weight: 400;\">To overcome the above exception we need to download the ChromeDriver to work with selenium commands.&nbsp; For every browser have a driver, the driver for Chrome is ChromeDriver.<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><b>Different Methods to initialize ChromeDriver<\/b><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"font-weight: 400;\">Below are the two methods to initialize ChromeDriver<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>By using WebDriver.Chrome.Driver System Property<\/li>\n\n\n\n<li>By using Environment Variables<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><b>Method 1: Using WebDriver.Chrome.Driver System Property<\/b><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"font-weight: 400;\">Below is the code to set the System Property for ChromeDriver<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><b>System.setProperty(\u201cwebdriver.chrome.driver\u201d,\u201cPath to chromedriver.exe\u201d);<\/b><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><b>Below is the complete program to launch the ChromeDriver<\/b><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>Package&nbsp; <\/b><span style=\"font-weight: 400;\">com.testing.selenium.ChromeDriver;<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>import&nbsp; <\/b><span style=\"font-weight: 400;\">org.openqa.selenium.WebDriver;<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>import&nbsp; <\/b><span style=\"font-weight: 400;\">org.openqa.selenium.chrome.ChromeDriver;<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>public class <\/b><span style=\"font-weight: 400;\">ChromeDriver<\/span> <span style=\"font-weight: 400;\">{<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>public static void <\/b><span style=\"font-weight: 400;\">main(String[] args) {<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/b><span style=\"font-weight: 400;\">System.setProperty<\/span><b>(&#8220;webdriver.chrome.driver&#8221;,&#8221;D:\\\\Testing\\\\Drivers\\\\chromedriver.exe&#8221;);<\/b><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b> &nbsp; <\/b><span style=\"font-weight: 400;\">WebDriver<\/span> <span style=\"font-weight: 400;\">driver<\/span><b>= new <\/b><span style=\"font-weight: 400;\">ChromeDriver();<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b> &nbsp; <\/b><span style=\"font-weight: 400;\">driver.get(&#8220;<\/span><a href=\"https:\/\/in.yahoo.com\/?p=us\" rel=\"nofollow noopener\" target=\"_blank\"><span style=\"font-weight: 400;\">https:\/\/in.yahoo.com\/?p=us<\/span><\/a><span style=\"font-weight: 400;\">&#8220;);<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"font-weight: 400; color: #800080;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String PageTitle = driver.getTitle();<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/b><span style=\"font-weight: 400;\">System.out.println(<\/span><b>&#8220;Page Title is:&#8221; <\/b><span style=\"font-weight: 400;\">+<\/span> <span style=\"font-weight: 400;\">PageTitle);<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"font-weight: 400; color: #800080;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;driver.close();<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/b><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>}<\/b><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"font-weight: 400;\">When you run the above program it will open <\/span><b>yahoo.com <\/b><span style=\"font-weight: 400;\">website in the new Chrome Browser and prints the website title.<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><b>Method 2: By using Environment Variables<\/b><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><b>Step<\/b> <b>1:<\/b><span style=\"font-weight: 400;\"> Go to <\/span><b>My Computer <\/b><span style=\"font-weight: 400;\">-&gt; Right<\/span> <span style=\"font-weight: 400;\">click<\/span> <span style=\"font-weight: 400;\">and click on<\/span><b> Properties<\/b><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"598\" height=\"482\" src=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_89.png\" alt=\"\" class=\"wp-image-2344\" title=\"\" srcset=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_89.png 598w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_89-300x242.png 300w\" sizes=\"(max-width: 598px) 100vw, 598px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><b>Step 2: <\/b><span style=\"font-weight: 400;\">Click<\/span> <span style=\"font-weight: 400;\">on <\/span><b>Change settings<\/b><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"747\" height=\"406\" src=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_90.png\" alt=\"\" class=\"wp-image-2345\" title=\"\" srcset=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_90.png 747w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_90-300x163.png 300w\" sizes=\"(max-width: 747px) 100vw, 747px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><b>Step 3: <\/b><span style=\"font-weight: 400;\">Click<\/span> <span style=\"font-weight: 400;\">on <\/span><b>Advanced <\/b><span style=\"font-weight: 400;\">tab and Click on<\/span><b> Environment Variables.<\/b><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"530\" height=\"601\" src=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_91.png\" alt=\"\" class=\"wp-image-2346\" title=\"\" srcset=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_91.png 530w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_91-265x300.png 265w\" sizes=\"(max-width: 530px) 100vw, 530px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><b>Step 4: <\/b><span style=\"font-weight: 400;\">Select Path under <\/span><b>System Variables<\/b><span style=\"font-weight: 400;\"> and Click <\/span><b>Edit<\/b><span style=\"font-weight: 400;\"> button.<\/span><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"746\" height=\"718\" src=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_92.png\" alt=\"\" class=\"wp-image-2347\" title=\"\" srcset=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_92.png 746w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_92-300x289.png 300w\" sizes=\"(max-width: 746px) 100vw, 746px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><b>Step 5:<\/b><span style=\"font-weight: 400;\"> Use <\/span><b>semicolon<\/b><span style=\"font-weight: 400;\"> at the end of the Variable value and paste the <\/span><b>ChromeDriver<\/b><span style=\"font-weight: 400;\"> path. On my computer my ChromeDriver exe is at <\/span><b>D:\\Testing\\Drivers<\/b><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"708\" height=\"673\" src=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_93.png\" alt=\"\" class=\"wp-image-2348\" title=\"\" srcset=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_93.png 708w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/04\/Screenshot_93-300x285.png 300w\" sizes=\"(max-width: 708px) 100vw, 708px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><b>Note:<\/b><span style=\"font-weight: 400;\"> You would not need to set the ChromeDriver System property every time in the script it is a one time job. Now your script will work without giving System Property code.<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><b>Below is the program to launch the ChromeDriver<\/b><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>package&nbsp; <\/b><span style=\"font-weight: 400;\">com<\/span><b>.<\/b><span style=\"font-weight: 400;\">testing.selenium.Chrome;<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>import <\/b><span style=\"font-weight: 400;\">org<\/span><b>.<\/b><span style=\"font-weight: 400;\">openqa.selenium.WebDriver;<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>import <\/b><span style=\"font-weight: 400;\">org<\/span><b>.<\/b><span style=\"font-weight: 400;\">openqa.selenium.chrome.ChromefoxDriver;<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>public class <\/b><span style=\"font-weight: 400;\">ChromeDriver<\/span> <span style=\"font-weight: 400;\">{<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>&nbsp;&nbsp;&nbsp;&nbsp;public static void <\/b><span style=\"font-weight: 400;\">main(String[] args) {<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>&nbsp;&nbsp;&nbsp;&nbsp;<\/b><span style=\"font-weight: 400;\">WebDriver<\/span> <span style=\"font-weight: 400;\">driver<\/span><b> = new <\/b><span style=\"font-weight: 400;\">ChromeDriver();<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>&nbsp;&nbsp;&nbsp;<\/b><span style=\"font-weight: 400;\">driver.get(&#8220;<\/span><a href=\"https:\/\/in.yahoo.com\/?p=us\" rel=\"nofollow noopener\" target=\"_blank\"><span style=\"font-weight: 400;\">https:\/\/in.yahoo.com\/?p=us<\/span><\/a><span style=\"font-weight: 400;\">&#8220;);<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"font-weight: 400; color: #800080;\">&nbsp;&nbsp;&nbsp;&nbsp;String PageTitle = driver.getTitle();<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>&nbsp;&nbsp;&nbsp;&nbsp;<\/b><span style=\"font-weight: 400;\">System.out.println(<\/span><b>&#8220;Page Title is:&#8221; <\/b><span style=\"font-weight: 400;\">+<\/span> <span style=\"font-weight: 400;\">PageTitle);<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"font-weight: 400; color: #800080;\">&nbsp;&nbsp;&nbsp;&nbsp;driver.close();<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>&nbsp;&nbsp;&nbsp;&nbsp;<\/b><span style=\"font-weight: 400;\">}<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #800080;\"><b>&nbsp;<\/b><span style=\"font-weight: 400;\">}<\/span><\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"font-weight: 400;\">When you run the above program and your script will run without the System Property code and it will open <\/span><b>yahoo.com <\/b><span style=\"font-weight: 400;\">website in the new Chrome Browser and prints the website title.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">FAQs<\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1788001884789\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">What is ChromeDriver in Selenium?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>ChromeDriver is a standalone executable that enables Selenium WebDriver to communicate with and control the Google Chrome browser for automated testing.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1788001950833\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">How do I download ChromeDriver?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>You can download ChromeDriver by selecting the version compatible with your installed Chrome browser and operating system, then extracting the downloaded file to a suitable location on your computer.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1788001955505\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">Why do I get the \u201cwebdriver.chrome.driver\u201d error?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>This error usually occurs when Selenium cannot locate the ChromeDriver executable. You need to specify the ChromeDriver path using a system property or configure the driver location through environment variables.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1788001957182\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">What are the different ways to initialize ChromeDriver?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>ChromeDriver can be initialized by setting the <code>webdriver.chrome.driver<\/code> system property or by adding the ChromeDriver location to the system environment variables.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1788001961710\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">Do I need to set the ChromeDriver path in every Selenium script?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>No. If the ChromeDriver location is configured correctly in the system environment variables, you do not need to specify the system property in every Selenium script.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>In this article, you will learn about Running Selenium Test on Chrome Browser&nbsp; Chrome driver implements the WebDriver protocol using an executable file called ChromeDriver.exe. The executable file starts a server on your system and all your tests are responsible to run your tests to communicate to this server. How to download latest version of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6494,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":"","_members_access_role":[],"_members_access_error":""},"categories":[43],"tags":[471,470,468,45,469],"class_list":["post-2338","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-selenium-tutorials","tag-browser","tag-chrome","tag-running","tag-selenium","tag-test"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/2338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/comments?post=2338"}],"version-history":[{"count":1,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/2338\/revisions"}],"predecessor-version":[{"id":44852,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/2338\/revisions\/44852"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media\/6494"}],"wp:attachment":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media?parent=2338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/categories?post=2338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/tags?post=2338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}