[Python] Why Selenium webdriver is not Imported

Discussão em 'Python' iniciado por Stack, Dezembro 7, 2024.

  1. Stack

    Stack Membro Participativo

    >>> import selenium
    >>> selenium.webdriver
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    AttributeError: module 'selenium' has no attribute 'webdriver'
    >>> from selenium import *
    >>> webdriver
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'webdriver' is not defined
    >>> from selenium import webdriver
    >>> webdriver
    <module 'selenium.webdriver' from 'C:\\Python312\\Lib\\site-packages\\selenium\\webdriver\\__init__.py'>


    In this code why selenium doesn't import webdriver unless if asked explicitly. According to my current understanding, if not asked, in python all classes/functions should load. then why webdriverd was not imported when we import all classes/functions from module unless asked explicitly.

    I was expecting webdriver to be load when i load selenium module or all classes/functions from selenium module but webdriver wasn't imported and is only loaded when asked explicitly.

    Edit: To add more context, I am using Windows OS. Also, I don't have a file named selenium.py in the current directory, which could conflict with the selenium module.

    Continue reading...

Compartilhe esta Página