首页 > 解决方案 > Selenium:'包 org.openqa.selenium 不存在'

问题描述

终端:错误信息

Eclipse IDE:程序设置

收到两 (2) 条错误消息:

package org.openqa.selenium does not exist
package org.openqa.selenium.chrome does not exist

这是我的程序的样子:MyClass.java

package newPackage;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class MyClass {

    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver",
                "/Users/Informatics/Downloads/chromedriver.exe");

        WebDriver driver = new ChromeDriver();
        driver.get("google.com");

        driver.close();
    }
}

ps 我正在使用最新版本的 Eclipse、Selenium、Chrome 和 Java。

标签: javaselenium

解决方案


如果你使用 intellijIdea 在 build.gradle 文件的依赖项中添加这个

implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.1.1'

我已添加为 testimplementation 组所以出现错误,应该是添加所有 jars 的实现组


推荐阅读