java - Selenium:'包 org.openqa.selenium 不存在'
问题描述
收到两 (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。
解决方案
如果你使用 intellijIdea 在 build.gradle 文件的依赖项中添加这个
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.1.1'
我已添加为 testimplementation 组所以出现错误,应该是添加所有 jars 的实现组
推荐阅读
- elixir - 要映射的字符串列表
- azure-devops - 通过命令行任务在 VSTS/TFS (Azure DevOps) 中配置 Jmeter 测试
- docker - 使用 docker 镜像创建 h2o 集群
- button - 使用新按钮自定义交互式网格工具栏以发送邮件
- java - 使用 Scrollview 滚动的背景
- ibm-watson - 将 Watson Studio Visual Recognition 模型移至桌面应用程序
- sql-server - 实体框架关联不会延迟加载特定记录。外键是字符串
- java - 文本到语音android在活动可见时输出语音
- python - pysptk 库中如何提取 MFCC?
- c - 如何为可变长度的字符串分配内存?