简体   繁体   English

如何从命令行使用多个程序包运行Selenium testNG文件?

[英]How to run a Selenium testNG file from Command Line with multiple packages?

I am having trouble running my testNG xml file from the command line due the main Selenium Java tests having multiple packages. 由于主要的Selenium Java测试具有多个软件包,因此无法从命令行运行testNG xml文件。

I have a package called webDrivertests, which includes the java class that contains the methods the xml file runs, called LoadConfigModels.java. 我有一个名为webDrivertests的程序包,其中包括java类,该类包含xml文件运行的方法,称为LoadConfigModels.java。

The xml file is parallelLoadConfig.xml. xml文件是parallelLoadConfig.xml。

In LoadConfigModels.java, I import another package called utility, which contains a class called ExcelUtils.java that I use to parse an excel sheet. 在LoadConfigModels.java中,我导入了另一个名为Utility的程序包,其中包含一个名为ExcelUtils.java的类,该类用于解析excel工作表。

Here is the batch file I'm using: 这是我正在使用的批处理文件:

set projectLocation=C:\Users\user_name\eclipse-workspace\Test_Scripts
cd/
cd %projectLocation%
set classpath=%projectLocation%\bin;%projectLocation%\lib\*
java org.testng.TestNG %projectLocation%\parallelLoadConfig.xml
pause

Here is a directory: 这是一个目录:

--> Project Name: Test_Scripts ->项目名称:Test_Scripts

----> Package: utility ---->包:实用程序

--------> ExcelUtils.java --------> ExcelUtils.java

----> Package: webDrivertests ---->软件包:webDrivertests

--------> LoadConfigModels.java --------> LoadConfigModels.java

Everything runs smoothly until the code reaches the Excel.utils call and crashes. 一切运行顺利,直到代码到达Excel.utils调用并崩溃。 The code runs fine when running in eclipse. 在eclipse中运行时,代码运行良好。 Any help would be appreciated! 任何帮助,将不胜感激! Thank you 谢谢

The best way to handle your problem is to use Maven/Gradle to build the project and launch tests. 解决问题的最佳方法是使用Maven / Gradle构建项目并启动测试。

https://www.softwaretestinghelp.com/maven-project-setup-for-selenium-selenium-tutorial-24/ https://www.softwaretestinghelp.com/maven-project-setup-for-selenium-selenium-tutorial-24/

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

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