Selenimu运行脚本时遇到的与FF浏览器相关问题小结

本文记录了两种常见的Selenium启动失败的情况及其解决办法。一种情况是由于Firefox版本与Selenium版本不兼容导致的问题;另一种是由于系统路径中未找到Firefox浏览器导致的错误。文章提供了详细的解决方案,包括更新Selenium版本和指定Firefox浏览器的完整路径。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

错误信息1:

FAILED CONFIGURATION: @BeforeClass setUp
java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: Unable to delete file C:\Users\ADMINI~1\AppData\Local\Temp\customProfileDir9cf2c422885b4bb683e8f836a80a58be\parent.lock

原因:ff3.6与selenium1.0.1不兼容,服务器端使用selenium1.0.2以上的版本即可


错误信息2:

java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: java.lang.RuntimeException: Firefox 3 could not be found in the path!
Please add the directory containing ''firefox.exe'' to your PATH environment
variable, or explicitly specify a path to Firefox 3 like this:
*firefox3c:\blah\firefox.exe

java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: org.openqa.selenium.server.browserlaunchers.InvalidBrowserExecutableException: The specified path to the browser executable is invalid.  

原因:找不到FF,不能打开浏览器
解决:1、把ff重新安装一次,安装路径默认,不要修改
            2、在脚本中增加详细的浏览器绝对路径地址:

selenium = new DefaultSelenium("localhost", 4444, "*firefox D:\Program Files\Mozilla Firefox\firefox.exe","http://istock.jrj.com.cn/");

Traceback (most recent call last): File "C:\Users\HUAWEI\Desktop\bilibili_danmu.py", line 15, in <module> driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options) File "D:\AppGallery\Downloads\python\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 47, in __init__ super().__init__( ~~~~~~~~~~~~~~~~^ browser_name=DesiredCapabilities.CHROME["browserName"], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<3 lines>... keep_alive=keep_alive, ^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "D:\AppGallery\Downloads\python\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 69, in __init__ super().__init__(command_executor=executor, options=options) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\AppGallery\Downloads\python\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 261, in __init__ self.start_session(capabilities) ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^ File "D:\AppGallery\Downloads\python\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 362, in start_session response = self.execute(Command.NEW_SESSION, caps)["value"] ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\AppGallery\Downloads\python\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 454, in execute self.error_handler.check_response(response) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ File "D:\AppGallery\Downloads\python\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 232, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary Stacktrace: Backtrace: GetHandleVerifier [0x00D1A813+48355] (No symbol) [0x00CAC4B1] (No symbol) [0x00BB5358] (No symbol) [0x00BD1A9E] (No symbol) [0x00BD0579] (No symbol) [0x00C00C55] (No symbol) [0x00C0093C] (No symbol) [0x00BFA536] (No symbol) [0x00BD82DC] (No symbol) [0x00BD93DD] GetHandleVerifier [0x00F7AABD+2539405] GetHandleVerifier [0x00FBA78F+2800735] GetHandleVerifier [0x00FB456C+2775612] GetHandleVerifier [0x00DA51E0+616112] (No symbol) [0x00CB5F8C] (No symbol) [0x00CB2328] (No symbol) [0x00CB240B] (No symbol) [0x00CA4FF7] BaseThreadInitThunk [0x772B5D49+25] RtlInitializeExceptionChain [0x77BECF0B+107] RtlGetAppContainerNamedObjectPath [0x77BECE91+561]又显示这个,怎么改?疯了我要
最新发布
07-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值