zoukankan      html  css  js  c++  java
  • java+selenium3.0 运行时出的问题(system property)!

    按照之前的文章讲解,都已经搭建好了,可是在刚开始运行就报错了,代码和报错如下:

    WebDriver driver = new ChromeDriver();
    driver.get("http://www.baidu.com");

    错误如下:

    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 property)

    那么,我们针对三种浏览器的解决办法如下:

    按照顺序,Chrome、FirFox、IE:

    System.setProperty("webdriver.chrome.driver", "D:\fortest\drivers\chromedriver.exe");
    webDriver = new ChromeDriver();
    System.setProperty("webdriver.gecko.driver", "D:\fortest\drivers\geckodriver.exe");
    webDriver = new FirefoxDriver();
    System.setProperty("webdriver.ie.driver", "D:\fortest\drivers\IEDriverServer.exe");
    webDriver = new InternetExplorerDriver();

    OK,再运行解决!

  • 相关阅读:
    MySQL Community Server 8.0.16
    Python的编码规范
    Python 的语言特性
    spark笔记 环境配置
    C#委托实现工厂规则注入
    特性与元数据
    可输入的模糊搜索ComBox控件
    ASPX页面输出datatable的一种方法
    QRcode生成二维码,保存二维码图片到服务器
    SQL语句的随机值与行号,字符串拼接
  • 原文地址:https://www.cnblogs.com/iceb/p/7114955.html
Copyright © 2011-2022 走看看