I have added maven dependency for extent reports :
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.5</version>
<scope>provided</scope>
</dependency>.
In the runner class I have specified the plugin in Cucucmber options:
#CucumberOptions(
features={"src/test/java/features/Exception.feature"},strict = true
,glue={"com.selenium.wrapper","stepDefinitaion"},
format = { "pretty","html:target/site/cucumber-pretty","html:target/cucumber-report","json:target/cucumber.json" },
plugin = {"com.cucumber.listener.ExtentCucumberFormatter:output/report.html"}
And In the #After hook i have added the code to add the screenshot:
//* add code to take screenshot and save it
Reporter.addScreenCaptureFromPath("path of the screenshot");
After execution a blank image is added:
image 2 shows the blank screenshot
Did you try saving the screenshot as .png file.I had faced the same issue while embedding screenshots which were saved as .jpg files.
For Cucumber extended report embed is not working due to this, we have to save the image and then
File sourcePath = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
File destinationPath = new File(System.getProperty("user.dir") + "/target/test-report/extent-report/screenshots/" + screenshotName + ".png");
copyFile(sourcePath, destinationPath); Reporter.addScreenCaptureFromPath("./screenshots/"+screenshotName+".png");
Save the screenshot with the ".png" extension. Some issue while embedding the image with .jpg files. I have faced the same issue and I have modified the .jpg to .png and the screenshots are embedded to the extent report.
Related
Tech Stack used
Ruby 2.5.8, Rails 5.0.7, Ruby Gems: combine_pdf
Here is my sample code that is working for most of the PDF Urls hosted in S3, except one PDF.
#pdf = CombinePDF.new
#pdf << CombinePDF.parse(Net::HTTP.get_response(URI.parse(s3_pdf_url)).body)
#pdf = #pdf.to_pdf
Above code is working as expected for 90% of the PDF files, there is one file that is not working for me. I don't see any exceptions generated and not sure how to debug it.
CombinePDF do generates the final pdf and it is blank as shown in this screenshot_link.
Any feedback would be appreciated.
Here is my another example code. I'm writing original S3 PDF into the Tempfile and using CombinePDF.load() to combine the PDF which is there inside tempfile. But still this PDF is not combined and no exception generated. When I opened tempfile(MyPDF20220921-21580-1qzgy1u.pdf) I can see and access PDF.
path = s3_pdf_url
t = Tempfile.new(["MyPDF", '.pdf'])
t.write(open(path).read.force_encoding(Encoding::UTF_8))
t.close
#pdf = CombinePDF.load t.path
#pdf = #pdf.to_pdf
I have created a button to export the form data to simple Excel.
Everything is working file, even if i try to save this excel file in the file cabinet it gets saved correctly.
But when i try to downlaod the excel file, downloads wierd single cell file with special characters or system gives either an error or saves an empty excel file.
Can anyone help me in how to download the excel file from button click. I think i have issue in my responce.
My Code example is as follows:
.
.
.
xmlString += '</Table></Worksheet></Workbook>';// this is my xml string
var xlsFile = nlapiCreateFile('test.xls', 'EXCEL', nlapiEncrypt(xmlString, 'base64'));
response.writeFile(xmlFile);
}
error screenshot:
I think the reason for the response issue is because you are calling a non-existent variable "xmlFile" in writeFile();
try using this writeFile(xlsFile);
I'm trying to download and save a pdf file with nodejs and nightwatchjs, yet it does not work. PDF file remains empty (0kb) and I can't open it with Adobe Acrobat. Here's the code:
var url = "http://www.sait.ca/Documents/sample.pdf"
var file = fs.createWriteStream("form.pdf");
https.get(url, function(response){
response.pipe(file);
});
It looks like this method worked for others (see -> Download File, save it and read it again --> Error), but it does not for me. Am I missing something?
You need to call stream.end().
Store the file in your public folder and do an redirect like this
res.redirect(http://yourdomain.com/uploads/your_file.pdf);
I need to export some data from a few tables to a excel file. The thing is, the only working extension is '.xls', which is too old. So when I open this file it shows in protected exibition mode, even if I uncheck all boxes in Excel Protected Exibition Mode Options.
I'm not sure why I can't save in other extensions, like .xlsx, because if I use the native function to save as .xlsx: STR_OOXML_EXCEL_EXTENSION or just write .xlsx it saves, but does not open the document.
Shows this message: Excel cannot open the file 'file.xlsx' bacause the format or extension is not valid. Check if the document is corrupted or the extension matches the file format.
This is the code I'm using to create the file:
MyWorkbook := TsWorkbook.Create;
try
MyWorksheet := MyWorkbook.AddWorksheet('Orçamento');
And this is the one I'm using to save:
MyWorkbook.WriteToFile(MyDir + orcamento + '.xls', OUTPUT_FORMAT, True);
finally
MyWorkbook.Free;
The only option I can think of, is using another package, Excel or OpenOffice could help.
Settings: Lazarus 1.4.2 with FPC 2.6.4 and fpSpreadsheet 1.6.0, running on Windows 7 64-bit.
I'm not sure what your variable or constant OUTPUT_FORMAT contains but if you specify a format it should be one of these:
sfExcel2, sfExcel5, sfExcel8, sfOOXML, sfOpenDocument,
sfCSV, sfHTML, sfWikiTable_Pipes, sfWikiTable_WikiMedia
So if you want to save as .xlsx you could do this (use sfOOXML as format):
uses fpspreadsheet, fpstypes, xlsxooxml;
//...
MyWorkbook.WriteToFile(MyDir + orcamento + '.xlsx', sfOOXML, True);
You could also do this:
uses fpspreadsheet, fpstypes, xlsxooxml;
//...
MyWorkbook.WriteToFile(MyDir + orcamento + '.xlsx', True);
It will automatically detect the .xlsx extension and save the proper format.
You do need to include xlsxooxml in your uses clause because that unit registers the xlsx-format (automatically).
Hai, i'm using Apache POI 3.6
I've already created some code..
XWPFDocument doc = new XWPFDocument(new FileInputStream(file));
wordxExtractor = new XWPFWordExtractor(doc);
text = wordxExtractor.getText();
System.out.println("adding docx " + file);
d.add(new Field("content", text, Field.Store.NO, Field.Index.ANALYZED));
unfortunately, it generated error..
Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:149)
at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:136)
at org.apache.poi.openxml4j.opc.Package.<init>(Package.java:54)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:98)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:199)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:178)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:53)
at org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:98)
at org.apache.lucene.demo.Indexer.indexDocs(Indexer.java:153)
at org.apache.lucene.demo.Indexer.main(Indexer.java:88)
It seemed that it used Constructor
XWPFWordExtractor(OPCPackage container)
but not this one ->
XWPFWordExtractor(XWPFDocument document)
Any wondering why??
Or any idea how I can extract the .docx then convert it into a String?
You need to Add dom4j Library to your claspath or your project libraries
It looks like you don't have all of the dependencies on your classpath.
If you look at http://poi.apache.org/overview.html you'll see that dom4j is a required library when working with the OOXML files. From the exception you got, it seems that you don't have it... If you look in the POI binary download, you should find it in the ooxml-libs subdirectory.
You could try docx4j instead; see http://dev.plutext.org/svn/docx4j/trunk/docx4j/src/main/java/org/docx4j/TextUtils.java