首页 > 解决方案 > 运行我的 Maven 项目时来自 Eclipse 的 TestNG 错误

问题描述

TestNG Error in Maven Project嗨戴维斯和其他人也是如此: - 下面是我的项目截图和代码,我在TestNg使用 Maven 项目时遇到了这个错误,请帮助我,我还附上了一些截图供参考:-

    GenerateReports.java
    package ExtentReports.GenerateHTMLReports;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.testng.annotations.BeforeTest;
    import org.testng.annotations.Test;
    import com.aventstack.extentreports.ExtentReports;
    import com.aventstack.extentreports.reporter.ExtentSparkReporter;
    public class GenerateReports {
        ExtentReports E2;
        @BeforeTest
        public void config()
        {
            
         String s1 = System.getProperty("user.dir")+"\\reports\\index1.html";
         ExtentSparkReporter E1 = new ExtentSparkReporter(s1);
         E1.config().setReportName("MyAutomationReport");
         E1.config().setDocumentTitle("GoogleHomePage");
         
         E2 = new ExtentReports();
         E2.attachReporter(E1);
         E2.setSystemInfo("Tester", "G");
         
         
        }
        
        
        
        @Test
        public void initializeDriver()
        {
            E2.createTest("MyHTMlReportTest");
            System.setProperty("webdriver.chrome.driver",
                    "F:\\Selenium_Training\\Ganesh_Project\\Browser_Drivers\\chromedriver.exe");
            WebDriver driver = new ChromeDriver();
            driver.get("https://www.google.com");
            driver.getTitle();
            driver.close();
            E2.flush();
        }
        
        
    }

Pom.xml 在 XML 中运行 Maven 项目时出现 TestNG 错误,这是错误消息:-

                org.testng.TestNGException: 
TestNG by default disables loading DTD from unsecured Urls. If you need to explicitly load the DTD from a http url, please do so by using the JVM argument [-Dtestng.dtd.http=true]
                    at org.testng.xml.TestNGContentHandler.resolveEntity(TestNGContentHandler.java:115)
                    at com.sun.org.apache.xerces.internal.util.EntityResolverWrapper.resolveEn
                
                Also, i tried the below possibilities and again getting error message which is different from this:-
                
                I tried to add Jvm argument -Dtestng.dtd.http=true and placed it under run -->run configurations-->arguments-->VM arguments in eclipse
                
After placing the above jvm argument i am getting this new error message in console, do not know how to solve it below is the error after adding jvm argument and running the maven project:-                 
                org.testng.TestNGException: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
                    at org.testng.TestNG.parseSuite(TestNG.java:354)
                    at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:374)
                    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:103)
      

标签: maventestng

解决方案


推荐阅读