Skip to content

[πŸ› Bug]: Python import selenium webdriver error on Python 3.12.4Β #15146

@shihte

Description

@shihte

What happened?

BUG?: Python import selenium webdriver error on Python 3.12.4

Description
Import error with selenium.webdriver on Python 3.12.4

Steps to Reproduce

  1. Python 3.12.4
  2. selenium 4.28.1
  3. Import fails:
from selenium import webdriver

### How can we reproduce the issue?

```shell
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from urllib.parse import urlparse

def get_cookies(url):
    options = Options()
    options.add_argument('--headless')
    
    driver = selenium.webdriver.Chrome(options=options)
    driver.get(url)
    
    cookies = driver.get_cookies()
    driver.quit()
    
    return {
        cookie['name']: cookie['value'] 
        for cookie in cookies
    }

url = "https://www.google.com"
cookies = get_cookies(url)
print(cookies)

Relevant log output

Traceback (most recent call last):
  File "/Users/*/Desktop/CoolEnglishHacker/selenium.py", line 1, in <module>
    from selenium import webdriver
  File "/Users/*/Desktop/CoolEnglishHacker/selenium.py", line 1, in <module>
    from selenium import webdriver
ImportError: cannot import name 'webdriver' from 'selenium' (consider renaming '/Users/*/Desktop/CoolEnglishHacker/selenium.py' if it has the same name as a library you intended to import)

Operating System

MacOS 15.1.1

Selenium version

selenium 4.28.1

What are the browser(s) and version(s) where you see this issue?

Chrome 131.0.6778.265

What are the browser driver(s) and version(s) where you see this issue?

no

Are you using Selenium Grid?

selenium 4.28.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!I-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions