{"id":23253,"date":"2022-06-14T07:01:37","date_gmt":"2022-06-14T07:01:37","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=23253"},"modified":"2025-05-17T05:56:38","modified_gmt":"2025-05-17T05:56:38","slug":"how-to-fix-unexpected-keyword-executable_path-error","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/how-to-fix-unexpected-keyword-executable_path-error\/","title":{"rendered":"How to fix unexpected keyword &#8216;executable_path&#8217; error"},"content":{"rendered":"<h2>How to fix unexpected keyword &#8216;executable_path&#8217;<\/h2>\n<p>The following is the error trace. Let&#8217;s understand the error and learn how to fix this error in Python automation scripts.<\/p>\n<h2>Error trace:<\/h2>\n<p>TypeError: WebDriver.__init__() got an unexpected<br \/>\nkeyword argument &#8216;<strong>executable_path<\/strong>&#8216;<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-23254\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/WebDriver-Unexpected-Keyword-Executable-Path.png\" alt=\"WebDriver Unexpected Keyword Executable Path\" width=\"1920\" height=\"976\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/WebDriver-Unexpected-Keyword-Executable-Path.png 1920w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/WebDriver-Unexpected-Keyword-Executable-Path-300x153.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/WebDriver-Unexpected-Keyword-Executable-Path-1024x521.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/WebDriver-Unexpected-Keyword-Executable-Path-768x390.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/WebDriver-Unexpected-Keyword-Executable-Path-1536x781.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<h2>Example<\/h2>\n<p>For example, the following Python Selenium test code will throw this particular<\/p>\n<p>error:<\/p>\n<pre><code class=\"language-python\" data-line=\"\"># Python Selenium Script\n# Python Selenium Tutorials\n# www.TestingDocs.com \n\nfrom selenium import webdriver\nfrom selenium.webdriver.common.by import By\nimport unittest\n\nclass login(unittest.TestCase):\n    def setUp(self):\n        self.driver = webdriver.Chrome(executable_path=&#039;\nD:\\chromedriver.exe&#039;)\n        self.base_url = &quot;https:\/\/www.google.com&quot;\n        \n    def test_example(self):\n        driver = self.driver\n        driver.get(self.base_url)\n        driver.find_element(By.NAME,&quot;q&quot;).send_keys(&quot;test&quot;)\n     \n    def tearDown(self):\n        self.driver.quit()\n        \n        \nif __name__ == &#039;__main__&#039;:\n    unittest.main()          <\/code><\/pre>\n<h2>Fix<\/h2>\n<p>This error occurs because of the <strong>webdriver.Chrome<\/strong> class in Selenium no longer accepts the executable_path argument in its initializer. Instead, you should use the webdriver.Chrome with the Service object to specify the path to the <strong>ChromeDriver<\/strong> executable.<\/p>\n<p>fixed code:<\/p>\n<p><em>self.driver = webdriver.Chrome()<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to fix unexpected keyword &#8216;executable_path&#8217; error<\/p>\n<p>The following is the error trace. Let&#8217;s understand the error and learn how to fix this error in Python<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[185],"tags":[],"class_list":["post-23253","post","type-post","status-publish","format-standard","hentry","category-selenium","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/23253","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=23253"}],"version-history":[{"count":7,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/23253\/revisions"}],"predecessor-version":[{"id":27377,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/23253\/revisions\/27377"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=23253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=23253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=23253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}