Skip to content

selenium.webdriver.common.options is missing #7379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bersbersbers opened this issue Feb 25, 2022 · 2 comments
Closed

selenium.webdriver.common.options is missing #7379

bersbersbers opened this issue Feb 25, 2022 · 2 comments
Labels
stubs: incomplete Annotations or sub-modules missing from an existing package or module

Comments

@bersbersbers
Copy link
Contributor

See https://github.com/python/typeshed/tree/master/stubs/selenium/selenium/webdriver/common

While the following codes are running fine:

"""Show bug."""
from typing import Any, Literal, Type

from selenium import webdriver
from selenium.webdriver import chrome, firefox
from selenium.webdriver.common.options import ArgOptions
from selenium.webdriver.remote.webdriver import WebDriver


def fun(browser: Literal["chrome", "firefox"]) -> Any:
    """Show bug."""
    driver_class: Type[WebDriver]
    options: ArgOptions
    if browser == "chrome":
        driver_class = webdriver.Chrome
        options = chrome.options.Options()
    elif browser == "firefox":
        driver_class = webdriver.Firefox
        options = firefox.options.Options()
    return (driver_class, options)
"""Show bug."""
from selenium.webdriver import chrome
from selenium.webdriver.common.options import ArgOptions


def fun() -> ArgOptions:
    """Show bug."""
    return chrome.options.Options()

I see various errors in Pylance and mypy:

Import "selenium.webdriver.common.options" could not be resolved
Incompatible types in assignment (expression has type "Options", variable has type "ArgOptions")
Incompatible return value type (got "Options", expected "ArgOptions") [return-value]

Interstingly, selenium.webdriver.common.options is not mentioned here, either: https://www.selenium.dev/selenium/docs/api/py/api.html#webdriver-common

@srittau srittau added the stubs: incomplete Annotations or sub-modules missing from an existing package or module label Feb 25, 2022
@Akuli
Copy link
Collaborator

Akuli commented Feb 25, 2022

Are you using Selenium 3 or Selenium 4? If it is Selenium 4, you should upgrade to 4.1.2 (released yesterday). It comes with its own type annotations, and type checkers should use those instead of what's in typeshed.

@bersbersbers
Copy link
Contributor Author

Are you using Selenium 3 or Selenium 4? If it is Selenium 4, you should upgrade to 4.1.2 (released yesterday). It comes with its own type annotations, and type checkers should use those instead of what's in typeshed.

Thanks for the hint! I was using some version Selenium 4 (installed 3-4 days ago), and due to some typing error that I don't remember, I installed types-selenium without paying attention to the version number (3.141.7). I then updated to selenium==4.1.2 today. I guess that version (and maybe the previous one, not sure) conflict with the older types-selenium, uninstalling which solves the issue. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: incomplete Annotations or sub-modules missing from an existing package or module
Projects
None yet
Development

No branches or pull requests

3 participants