ChromeDriver不能通过CMD以"testng.xml"开头 [英] ChromeDriver does not start through CMD with "testng.xml"
问题描述
我试图从CMD运行TestNG.xml文件,但是没有显示错误,而且ChromeDriver似乎没有启动.
I was trying to run a TestNG.xml file from CMD but there are no errors shown and it seems that ChromeDriver is not starting.
注意:如果我转到Eclipse->右键单击testng.xml->以TestNG套件的身份运行,它将运行完美.
Note: if i go to Eclipse -> right click on testng.xml -> run as TestNG suite it will work perfectly.
-
以下是通过cmd执行时收到的消息.
Below is the message i get when executing through cmd.
bat文件包含:
java -cp "D:\Java Applications\WebDriverProject\lib*;D:\Java Applications\WebDriverProject\bin" org.testng.TestNG testng.xml
pause
The bat file contains:
java -cp "D:\Java Applications\WebDriverProject\lib*;D:\Java Applications\WebDriverProject\bin" org.testng.TestNG testng.xml
pause
testng.xml包含:
The testng.xml contains:
- eclipse的项目结构为:
- The project structure from eclipse is:
推荐答案
我知道了.首先,如何设置类路径环境至关重要.第一个路径必须是项目bin文件夹(在其中找到.class文件的路径)的路径.我将粘贴我的类路径环境:
I figured this out. First of all, how you set up the classpath environment is crucial. The very first path must be a path to your project bin folder (where the .class files are found). I will just paste what my classpath environment looks like:
set classpath=C:\eclipse-2018\ACR_Tests\bin;C:\Selenium_dependencies\*;C:\TestNG\plugins\*
设置TestNG类路径:
Set TestNG classpath:
java -classpath %classpath% org.testng.TestNG testng.xml
注意: 我还向类路径中添加了一个"Selenium依赖项"文件夹,该文件夹包含更多的硒库,包括chromedriver.jar
Note: I have a "Selenium dependencies" folder also added to the classpath, this is a folder containing more selenium libraries, including chromedriver.jar
下载压缩包:
selenium-chrome-driver JAR 3.12.0
selenium-chrome-driver JAR 3.12.0
它包含您需要的依赖项.
It contains the dependencies that you need.
https://jar-download.com/artifacts/org.seleniumhq.selenium/selenium-chrome-driver/3.12.0/source-code
将所有内容提取到一个文件夹中.就我而言,我将其称为"Selenium_dependencies".
Extract all to a folder. In my case I called it "Selenium_dependencies".
此外,对于TestNG库,我使用的是7.0.0版,您可以在此处下载:
Also, for TestNG libraries I'm using 7.0.0 release which you can download here:
http://dl.bintray.com/testng- team/testng-eclipse-release/zipped/
我的testng.xml就像这样:
My testng.xml is like so:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test thread-count="5" name="Test">
<classes>
<class name="P1.ACR_Server"/> <!-- package.class -->
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
还-确保构建路径中包含client-combined.jar.
Also - ensure that you have client-combined.jar included on the build path.
构建路径应包含以下库:
The build path should contain these libraries:
这篇关于ChromeDriver不能通过CMD以"testng.xml"开头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!