【问题标题】:Program is searching for chrome driver in wrong path instead of Executable path mentioned in script程序正在错误路径中搜索 chrome 驱动程序,而不是脚本中提到的可执行路径
【发布时间】:2017-09-10 08:29:13
【问题描述】:

我知道在Selenium WebDriver 中提出了许多与可执行路径问题相关的问题,但是,我在下面解释的问题是不同的。

我在脚本中正确地提供了 chrome 驱动程序路径。 路径:F:\\chromedriver.exe 但是系统在执行过程中在不同的路径中搜索:驱动程序可执行文件不存在:E:\WorkSpace\Flipkart\‪F:\chromedriver.exe

我不知道为什么它正在寻找完全错误的不同路径。请提供您对此问题的建议和看法。

public class Engine {
 public static void main(String[] args) {

    System.setProperty("webdriver.chrome.driver", "‪F:\\chromedriver.exe");
    WebDriver driver = new ChromeDriver();
 }

}

【问题讨论】:

    标签: java eclipse path selenium-chromedriver executable


    【解决方案1】:

    我使用 File 类绕过了这个问题。请找到以下代码。

    public class Engine {
         public static void main(String[] args) {
        File filename = new File("F:\\chromedriver.exe");
            System.setProperty("webdriver.chrome.driver", filename.getAbsolutePath());
    
            WebDriver driver = new ChromeDriver();
            driver.get("www.google.com");
         }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-03
      • 1970-01-01
      • 2021-10-29
      • 2019-01-17
      • 1970-01-01
      相关资源
      最近更新 更多