当前位置: 首页 > 知识库问答 >
问题:

线程“main”org.openqa.selenium.WebDriverException中的异常:chrome无法访问

益英逸
2023-03-14

我正在尝试使用selenium(2.53.1)和pom作为浏览器启动Chrome(版本58.0.3029.110(64位))

 <dependency>
			<groupId>org.seleniumhq.selenium</groupId>
			<artifactId>selenium-server</artifactId>
			<version>2.53.1</version>
			<exclusions>
				<exclusion>
					<artifactId>snakeyaml</artifactId>
					<groupId>org.yaml</groupId>
				</exclusion>
			</exclusions>
		  </dependency>`

代码:

System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "\\lib\\chromedriver.exe");
    System.out.println(System.getProperty("webdriver.chrome.driver"));
    DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome();
    ChromeOptions options = new ChromeOptions();
    options.addArguments("disable-infobars");
    desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, options);
    WebDriver driver = new ChromeDriver();
    driver.get("http://www.google.com");

我在Eclipse控制台中得到以下异常

D: \eclipse\QA\u Code\u Git\u Gerrit\TA-PAY\api automation\lib\chromedriver。exe在端口38042上启动ChromeDriver 2.29.461591(62ebf098771772160f391d75e589dc567915b233),仅允许本地连接。线程“main”org.openqa.selenium中出现异常。WebDriverException:chrome不可访问(驱动程序信息:chromedriver=2.29.461591(62ebf098771772160f391d75e589dc567915b233),平台=Windows NT 6.1.7601 SP1 x86_64)(警告:服务器未提供任何堆栈跟踪信息)命令持续时间或超时:62.38秒构建信息:版本:“2.53.1”,修订:“A36B8B1CD572871688E54B817830ADCE9B0158D”,时间:“2016-06-30 19:26:09”

请帮我做这个。我不知道是什么问题。

共有3个答案

蔡晨
2023-03-14

给这个

System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "\\lib\\chromedriver.exe");
System.out.println(System.getProperty("webdriver.chrome.driver"));
DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
options.addArguments("disable-infobars");
desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(desiredCapabilities);
driver.get("http://www.google.com");
欧旻
2023-03-14

不确定硒2.53是否适用于最新的ChromeDriver。如果您可以试用最新版本的Selenium(V3.4),那就太好了

慕麒
2023-03-14

看起来你使用了错误版本的Chrome驱动程序。

由于您的Chrome浏览器版本是58.0.3029.110,您必须使用ChromeDriver 2.29,可以从这里下载

 类似资料:
  • 我一直试图使用Selenium sendkeys(),但没有成功使用Chrome。我在这里研究过类似的问题,但似乎没有成功。我可以生成URL,调用按钮(click()),但是当我试图在特定的文本字段中输入值时,我会得到: 线程“main”org.openqa.selenium.WebDriverException中出现异常:未知错误:无法聚焦元素。

  • 从终端执行jar时,我得到以下信息: 我搜索了他的错误,发现了一些相同的执行输出错误,但没有解决我的情况。 下面详细介绍了文件的位置、清单内容、所采取的终端步骤以及所涉及的两个类文件的代码内容。 文件位置 > SWT库 舱单 班级 普通人。jar(参见下面的创建): Manifest.txt内容: 终端动作 > 目录更改 . jar创建 舱单检查 普通人。jar执行 密码 用户nterface.c

  • 我在ubuntu服务器上运行selenium测试用例,该服务器基本上在firefox和chrome中运行测试用例。Firefox启动并成功运行测试用例,但chrome引发异常: *****下面是stacktrace的片段:***** 在端口21549上启动ChromeDriver(v2.8.240825) 禁用PAC支持,因为没有系统实现 测试集成。AdminUserelementscheck失败

  • 问题内容: 每当我运行此命令时,该函数就可以正常使用。当我选择洞穴时,消息会每隔2秒弹出一次,然后当它越过该部分时,就会出现错误: 我已经尝试过和,并且在该方法中使用时,出现了很多错误。当我在方法中使用时,它不接受我的输入。 当我在该方法中使用时,它不接受我的字符串输入,而直接进入另一个游戏,但是布尔值返回并且它无限地发送垃圾邮件“ Which Cave …”。 我已经阅读了错误报告,以及类似问题

  • 问题内容: 我正在开发一个访问数据库的项目,但是我遇到了一些问题。我尝试使用hibernate3.2和4.52,但是它不起作用。 例外是在这行代码中 问题答案: 您需要在类路径中检查类org.apache.log4j.Level的冲突版本并进行解决。版本1.2.12或更高版本的log4j jar中提供了TRACE级别。