selenium + WebDriver + java启动Chrome浏览器报错

一、Unable to find a free port

代码:

原因:代码没有问题,IP地址绑定不正,hosts文件中有一个不存在的IP地址

解决:将IP地址修改为127.0.0.1(最好不要使用本机IPV4地址)

 

二、Driver info: driver.version: ChromeDriver

问题:可能是版本不匹配导致的

解决:

→去官网下载与Chrome匹配的Chromedriver:http://npm.taobao.org/mirrors/chromedriver/

→如果还是没有解决,打开任务管理器,手动关闭Chromedriver.exe

→如果还没有解决,参照问题一,看一下hosts文件中的地址是否正确

 

三、Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, seehttp://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded fromhttp://code.google.com/p/chromedriver/downloads/list

原因:读取不到Chromedriver正确的路径

解决:代码中启动浏览器之前设置正确的路径

System.setProperty("webdriver.chrome.driver", "D:\\Application\\chromedriver.exe");

 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值