Python webbot 库,示例返回"session not created exception: Missing or invalid capabilities"



我试图在Ubuntu 22.04上运行这个简单的Python webbot示例:

from webbot import Browser
web = Browser()
web.go_to('google.com')
web.type('hello its me')  # or web.press(web.Key.SHIFT + 'hello its me')
web.press(web.Key.ENTER)
web.go_back()
web.click('Sign in')
web.type('mymail@gmail.com' , into='Email')
web.click('NEXT' , tag='span')
web.type('mypassword' , into='Password' , id='passwordFieldId')
web.click('NEXT' , tag='span') # you are logged in . woohoooo

然而,当我使用Python3运行示例时,我得到这个错误:

web = Browser()
File "/usr/local/lib/python3.10/dist-packages/webbot/webbot.py", line 68, in __init__
self.driver = webdriver.Chrome(executable_path=driverpath, options=options)
File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/chrome/webdriver.py", line 80, in __init__
super().__init__(
File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/chromium/webdriver.py", line 104, in __init__
super().__init__(
File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py", line 286, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py", line 378, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py", line 440, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created exception: Missing or invalid capabilities
(Driver info: chromedriver=2.39.562737 (dba483cee6a5f15e2e2d73df16968ab10b38a2bf),platform=Linux 5.19.0-38-generic x86_64)

我安装Chrome使用:

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb

如何解决这个问题?

我对这个很陌生,我只是想登录一个网站,不管用什么浏览器。

我用谷歌搜索如何使用Firefox,但是库的名字使搜索变得困难。

您使用的是什么版本的selenium ?当你使用高于3.141.0的硒版本时,我看到了webbot的问题。如果你有更高的版本,你将不得不用这个替换它,然后尝试运行你的脚本。

相关内容

  • 没有找到相关文章

最新更新