Selenium学习遇到的错误(一)

第一次启动浏览器驱动报错

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, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html

原因:驱动版本不对,驱动没有放在安装目录下
我的错误原因:System.setProperty("webdriver.chrome.driver", "D:\\Chrome\\Application\\drivers\\chromedriver_win32\\chromedriver.exe");中的"webdriver.chrome.driver", webdriver少写了driver

启动之后报错

Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary

这是因为Chrome没有放在默认浏览器目录下导致的,更改目录和环境变量配置启动正确
在这里插入图片描述

调试多选框的时候出错

Exception in thread "main" org.openqa.selenium.InvalidElementStateException: invalid element state

但是有输出。说明输出语句正常,后面的clear出错。注释掉就没了。在多选框中,这个是没用的
在这里插入图片描述

两个方法连着调用,但是后面一个方法没有执行完

原因:上一个的休眠时间太长。针对不同的元素有不同的方法,所以需要在一个元素执行完之后休息一段时间

下拉框创建Select报错

Class 'Anonymous class derived from Select' must either be declared abstract or implement abstract method 'accept(Visitor)' in 'Instruction'

已知Select是下拉框对象,是需要传网页元素进去的,不存在抽象说法。查看之后发现,自动导包错误,改成selenium的包即可

Actions新建对象报错

Action action = new Action(driver);

显示这个类是抽象类,不能传参数。
先排除导包错误,后面发现是Actions写成了Action。。。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值