简体   繁体   English

Eclipse 无法找到 chrome 库

[英]Eclipse is not able to find chrome library

I am pretty new to Selenium world.我对硒世界很陌生。 I have been stuck with this code of opening a basic facebook page and it keeps throwing an error saying:我一直坚持使用这个打开基本 facebook 页面的代码,它不断抛出一个错误说:

Starting ChromeDriver 78.0.3904.105 (60e2d8774a8151efa6a00b1f358371b1e0e07ee2-refs/branch-heads/3904@{#877}) on port 8852 Only local connections are allowed.在端口 8852 上启动 ChromeDriver 78.0.3904.105 (60e2d8774a8151efa6a00b1f358371b1e0e07ee2-refs/branch-heads/3904@{#877}) 仅允许本地连接。 Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.请保护 ChromeDriver 及相关测试框架使用的端口,防止恶意代码访问。 Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48' System info: host: 'ATLMD2226268', ip: '10.7.0.108', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_211'线程“main” org.openqa.selenium.WebDriverException 中的异常:未知错误:找不到 Chrome 二进制构建信息:版本:'3.141.59',修订版:'e82be7d358',时间:'2018-11-14T08:25:48 '系统信息:主机:'ATLMD2226268',ip:'10.7.0.108',os.name:'Windows 10',os.arch:'amd64',os.version:'10.0',java.version:'1.8。 0_211'

Code I am using is:我使用的代码是:

package NewPackage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class MyClass {
    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\vaaggarw\\Downloads\\chromedriver_win32\\chromedriver.exe");
        ChromeOptions options = new ChromeOptions();
        options.setBinary("C:\\Program Files (x86)\\Google Chrome (Local)\\chrome.exe");
        WebDriver driver = new ChromeDriver();
        String baseUrl = "http://www.facebook.com";
        String tagName = "";

        driver.get(baseUrl);
        tagName = driver.findElement(By.id("email")).getTagName();
        System.out.println(tagName);
        driver.close();
        System.exit(0);
}
}
  1. make sure all selenium jars are not missing in your project.确保您的项目中没有缺少所有硒罐。 If not delete them anyway and add new jars from fresh download如果仍然不删除它们并从新下载中添加新的 jars
  2. clean your project清理你的项目
  3. as pcalkins advises, use the chrome options propertly正如 pcalkins 所建议的,正确使用 chrome 选项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM