Java 错误:包org.openqa.selenium不存在

Java 错误:包org.openqa.selenium不存在,java,command-line,classpath,Java,Command Line,Classpath,我试图从命令行执行桌面上的程序: javac'BrowserStackTest.java' 课程内容: 导入org.openqa.selenium.By; 导入org.openqa.selenium.Platform; 导入org.openqa.selenium.WebDriver; 导入org.openqa.selenium.WebElement; 导入org.openqa.selenium.remote.DesiredCapabilities; 导入org.openqa.selenium.r

我试图从命令行执行桌面上的程序:

javac'BrowserStackTest.java' 课程内容:

导入org.openqa.selenium.By; 导入org.openqa.selenium.Platform; 导入org.openqa.selenium.WebDriver; 导入org.openqa.selenium.WebElement; 导入org.openqa.selenium.remote.DesiredCapabilities; 导入org.openqa.selenium.remote.RemoteWebDriver; 导入org.testng.annotations.Test; 导入java.net.URL; 公共类浏览器堆栈测试{ } 我得到了以下错误:

BrowserStackTest.java:1: error: package org.openqa.selenium does not exist
    import org.openqa.selenium.By;
                              ^
BrowserStackTest.java:2: error: package org.openqa.selenium does not exist
    import org.openqa.selenium.Platform;
                              ^
BrowserStackTest.java:3: error: package org.openqa.selenium does not exist
    import org.openqa.selenium.WebDriver;
                              ^
BrowserStackTest.java:4: error: package org.openqa.selenium does not exist
    import org.openqa.selenium.WebElement;
                              ^
BrowserStackTest.java:5: error: package org.openqa.selenium.remote does not exist
    import org.openqa.selenium.remote.DesiredCapabilities;
从错误中,我可以观察到我没有提供用于执行的JAR,但我无法提供它们,因为缺少足够的文档,例如在何处添加用于执行此类程序的JAR。

我通过以下方式解决了此问题: 1-从下载selenium jar文件,名称应类似于client-combined-3.141.59.jar

2-将jar文件包括在libs文件夹中

3-in-app build.gradle添加到以下行:

implementation files('libs/client-combined-3.141.59.jar')

请不要介意类是emptyuse-cp选项,用于指定要包括的jar,比如这里@Nadir,感谢它工作了javac-cp selenium-2.48.2/selenium-java-2.48.2.jar;selenium-2.48.2/selenium-java-2.48.2-srcs.jar;selenium-2.48.2/libs/*BrowserStackTest.java,但在执行上述说明后,我得到了一些更多信息:一些输入文件使用或覆盖了不推荐使用的API。注意:有关详细信息,请使用-Xlint:deprecation重新编译。注意:某些输入文件使用未经检查或不安全的操作。注意:使用-Xlint:unchecked重新编译以获取详细信息。在执行java BrowserStackTest类时,继续上面的注释,得到以下错误:发生了JNI错误,请检查您的安装并重试线程主java.lang.NoClassDefFoundError中的异常:org/openqa/selenium/Capabilities位于java.lang.Class.getDeclaredMethods0Native方法,原因是:java.lang.ClassNotFoundException:org.openqa.selenium.Capabilities