selenium - 我的问题是我收到一个错误(等待驱动程序服务器为 Chrome 浏览器启动超时)
问题描述
我正在使用带有 Windows 10-64 位、selenium-server-standalone-3.141.59 和 selenium-java-3.141.59 的 Eclipse Luna。
我编写了一个简单的程序来访问 url。但是我收到了这个错误:
[13552:3540:0515/184943.562:ERROR:cache_util_win.cc(21)] 无法移动缓存:0 [13552:3540:0515/184943.562:ERROR:cache_util.cc(141)] 无法移动缓存文件夹 C: \Users\RChauh\AppData\Local\Google\Chrome\User Data\ShaderCache\GPUCache 到 C:\Users\RChauh\AppData\Local\Google\Chrome\User Data\ShaderCache\old_GPUCache_000 [13552:3540:0515/184943.562:错误:disk_cache.cc(185)] 无法创建缓存 [13552:3540:0515/184943.562:ERROR:shader_disk_cache.cc(623)] 着色器缓存创建失败:-2 在现有浏览器会话中打开。线程“主”org.openqa.selenium.WebDriverException 中的异常:等待驱动程序服务器启动超时。构建信息:版本:'3.141.59',修订:'e82be7d358',时间:'2018-11-14T08:25:53' 系统信息:主机:'LAPTOP-3VFBUTNB',ip:'192.168.1。http://localhost:32149/status]在 org.openqa.selenium.remote.service.DriverService.waitUntilAvailable( DriverService.java:197) ... 9 更多原因:com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout( SimpleTimeLimiter.java:156) 在 org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75) ... 10 更多
package helloWorld;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class java {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver","C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
WebDriver driver=new ChromeDriver();
driver.get("https://www.facebook.com/");
System.out.println("LoginPage");
driver.quit();
}
}
解决方案
您应该将webdriver.chrome.driver
属性设置为指向chromedriver.exe
,而不是chrome.exe
- 为您的 Chrome 浏览器版本下载相关的ChromeDriver包
- 在某处解压档案
- 修改
webdriver.chrome.driver
属性以指向chromedriver.exe
第 2 步 - 就是这样,你现在应该可以走了
如果需要,请查看ChromeDriver - Chrome 的 WebDriver -> 入门以获取更多详细信息。
直到意识到页面对象设计模式还为时不晚,它是某种形式的 Selenium 脚本最佳实践,它允许将测试逻辑与 UI 元素定义分开,从而使您的测试更易于开发,尤其是维护。查看设计模式 - 页面对象模型以获取更多详细信息和示例测试项目。
推荐阅读
- python - 通过范围索引获取整个数组
- python - 在 python 中可视化嵌套函数调用
- java - android studio switch 如何以编程方式设置开关的状态
- rust - 如何使一个项目在我的二进制 crate 目标中可见,但在任何其他 crate 中不可见?
- javascript - Javascript 获取原型函数名称
- r - 在 R 中合并数据集
- json - JSON 数据的 PostgreSQL 平均值
- javascript - 使用 Numeral.js 格式化字符串
- python - Python Selenium selenium.common.exceptions.StaleElementReferenceException
- java - Spring MVC:如何在反序列化包含重复对象定义的 JSON 字符串时创建对象的单个实例