简体   繁体   中英

Errror with using Selenium Webdriver with chrome

from bs4 import BeautifulSoup, SoupStrainer
from selenium import webdriver
from selenium.webdriver import chrome
from selenium.webdriver.chrome.options import Options



url = 'https://...'
options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument("--headless")
driver = webdriver.Chrome('path')
driver.get(url)

Error:

Traceback (most recent call last):
  File "", line 20, in <module>
    driver.get(EPL_url)
  File "", line 333, in get
    self.execute(Command.GET, {'EPL_url': url})
  File "", line 321, in execute
    self.error_handler.check_response(response)
  File "", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown command: unknown command: session/9df33bd6f0e57084300c81738cf6c2d5/EPL_url

I have tried to look at all the potential errors around this and have found nothing. The annoying things is, the "driver.get()" function was working perfectly earlier. It only seemed to have been disrupted after I had changed the variable name of the URL. I seriously do not know what to do and need to get this code back up and running. Please help me with the above error so I can rectify this.! It would be much appreciated.

This issue can be because of the path of the chrome driver. Here's a simpler solution: install the python-chrome drive package, import it in your script, and it's done.

Step by step:

  1. pip install chromedriver-binary
  2. import the package
from selenium import webdriver
import chromedriver_binary  # Adds chromedriver binary to path

driver = webdriver.Chrome()
driver.get("http://www.python.org")

Reference: https://pypi.org/project/chromedriver-binary/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM