繁体   English   中英

似乎无法让 Eclipse IDE 在我的 Mac 上找到 geckodriver

[英]Cannot seem to get Eclipse IDE to find the geckodriver on my Mac

返回的错误是:“线程“main”中的异常java.lang.IllegalStateException:驱动程序可执行文件不存在:/usr/local/bin/geckodriver”

如您所见,驱动程序在那里: ➜ bin pwd /usr/local/bin ➜ bin ls geck* geckodriver

我在论坛上搜索了同一问题的许多其他答案,但我尝试过的任何内容都没有产生任何影响。 我最初手动安装了 geckodriver,但是当我无法让它工作时,我删除了该文件并通过 brew install 安装它,但它没有任何区别。

package automationFramework;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

public class WebTestMainPage {

    public static void main(String[] args) {

        System.setProperty("webdriver.gecko.driver", "/usr/local/bin/geckodriver⁩");
        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.store.demoqa.com");

适用于 Java 开发人员的 Eclipse IDE 版本:2018-12 (4.10.0) 构建 ID:20181214-0600 操作系统:Mac OS X,v.10.14.2,x86_64 / cocoa Java 版本:11.0.1

您需要先使 geckodriver 可执行,然后才能执行脚本。
要使其可执行,您需要转到其所在的文件夹,在您的情况下是 /usr/local/bin,然后使用 chmod +x 命令使其可执行。
尝试以下步骤:

cd /usr/local/bin
chmod +x geckodriver

现在您将能够执行您的脚本。

暂无
暂无

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

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