

{"id":113991,"date":"2023-06-29T09:00:21","date_gmt":"2023-06-29T03:30:21","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=113991"},"modified":"2023-06-29T14:49:52","modified_gmt":"2023-06-29T09:19:52","slug":"run-selenium-test-on-chrome-browser","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/","title":{"rendered":"How to Run Selenium Tests on Chrome?"},"content":{"rendered":"<p>A well-liked open-source framework for automating web browsers is called Selenium. It allows developers and testers to automate web applications and perform functional and regression testing of web applications. Selenium supports multiple browsers like Chrome, Firefox, Edge, and Safari. In this article, we will focus on how to run selenium tests on Chrome browser.<\/p>\n<h3>ChromeDriver<\/h3>\n<p>The WebDriver protocol is implemented for Chrome by ChromeDriver, a standalone server. It is maintained by the Chromium team and is available for download on the Chromium website. ChromeDriver starts the Chrome browser instance and sends commands to it via the WebDriver interface.<\/p>\n<h3><b>Setting up<\/b> ChromeDriver<\/h3>\n<p>Before we can run tests on Chrome, we need to download and set up ChromeDriver. We need to ensure that the ChromeDriver version matches the Chrome browser version installed on our system. We can check the Chrome browser version by going to the &#8220;Chrome Menu&#8221; -&gt; &#8220;Help&#8221; -&gt; &#8220;About Google Chrome&#8221;. Once we have the Chrome browser version, we can download the appropriate version of ChromeDriver from the Chromium website.<\/p>\n<p>Here&#8217;s a step-by-step guide to setting up Selenium Chromedriver:<\/p>\n<p>1. First, <a href=\"https:\/\/sites.google.com\/a\/chromium.org\/chromedriver\/downloads\">download the latest version of Chromedriver<\/a> from the official website. Make sure you download the appropriate version for your operating system and Chrome browser version.<\/p>\n<p>2. Extract the Chromedriver executable file from the downloaded zip file to a directory on your computer.<\/p>\n<p>3. Next, install the Selenium library for Python by running the command: pip install selenium. This will install the Selenium Python package, which includes the necessary modules for interacting with the Chromedriver.<\/p>\n<p>4. Now you&#8217;re ready to write your first Selenium test script. Here&#8217;s an example script that navigates to Google.com and searches for a query:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from selenium import webdriver\r\n\r\nchromedriver_path = '\/path\/to\/chromedriver'\r\ndriver = webdriver.Chrome(chromedriver_path)\r\ndriver.get('https:\/\/www.google.com')\r\nsearch_box = driver.find_element_by_name('q')\r\nsearch_box.send_keys('Selenium Chromedriver')\r\nsearch_box.submit()\r\ndriver.implicitly_wait(10)\r\ndriver.quit()\r\n<\/pre>\n<p>5. Replace the &#8216;\/path\/to\/chromedriver&#8217; in the script above with the actual path to the Chromedriver executable file on your computer.<\/p>\n<p>6. Save the script to a file with a .py extension, such as selenium_test.py.<\/p>\n<p>7. Run the script from the command line by running the command python selenium_test.py. This will open a new Chrome window and execute the test script.<\/p>\n<p>After downloading ChromeDriver, we need to add the location of the ChromeDriver executable to the PATH environment variable. This ensures that the system can locate ChromeDriver when we run our tests.<\/p>\n<h3><b>Writing Tests in Selenium\u00a0<\/b><\/h3>\n<p>Selenium provides a rich set of APIs to interact with web pages. We can use these APIs to simulate user interactions with the web page, verify page elements, and perform various other tasks. Here is a basic test that opens the Chrome browser, navigates to a web page, enters text into a search box, and clicks on the search button:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from selenium import webdriver\r\n\r\nbrowser = webdriver.Chrome()\r\n\r\nbrowser.get('https:\/\/www.google.com')\r\n\r\nsearch_box = browser.find_element_by_name('q')\r\n\r\nsearch_box.send_keys('Selenium')\r\n\r\nsearch_button = browser.find_element_by_name('btnK')\r\n\r\nsearch_button.click()\r\n\r\nbrowser.quit()\r\n<\/pre>\n<h3>Running<b> Selenium Tests on Chrome Browser<\/b><\/h3>\n<p>To run the test, we need to save the test script to a file with the .py extension and execute the file using Python. The following command will execute the test script:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\u2018py test_script.py\u2019<\/pre>\n<p>When we run the test, we should see a new Chrome browser window open, navigate to the Google homepage. Then it will enter the search query, click the search button, and close the browser.<\/p>\n<h3>Conclusion<\/h3>\n<p>In this article, we learned how to set up ChromeDriver and run tests on Chrome using Selenium. We also saw a simple example of how to write a test script in Selenium. Selenium provides a powerful toolset for automating web applications, and Chrome is just one of the many browsers it supports. With the help of Selenium, we can automate repetitive tasks, perform regression testing, and ensure the quality of our web applications.<span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:208,&quot;href&quot;:&quot;https:\\\/\\\/sites.google.com\\\/a\\\/chromium.org\\\/chromedriver\\\/downloads&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20231118234835\\\/https:\\\/\\\/sites.google.com\\\/a\\\/chromium.org\\\/chromedriver\\\/downloads&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-07 14:18:00&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2025-12-31 17:56:38&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-11 01:27:25&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-21 00:14:09&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-08 17:41:34&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-19 02:38:07&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-22 04:17:09&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-28 23:14:23&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-23 06:57:17&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-02 10:36:26&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-29 03:31:52&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-07 04:51:54&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-01 08:29:10&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-18 07:25:53&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-06-30 11:19:47&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-30 11:19:47&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A well-liked open-source framework for automating web browsers is called Selenium. It allows developers and testers to automate web applications and perform functional and regression testing of web applications. Selenium supports multiple browsers like&#46;&#46;&#46;<\/p>\n","protected":false},"author":581,"featured_media":114515,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22825],"tags":[27572],"class_list":["post-113991","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-selenium-tutorials","tag-run-selenium-test-on-chrome"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Run Selenium Tests on Chrome? - DataFlair<\/title>\n<meta name=\"description\" content=\"Learn how to run selenium tests on Chrome browser in easy steps like chrome installation, setting up chromedriver, then running tests etc.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Run Selenium Tests on Chrome? - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Learn how to run selenium tests on Chrome browser in easy steps like chrome installation, setting up chromedriver, then running tests etc.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-29T03:30:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-29T09:19:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/04\/running-test-on-chrome-1.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Run Selenium Tests on Chrome? - DataFlair","description":"Learn how to run selenium tests on Chrome browser in easy steps like chrome installation, setting up chromedriver, then running tests etc.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/","og_locale":"en_US","og_type":"article","og_title":"How to Run Selenium Tests on Chrome? - DataFlair","og_description":"Learn how to run selenium tests on Chrome browser in easy steps like chrome installation, setting up chromedriver, then running tests etc.","og_url":"https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2023-06-29T03:30:21+00:00","article_modified_time":"2023-06-29T09:19:52+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/04\/running-test-on-chrome-1.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445"},"headline":"How to Run Selenium Tests on Chrome?","datePublished":"2023-06-29T03:30:21+00:00","dateModified":"2023-06-29T09:19:52+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/"},"wordCount":593,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/04\/running-test-on-chrome-1.webp","keywords":["Run Selenium Test on Chrome"],"articleSection":["Selenium Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/","url":"https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/","name":"How to Run Selenium Tests on Chrome? - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/04\/running-test-on-chrome-1.webp","datePublished":"2023-06-29T03:30:21+00:00","dateModified":"2023-06-29T09:19:52+00:00","description":"Learn how to run selenium tests on Chrome browser in easy steps like chrome installation, setting up chromedriver, then running tests etc.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/04\/running-test-on-chrome-1.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/04\/running-test-on-chrome-1.webp","width":1200,"height":628,"caption":"running test on chrome"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/run-selenium-test-on-chrome-browser\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Selenium Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/selenium-tutorials\/"},{"@type":"ListItem","position":3,"name":"How to Run Selenium Tests on Chrome?"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam6\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/113991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=113991"}],"version-history":[{"count":4,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/113991\/revisions"}],"predecessor-version":[{"id":114516,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/113991\/revisions\/114516"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/114515"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=113991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=113991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=113991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}