繁体   English   中英

在源代码中使用 selenium 时,如何从命令行编译 java 程序?

[英]How do you compile a java program from the command line while using selenium in the source code?

我正在为我的计算机科学课程做一个期末项目。 我使用 Selenium 库构建了一个程序,以自动化创建 github 存储库并将其链接到本地文件夹的过程。 我只能使用它们的“运行”功能在 VS Code 中运行程序。 I want to be able to run this from the Command Line in Windows, but I am not able to compile it since Java doesn't recognize Selenium object types like WebDriver and WebElement. 我将如何使用这个外部库编译它?

强烈建议将 Maven 用于 java 项目。 如果您已将 maven 依赖项添加到 pom.xml 文件,它可以获取所有需要的依赖项。

否则下载 Selenium jar 文件并使用以下命令编译您的代码。

javac -cp .:jarfile1.jar:jarfile2.jar <MainClass>.java

并运行以下命令执行

java MainClass

暂无
暂无

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

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