Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从Selenium的扩展报告3.1.5迁移到4.1.6_Java_Selenium_Selenium Webdriver_Testng_Selenium Extent Report - Fatal编程技术网

Java 从Selenium的扩展报告3.1.5迁移到4.1.6

Java 从Selenium的扩展报告3.1.5迁移到4.1.6,java,selenium,selenium-webdriver,testng,selenium-extent-report,Java,Selenium,Selenium Webdriver,Testng,Selenium Extent Report,我正在尝试将基于selenium/java/gradle的项目从Extent report 3.1.5迁移到4.1.6,以获得所有新的更新。在我的搜索过程中,我注意到ExtentHTMLReporter已从4.1.3中弃用,我们需要使用ExtentSparkReporter。所以,我做了这个更改,但仍然抛出异常“java.lang.NoSuchFieldError:VERSION_2_3_29”。下面是我的记者课 我的记者班: import java.io.FileInputStream; im

我正在尝试将基于selenium/java/gradle的项目从Extent report 3.1.5迁移到4.1.6,以获得所有新的更新。在我的搜索过程中,我注意到ExtentHTMLReporter已从4.1.3中弃用,我们需要使用ExtentSparkReporter。所以,我做了这个更改,但仍然抛出异常“java.lang.NoSuchFieldError:VERSION_2_3_29”。下面是我的记者课

我的记者班:

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.ITestContext;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;

import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.MediaEntityBuilder;
import com.aventstack.extentreports.MediaEntityModelProvider;
import com.aventstack.extentreports.Status;
import com.aventstack.extentreports.reporter.ExtentSparkReporter;
import com.aventstack.extentreports.reporter.configuration.Theme;

import gov.nv.dwss.nvkids.selenium.api.base.CustomExtentTest;
import gov.nv.dwss.nvkids.selenium.utils.ReadPropertyFile;

public abstract class Reporter{


        public RemoteWebDriver driver;
        private static ExtentReports extent;
        public  ExtentTest test;
        public String testcaseName, testcaseDec, author ; 
        public String category;
        private Logger log=Logger.getLogger(Reporter.class);

        @BeforeSuite (alwaysRun = true)
        public void startReport(ITestContext c) throws IOException 
        {
            System.setProperty("org.freemarker.loggerLibrary", "none");
            try {
                Properties prop=new Properties();
                prop.load(new FileInputStream("./Resources/log4j.properties"));
                PropertyConfigurator.configure(prop);
                } catch (Exception e) {
                log.error(e);
            }
            log.debug("Configuring Extent Report...");
            ExtentSparkReporter reporter;
            String extentreportpath;
            String reportName=this.getClass().getName().substring(29, 33).toUpperCase() +" - Test Report";
            String suiteName = c.getCurrentXmlTest().getSuite().getName()+" - Test Report";
            if (suiteName.contains("Default suite")||suiteName.contains("Failed suite"))
            {
                suiteName =reportName;
            }
            String rptName="h5{font-size: 0px;}h5::after{content:\'"+suiteName+"\';font-size: 1.64rem; line-height: 110%;margin: 0.82rem 0 0.656rem 0;}";
            extentreportpath="./reports/"+suiteName+".html";
            reporter = new ExtentSparkReporter(extentreportpath);
            //reporter.setAppendExisting(true);         
            extent   = new ExtentReports(); 
            extent.attachReporter(reporter);
            extent.setSystemInfo("URL", ReadPropertyFile.getInstance().getPropertyValue("URL"));
            //reporter.loadXMLConfig("./Resources/extent-config.xml");
            reporter.config().setTheme(Theme.DARK);
            //reporter.config().setTestViewChartLocation(ChartLocation.BOTTOM);
            reporter.config().setReportName(suiteName);
            reporter.config().setCSS(rptName);
            log.info("Extent Report Configured Successfully");

        }

        @Parameters({"browser"})
        @BeforeClass(alwaysRun = true)
        public ExtentTest report(@Optional("browser") String browser)  
        {
             if(ReadPropertyFile.getInstance().getPropertyValue("RunMode").equalsIgnoreCase("STANDALONE"))
            {
                if(browser.equals("browser")) {
                    browser = ReadPropertyFile.getInstance().getPropertyValue("Browser");
                }
            }
            test = extent.createTest(testcaseName, testcaseDec +" <br /><br />Browser Name: "+browser+" <br /><br />Category: "+category);
            test.assignAuthor(author);
            CustomExtentTest extenttst = CustomExtentTest.getInstance();
            extenttst.setExtentTest(test);
            return test;  
        }



        public abstract long takeSnap();

        public void reportStep(String desc,String status,boolean bSnap)
        {
            MediaEntityModelProvider img=null;
            if(bSnap && !status.equalsIgnoreCase("INFO"))
            {
                long snapNumber=100000L;
                snapNumber=takeSnap();
                try
                {
                    img=MediaEntityBuilder.createScreenCaptureFromPath("images/"+snapNumber+".jpg").build();
                }
                catch(IOException e)
                {
                    log.error(e);
                }
            }
            if(status.equalsIgnoreCase("pass"))
            {
                test.log(Status.PASS, desc, img);
            }
            else if(status.equalsIgnoreCase("fail"))
            {
                test.log(Status.FAIL, desc, img);
            }
            else if(status.equalsIgnoreCase("INFO"))
            {
                test.log(Status.INFO, desc,img);
            }
        }

        public void reportStep(String desc,String status)
        {

            reportStep(desc,status,true);
        }


        @AfterSuite (alwaysRun=true )
        public void stopReport() 
        {
            log.debug("Stopping and preparing the report...");
            extent.flush();
            log.info("Report prepared successfully");
        }
    }
import java.io.FileInputStream;
导入java.io.IOException;
导入java.util.Properties;
导入org.apache.log4j.Logger;
导入org.apache.log4j.propertyConfiguration;
导入org.openqa.selenium.remote.RemoteWebDriver;
导入org.testng.ITestContext;
导入org.testng.annotations.AfterSuite;
导入org.testng.annotations.BeforeClass;
导入org.testng.annotations.BeforeSuite;
导入org.testng.annotations.Optional;
导入org.testng.annotations.Parameters;
导入com.aventstack.extentreports.extentreports;
导入com.aventstack.extentreports.extendettest;
导入com.aventstack.extentreports.mediatentitybuilder;
导入com.aventstack.extentreports.MediaEntityModelProvider;
导入com.aventstack.extentreports.Status;
导入com.aventstack.extentreports.reporter.ExtentSparkReporter;
导入com.aventstack.extentreports.reporter.configuration.Theme;
导入gov.nv.dwss.nvkids.selenium.api.base.CustomExtentTest;
导入gov.nv.dwss.nvkids.selenium.utils.ReadPropertyFile;
公开摘要类记者{
公共远程网络驱动程序;
私有静态扩展端口范围;
公共延伸试验;
公共字符串testcaseName,testcaseDec,author;
公共字符串类别;
私有记录器log=Logger.getLogger(Reporter.class);
@BeforeSuite(alwaysRun=true)
公共void startReport(ITestContext c)引发IOException
{
System.setProperty(“org.freemarker.loggerLibrary”,“无”);
试一试{
Properties prop=新属性();
prop.load(新文件输入流(“./Resources/log4j.properties”);
PropertyConfigurator.configure(prop);
}捕获(例外e){
日志错误(e);
}
调试(“配置数据块报告…”);
延伸公园记者;
字符串扩展端口路径;
String reportName=this.getClass().getName().substring(29,33).toUpperCase()+“-Test Report”;
字符串suiteName=c.getCurrentXmlTest().getSuite().getName()+“-测试报告”;
if(suiteName.contains(“默认套件”)| | suiteName.contains(“失败套件”))
{
suiteName=reportName;
}
字符串rptName=“h5{font size:0px;}h5::在{content:\'”+suiteName+“\'”之后;字体大小:1.64rem;行高:110%;边距:0.82rem 0.656rem 0;}”;
extentreportpath=“./reports/”+suiteName+“.html”;
reporter=新的ExtentSparkReporter(extentreportpath);
//reporter.sets(真);
区段=新的扩展端口();
附件报告人(报告人);
extent.setSystemInfo(“URL”,ReadPropertyFile.getInstance().getPropertyValue(“URL”);
//reporter.loadXMLConfig(“./Resources/extent-config.xml”);
reporter.config().setTheme(Theme.DARK);
//reporter.config().setTestViewChartLocation(ChartLocation.BOTTOM);
reporter.config().setReportName(suiteName);
reporter.config().setCSS(rptName);
log.info(“数据块报告配置成功”);
}
@参数({“浏览器”})
@上课前(alwaysRun=true)
公共扩展测试报告(@可选(“浏览器”)字符串浏览器)
{
if(ReadPropertyFile.getInstance().getPropertyValue(“运行模式”).equalsIgnoreCase(“独立”))
{
if(browser.equals(“browser”)){
browser=ReadPropertyFile.getInstance().getPropertyValue(“浏览器”);
}
}
test=extent.createTest(testcaseName,testcaseDec+“

浏览器名称:“+Browser+”

Selenium版本-3.141.59 Testng-7.1.0 范围报告-4.1.6 Java版本-1.8
请提供您的建议。

最后,是freemarker版本导致了问题。升级到freemark