Home > Blockchain >  selenium.common.exceptions.WebDriverException: Message: 'WebScraping' executable may have
selenium.common.exceptions.WebDriverException: Message: 'WebScraping' executable may have

Time:12-22

I can't seem to make this work. It always displays the wrong permission. I have downloaded the chromedriver version 96 and my chrome version is 96. I know that the executable path has been depreciated and changed it to Service. Can anybody help me with this?

Here is the code:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService

chrome_driver_path = "/Users/thangtruong/WebScraping"
service = ChromeService(executable_path=chrome_driver_path)
driver = webdriver.Chrome(service=service)
website = "https://www.amazon.com"
driver.get(website)

CodePudding user response:

A couple of things here:

  • If your underlying is :

    • You have to download chromedriver_win32.zip from the ChromeDriver Download Location and unzip it for usage.

    • Additionally, if you are explicitly specifying the Chromedriver binary path you have to append the binary extension as well, effectively i.e. chromedriver.exe.

    • While mentioning the Chromedriver binary path you have to either use the single forward slash i.e. (/) along with the raw (r) switch or you have to use the escaped backslash i.e. (\\).

    • So your effective line of code will be :

      chrome_driver_path = r'C:/Users/thangtruong/WebScraping/chromedriver.exe'
      service = ChromeService(executable_path=chrome_driver_path)
      driver = webdriver.Chrome(service=service)
      website = "https://www.amazon.com"
      driver.get(website)
      
  • If your underlying is :

    • You have to download chromedriver_linux64 from the ChromeDriver Download Location and untar it for usage.

    • Additionally, if you are explicitly specifying the Chromedriver binary path you don't have to provide any extension for the executable binary, effectively i.e. chromedriver.

    • While mentioning the Chromedriver binary path you have to use the single forward slash i.e. (/).

    • So your effective line of code will be :

      chrome_driver_path = '/Users/thangtruong/WebScraping/chromedriver'
      service = ChromeService(executable_path=chrome_driver_path)
      driver = webdriver.Chrome(service=service)
      website = "https://www.amazon.com")
      driver.get(website)
      
  • If your underlying is :

    • You have to download chromedriver_mac64 from the ChromeDriver Download Location and untar it for usage.

    • Additionally, if you are explicitly specifying the Chromedriver binary path you don't have to provide any extension for the executable binary, effectively i.e. chromedriver.

    • While mentioning the chromedriver binary path you have to use the single forward slash i.e. (/).

    • So your effective line of code will be :

      chrome_driver_path = '/Users/thangtruong/WebScraping/chromedriver'
      service = ChromeService(executable_path=chrome_driver_path)
      driver = webdriver.Chrome(service=service)
      website = "https://www.amazon.com"
      driver.get(website)
      

References

You can find a couple of detailed discussions in:

  • Related