[Python] Unable to obtain chromedriver.exe using Selenium Manager

Discussão em 'Python' iniciado por Stack, Fevereiro 22, 2025.

  1. Stack

    Stack Membro Participativo

    Error: Message: Unable to obtain chromedriver.exe using Selenium Manager; Message: Unsuccessful command executed: /var/task/selenium/webdriver/common/linux/selenium-manager --browser chrome --output json; Expecting value: line 1 column 1 (char 0)

    Code:

    from http.server import BaseHTTPRequestHandler
    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    from selenium.webdriver.chrome.service import Service

    class Handler(BaseHTTPRequestHandler):

    def do_GET(self):
    self.send_response(200)
    self.send_header('Content-type', 'text/plain')
    self.end_headers()

    try:
    service = Service(executable_path=r'./chromedriver.exe')
    options = webdriver.ChromeOptions()
    options.add_argument('--headless')
    driver = webdriver.Chrome(service=service, options=options)
    driver.get('https://www.example.com/')
    driver.save_screenshot("screenshot_example.png")

    except Exception as e:
    # Print the exception error
    self.wfile.write(f'{str(e)}'.encode('utf-8'))

    self.wfile.write('Hello, world!'.encode('utf-8'))
    return


    I tried changing ./chromedriver.exe in many different ways already with/without .exe and / or the ./

    Continue reading...

Compartilhe esta Página