splinter icon indicating copy to clipboard operation
splinter copied to clipboard

Browser raise NoneType

Open MacroHongZ opened this issue 4 years ago • 7 comments

Code: ''' from splinter import Browser

browser = Browser('chrome') '''

result: TypeError: 'NoneType' object is not callable

I can't find the reason

MacroHongZ avatar Sep 01 '22 02:09 MacroHongZ

@MacroHongZ do you have a stack trace?

fsouza avatar Sep 01 '22 02:09 fsouza

I'm getting the same result. Installed splinter on python 3.10 and ran the same as above and got the following:

>>> browser = Browser()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/envs/splinter/lib/python3.10/site-packages/splinter/browser.py", line 121, in Browser
    return get_driver(driver, retry_count=retry_count, *args, **kwargs)
  File "/envs/splinter/lib/python3.10/site-packages/splinter/browser.py", line 92, in get_driver
    return driver(*args, **kwargs)
TypeError: 'NoneType' object is not callable

adamcheasley avatar Sep 02 '22 11:09 adamcheasley

@MacroHongZ @adamcheasley You're seeing this message because you didn't install the driver for the browser you're trying to use.

#1093 Catches this situation and returns an error message so this is more obvious.

You can either install selenium separately or when you install splinter with pip install splinter[selenium4]

javascript-error avatar Sep 02 '22 14:09 javascript-error

@jsfehler what do you think about to create an issue to improve this error message to users know that is necessary to install selenium?

andrewsmedina avatar Sep 02 '22 15:09 andrewsmedina

@jsfehler thanks for confirming! Yes, +1 for a better error message there.

adamcheasley avatar Sep 02 '22 18:09 adamcheasley

@andrewsmedina In the future we can check the driver name and return a more specific message. I've also updated the docs to make the installation process more obvious to new users.

javascript-error avatar Sep 03 '22 03:09 javascript-error

@jsfehler Thanks for your comment, the error is indeed due to Selenium not installed, but the error message is too ambiguous to find the cause. I would suggest that the doc could be updated to : “ pip install selenium pip install splinter“

MacroHongZ avatar Sep 14 '22 02:09 MacroHongZ