程序正在错误的路径中搜索chrome驱动程序,而不是脚本中提到的可执行路径

时间:2017-09-10 08:29:13

标签: java eclipse path selenium-chromedriver executable

我知道很多问题都与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();
 }

}

1 个答案:

答案 0 :(得分:0)

我使用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");
     }