java - 上面的代码给出了错误 Invalid character constant in selenium with java
问题描述
String wb = driver.findElement(By.xpath("//div[@class='gb_h gb_i']/a")).getAttribute('href');
上面的代码给出了Invalid character constant
我想href
使用java从html代码中获取的错误
解决方案
您应该更改getAttribute('href')
为,getAttribute("href")
因此它应该是
String wb = driver.findElement(By.xpath("//div[@class='gb_h gb_i']/a")).getAttribute("href");
getAttribute()
方法接收String
。
在 JavaString
中是由" "
whileCharacter
定义的' '
推荐阅读
- swagger-ui - 如何使用工作锚设置 swagger ui
- google-apps-script - 为什么函数 submitData 不将字段添加到指定的工作表?
- node.js - 在 Express 中 bodyparser 和 multer 如何协同工作?
- android - Jetpack WorkManager - 组织 WorkRequest
- android - 模拟器运行时总是崩溃
- javascript - Laravel 从数据库中获取经度和纬度并在谷歌地图上显示标记
- vue.js - 如何以 eslint 不会抛出“tinymce 未定义错误”的方式在 vue 中实现 tinymce?
- python - 如何获取此验证码以限制字符长度并仅允许数字
- c++ - 重用 auto 类型的变量
- javascript - Req.user 在 POST 和 GET 之间丢失