selenium学习中遇到的问题

本文介绍了如何解决Selenium WebDriver在启动浏览器过程中遇到的问题,包括设置Firefox路径、配置ChromeDriver环境变量及确保版本兼容等。

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

一:Exception in thread “main” org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA Build info: version: ‘2.47.1’, revision: ‘411b314’, time: ‘2015-07-30 02:56:46’

错误如下图所示:
这里写图片描述

出现这个错误的主要原因是:Firefox未安装在默认位置,使用System.setProperty设置Firefox安装路径即可

System.setProperty("webdriver.firefox.bin", "D:/Program Files (x86)/Mozilla Firefox/firefox.exe");

二、Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

原因一:安装相应浏览器的driver,如Chrome浏览器就是chromedriver,下载下来之后,是一个.exe文件,将放在在chrome的安装目录下(C:\Program Files (x86)\Google\Chrome\Application),然后再配置环境变量,在path最后添加;C:\Program Files (x86)\Google\Chrome\Application
注意:Chromedriver与Chrome版本号要相对应

chromedriver版本支持的Chrome版本
v2.33v60-62
v2.32v59-61
v2.31v58-60
v2.30v58-60
v2.29v56-58
v2.28v55-57
v2.27v54-56
v2.26v53-55
v2.25v53-55
v2.24v52-54
v2.23v51-53
v2.22v49-52
v2.21v46-50
v2.20v43-48
v2.19v43-47
v2.18v43-46
v2.17v42-43
v2.13v42-45
v2.15v40-43
v2.14v39-42
v2.13v38-41
v2.12v36-40
v2.11v36-40
v2.10v33-36
v2.9v31-34
v2.8v30-33
v2.7v30-33
v2.6v29-32
v2.5v29-32
v2.4v29-32


原因二:浏览器与selenium版本不对应,例如Firefox与selenium对应版本

SeleniumFireFox
2.25.018
2.30.019
2.31.020
2.42.229
2.44.033 (不支持31,2014/12/1)


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值