安装selenium遇到Unable to find a matching set of capabilities问题

本文介绍了一个关于Selenium WebDriver与Firefox浏览器版本不兼容导致的错误:Unable to find a matching set of capabilities。通过调整Firefox的安装位置及名称,最终解决了此问题。
Traceback (most recent call last):
  File "/Users/xinxin/PycharmProjects/click/click.py", line 5, in <module>
    driver = webdriver.Firefox(executable_path='/Users/xinxin/geckodriver')
  File "/Users/xinxin/click/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 162, in __init__
    keep_alive=True)
  File "/Users/xinxin/click/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/Users/xinxin/click/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/Users/xinxin/click/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
    self.error_handler.check_response(response)
  File "/Users/xinxin/click/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities
今天遇到一个很有意思的问题,安装selenium的时候遇到
Unable to find a matching set of capabilities

在网上查阅的时候,大部分是说可能是Firefox版本不匹配问题。在确认版本还算新的情况下:

python 2.7

selenium 3.11.0

geckodriver v0.20.0

Firefox 59.0.1

后来上stackoverflow发现有人提到,需要把Firefox安装在Applications里面,且不能更改命名,如Firefox58,我之前放在本地文件夹里,试着重新安装了一下成功了。

粘贴一下stackoverflow地址

https://stackoverflow.com/questions/43713445/selenium-unable-to-find-a-matching-set-of-capabilities-despite-driver-being-in







2025-09-02 11:26:57.253 INFO 96280 --- [ null to remote] o.o.selenium.remote.ProtocolHandshake : Detected dialect: W3C 当前线程数:task-6 当前线程数:task-3 2025-09-02 11:26:57.312 WARN 96280 --- [ task-1] o.o.selenium.devtools.CdpVersionFinder : Unable to find an exact match for CDP version 139, so returning the closest version found: a no-op implementation 2025-09-02 11:26:57.313 INFO 96280 --- [ task-1] o.o.selenium.devtools.CdpVersionFinder : Unable to find CDP implementation matching 139. 2025-09-02 11:26:57.313 WARN 96280 --- [ task-1] o.o.selenium.chromium.ChromiumDriver : Unable to find version of CDP to use for . You may need to include a dependency on a specific version of the CDP using something similar to `org.seleniumhq.selenium:selenium-devtools-v86:4.1.4` where the version ("v86") matches the version of the chromium-based browser you're using and the version number of the artifact is the same as Selenium's. 开始时间:2025-06-01 2025-09-02 11:26:58.861 ERROR 96280 --- [ task-1] t.c.c.AsyncAllShippingController : 获取Scfi数据失败 java.util.concurrent.CompletionException: org.openqa.selenium.UnhandledAlertException: unexpected alert open: {Alert text : 对不起你没有登陆! } (Session info: chrome=139.0.7258.155): 对不起你没有登陆! Build info: version: '4.1.4', revision: '535d840ee2' System info: host: 'LAPTOP-0716IRTK', ip: '192.168.50.201', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.1' Driver info: org.openqa.selenium.chrome.ChromeDriver Command: [1ebd4362150a71cb198dbe371597ec18, getPageSource {}] Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 139.0.7258.155, chrome: {chromedriverVersion: 139.0.7222.0 (5d257d73ae4e8..., userDataDir: C:\Users\HP\AppData\Local\T...}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:53085}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), se:cdp: ws://localhost:53085/devtoo..., se:cdpVersion: 139.0.7258.155, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true} Session ID: 1ebd4362150a71cb198dbe371597ec18 at org.springframework.aop.interceptor.AsyncExecutionAspectSupport.lambda$doSubmit$3(AsyncExecutionAspectSupport.java:281) ~[spring-aop-5.3.29.jar:5.3.29] at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run$$$capture(CompletableFuture.java:1768) ~[na:na] at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java) ~[na:na] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na] at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na] Caused by: org.openqa.selenium.UnhandledAlertException: unexpected alert open: {Alert text : 对不起你没有登陆! } (Session info: chrome=139.0.7258.155): 对不起你没有登陆! Build info: version: '4.1.4', revision: '535d840ee2' System info: host: 'LAPTOP-0716IRTK', ip: '192.168.50.201', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.1' Driver info: org.openqa.selenium.chrome.ChromeDriver Command: [1ebd4362150a71cb198dbe371597ec18, getPageSource {}] Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 139.0.7258.155, chrome: {chromedriverVersion: 139.0.7222.0 (5d257d73ae4e8..., userDataDir: C:\Users\HP\AppData\Local\T...}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:53085}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), se:cdp: ws://localhost:53085/devtoo..., se:cdpVersion: 139.0.7258.155, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true} Session ID: 1ebd4362150a71cb198dbe371597ec18 at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:131) ~[selenium-remote-driver-4.1.4.jar:na] at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:53) ~[selenium-remote-driver-4.1.4.jar:na] at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:184) ~[selenium-remote-driver-4.1.4.jar:na] at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167) ~[selenium-remote-driver-4.1.4.jar:na] at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142) ~[selenium-remote-driver-4.1.4.jar:na] at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:567) ~[selenium-remote-driver-4.1.4.jar:na] at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:622) ~[selenium-remote-driver-4.1.4.jar:na] at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:626) ~[selenium-remote-driver-4.1.4.jar:na] at org.openqa.selenium.remote.RemoteWebDriver.getPageSource(RemoteWebDriver.java:429) ~[selenium-remote-driver-4.1.4.jar:na] at tech.crawler.service.AsyncShippingService.getScfi(AsyncShippingService.java:97) ~[classes/:na] at tech.crawler.service.AsyncShippingService$$FastClassBySpringCGLIB$$728ca5b6.invoke(<generated>) ~[classes/:na] at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.29.jar:5.3.29] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) ~[spring-aop-5.3.29.jar:5.3.29] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.29.jar:5.3.29] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.29.jar:5.3.29] at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115) ~[spring-aop-5.3.29.jar:5.3.29] at org.springframework.aop.interceptor.AsyncExecutionAspectSupport.lambda$doSubmit$3(AsyncExecutionAspectSupport.java:278) ~[spring-aop-5.3.29.jar:5.3.29] ... 5 common frames omitted 解释一下这个是什么问题
最新发布
09-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值