Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm using Python 3.9 on macOS. I'm trying to start using webbot, but every time I try, I get this error:

selenium.common.exceptions.SessionNotCreatedException: Message: session not created 
exception: Missing or invalid capabilities
  (Driver info: chromedriver=2.39.562713 
(dd642283e958a93ebf6891600db055f1f1b4f3b2),platform=Mac OS X 10.14.6 x86_64)

I'm using macOS version 10.4 because I use 32 bit software. The part that really puzzles me is why is says chromedriver=2.39.562713. According to the pip, the driver's version is 103.0.5060.53. If I import selenium and try the command help(selenium), towards the end of the output, I get:

VERSION
    4.3.0

Where does this lower version come from? I'm pretty sure that's why I have "missing or invalid capabilities." If I start selenium with:

from selenium import webdriver
driver = webdriver.Chrome()

It starts Chrome as expected. Obviously I'm missing something.

I used to start webbot with:

from webbot import Browser
driver = Browser()

But then, just to be sure, I changed it to:

from webbot import Browser
driver = Browser(True, None, '/usr/local/bin/')

'/usr/local/bin/' being the location of a chrome webdriver installed by brew that is explicitly version 103. No difference.

Solution

The approved response was not the solution, but it led me to the solution.

My version of webbot is the latest, but it has a very different __init__ method:

    def __init__(self, showWindow=True, proxy=None , downloadPath:str=None):

Upon further inspection, I saw that the driverPath attribute (that I had tried to use earlier) was completely gone by design. So I decided to print the value of the inner variable driverpath inside the __init__ method. This returned the following:

project_root/virtualenvironment/lib/python3.9/site-packages/webbot/drivers/chrome_mac

There was my guilty party! I renamed that executable and in its place put a symbolic link to the correct binary. That worked.

Could you please elaborate what you did to resolve the problem? I have exactly the same issue here..thx! – user3712166 Jul 10, 2022 at 5:15 "I renamed that executable and in its place put a symbolic link to the correct binary.": do you rename chrome_mac to something else, and what's "correct binary"? – user3712166 Jul 10, 2022 at 16:19 Not sure if this would help anyone anymore, but I had this problem on Windows 10 today, I just went to chromedriver.chromium.org/downloads and downloaded the right driver for my version of chrome and replaced the version in venv\Lib\site-packages\webbot\drivers it's working on my computer now – rantsh Mar 20 at 14:32
driver = Browser(True, None, '/usr/local/bin/')

actually sets the downloadPath, not the driverPath. Use the parameter name explicitly

driver = Browser(driverPath='/usr/local/bin/')

From webbot.py

class Browser:
    def __init__(self, showWindow=True, proxy=None , downloadPath:str=None, driverPath:str=None, arguments=["--disable-dev-shm-usage","--no-sandbox"]):
        if driverPath is not None and isinstance(driverPath,str):
            driverPath = os.path.abspath(driverPath)
            if(not os.path.isdir(driverPath)):
                raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), driverPath)
        if driverPath is None:
            driverfilename = ''
            if sys.platform == 'linux' or sys.platform == 'linux2':
                driverfilename = 'chrome_linux'
            elif sys.platform == 'win32':
                driverfilename = 'chrome_windows.exe'
            elif sys.platform == 'darwin':
                driverfilename = 'chrome_mac'
            driverPath = os.path.join(os.path.split(__file__)[0], 'drivers{0}{1}'.format(os.path.sep, driverfilename))
        self.driver = webdriver.Chrome(executable_path=driverPath, options=options)

If driverPath is None it will set to /{parent_folder_abs_path}/drivers/chrome_mac or /{parent_folder_abs_path}/drivers/, I'm guessing you have an older chromedriver version there.

I'll look into that. Thanks! I looked carefully into how to set the options, though. I must have set it wrong anyway. – eje211 Jun 29, 2022 at 20:40

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.