Unable to view screenshots in Jenkins reports - jenkins

My jenkins reports do not show the screenshots captured in the runs. (They are run on a MAC). However, when I run the same job locally (windows machine), the reports have the screenshots.
I see the error as below in the Jenkins report.
When I try to open the image, It shows below. It's unable to find the path to the image actually.
Error : http://*****-mac:8080/job/***Test/job/******/ws/target/screenshots/2019-01-14/Sign%20In20190114154253.png
Actual: http://*****-mac:8080/job/***Test/job/******/HTML_20Report/target/screenshots/2019-01-14/Sign%20In20190114154253.png
I'm using the below code to capture the screenshot. It does capture the screenshots & I can see them in the actual location.
I don't know when I did a mistake, these images are not seen as links/not available in the report:
public void captureScreenshot() throws IOException {
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String dateForScreenshots = dateFormat.format(date);
File localScreenshots = new File(new File("target/screenshots"), dateForScreenshots);
if (!localScreenshots.exists() || !localScreenshots.isDirectory()) {
localScreenshots.mkdirs();
}
System.setProperty("org.uncommons.reportng.escape-output", "false");// this is to create a link in ReportNG
File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
String destination = System.getProperty("user.dir") + "/target/screenshots/" + dateForScreenshots + "/" + getDriver().getTitle() + Utils.generateRandomString() + ".png";
File screenshotName = new File(destination);
//Now add screenshot to results by copying the file
FileUtils.copyFile(scrFile, screenshotName);
Reporter.log("<br> <img src='" + destination + "' height='90' width='160' /><br>");
Reporter.log("");
}

From this line
Error : http://*****-mac:8080/job/***Test/job/******/ws/target/screenshots/2019-01-14/Sign%20In20190114154253.png
I think that Jenkins cannot find the target branch in the workspace folder (ws). Probably you need to specify the workspace folder in the Jenkins job (as in this answer) or just change the destination variable somehow to something like (added /HTML_20Report):
String destination = System.getProperty("user.dir") + "/HTML_20Report/target/screenshots/" + dateForScreenshots + "/" + getDriver().getTitle() + Utils.generateRandomString() + ".png";

Related

Electron.AutoUpdater.OnDownloadProgress not getting called during differential update download

We are using SignalR package to show the download progress to our electron desktop application. But it was found that the Electron.AutoUpdater.OnDownloadProgress was not getting called during differential update download after Electron.AutoUpdater.DownloadUpdateAsync(); was called.
enter image description here
However after deleting all the files inside C:\Users\username\AppData\Local\electron-updater and calling DownloadUpdateAsync(); the OnDownloadProgress works.
enter image description here
enter image description here
Electron Package: ElectronNET.API Version:13.5.1
.Net Version: 5.0
Node Version: v14.15.0
enter image description here
Electron.AutoUpdater.OnDownloadProgress += async (info) =>
{
var percentage = Math.Round(Convert.ToDouble(info.Percent), 1);
var totalsizeinmb = FormatSize(Convert.ToInt64(info.Total), "MB");
var downloadspeedinmb = FormatSize(Convert.ToInt64(info.BytesPerSecond), "MB");
var transfereedinmb = FormatSize(Convert.ToInt64(info.Transferred), "MB");
Console.WriteLine("percentage: " + percentage + "totalSize: " + totalsizeinmb + "downloadspeed: " + downloadspeedinmb + "transferSpeed: " + transfereedinmb);
await app.ApplicationServices.GetRequiredService().Clients.All.SendAsync("ReceiveDownloadProgress", percentage.ToString(), downloadspeedinmb, transfereedinmb, totalsizeinmb);
};

Rotativa BuildPdf is working on local computer but not on production server

I am using Rotativa to generate a pdf from a view I have created. Locally this works fine, the pdf is stored on my local computer and the email functiont then attaches and sends the file. But when I release it on our server, it basically breaks at this part:
var binary = pdf.BuildPdf(this.ControllerContext);
The website takes ages to load and then finally just says
Sorry, an error occurred while processing your request.
What i did to test this was to redirect to the actual view which will be generated in a pdf until this error was shown. I thought the issue was that the website does not have any write rights but could create directories in the required folder up until the above part mentioned.
What can I do to solve this?
Here is my full section of code for this part:
string Switches = string.Format("--print-media-type --header-html {0} --footer-html {1}", Url.Action("Header", "Home", new { area = "" }, "http"), Url.Action("Footer", "Home", new { area = "" }, "http"));
var fileName = ReportName+objScor.Name+"_"+objScor.Surname + DateTime.Now.ToString("dd MMM yyyy HHmmss") + ".pdf";
var filePath =(#"C:\\PDFReport\\" + fileName);
if (!System.IO.File.Exists(#"C:\\PDFReport\\"))
{
Directory.CreateDirectory(#"C:\\PDFReport\\");
}
var pdf = new Rotativa.ViewAsPdf("Report", report)
{
FileName = fileName,
CustomSwitches = Switches
};
var binary = pdf.BuildPdf(this.ControllerContext);
Thanks in advance.

Vaadin 7 and applet

0.7 and I want to Call an Applet for use a Token.
I did various tests:
1) Use of AppletIntegration 1.2.9 but when I call applet there's an Exception "ClassNotFoundException PaintTarget"
2) Download Legacy 1.2.10 by https://github.com/Haulmont/AppletIntegration/releases but when I cal the page I have the Exception ""Widgetset does not contain implementation for org.vaadin.applet.AppletIntegration. Check its #ClientWidget mapping, widgetsets GWT module description file and re-compile your widgetset. In case you have downloaded a vaadin add-on package, you might want to refer to add-on instructions. Unrendered UIDL:
org.vaadin.applet.AppletIntegration(NO CLIENT IMPLEMENTATION FOUND)"
3) I create a class AppletCustom
public class AppletCustom extends CustomComponent {
public AppletCustom(String codebase,
String archive,
String code,
String width,
String height,
Map<String, String> params) {
setCompositionRoot(new Label("<div id='appletDiv'></div>", ContentMode.HTML));
StringBuilder sb = new StringBuilder();
/* create the applet */
sb.append("var obj = document.createElement('object');");
sb.append("obj.setAttribute('type','application/x-java-applet');");
sb.append("obj.setAttribute('width','" + width + "');");
sb.append("obj.setAttribute('height','" + height + "');");
sb.append("var codeParam = document.createElement('param');");
sb.append("codeParam.setAttribute('name', 'code');");
sb.append("codeParam.setAttribute('value', '" + code + "');");
sb.append("obj.appendChild(codeParam);");
sb.append("var archiveParam = document.createElement('param');");
sb.append("archiveParam.setAttribute('name', 'archive');");
sb.append("archiveParam.setAttribute('value','" + archive + "');");
sb.append("obj.appendChild(archiveParam);");
sb.append("var param = document.createElement('param');");
sb.append("param.setAttribute('name', 'codebase');");
sb.append("param.setAttribute('value','" + codebase + "');");
sb.append("obj.appendChild(param);");
/* add params to the applet if you like */
if(params != null && !params.isEmpty()){
Iterator<Entry<String, String>> it =
params.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> pairs = (Map.Entry<String, String>) it.next();
sb.append("param = document.createElement('param');");
sb.append("param.setAttribute('name', '" + pairs.getKey() + "');");
sb.append("param.setAttribute('value','" + pairs.getValue() + "');");
sb.append("obj.appendChild(param);");
}
}
sb.append("document.getElementById('appletDiv').appendChild(obj);");
JavaScript.getCurrent().execute(sb.toString());
}
}
and i Call it in the page. The applet is seen correctly but i must to return a value using the method
vaadinUpdateVariable("docName", docName + SIGNED_FILE_SUFFIX, true);
How can i resolve my problem?
you might have have run into one of two Maven GWT plugin bugs: [MGWT-147][1] or [MGWT-148][2] just like [Henri Sara][3] said .
i recommended this blog for you : Vaadin addons and maven and eclipse.
please read this also : Using Vaadin with Maven 2
to help you getting your add-on work . if still n't fixed i refer using [Embedded][6] ui component and avoid the hard coding html tag's.
i wish if i helped you if n't i'm sorry that all i know about Vaadin+applets.
1# jira.codehaus(.)org/browse/MGWT-147
2#jira.codehaus(.)org/browse/MGWT-148
3#vaadin(.)com/c/my_sites/view?groupId=13199&privateLayout=0
4# vaadin(.)com/download/prerelease/7.0/7.0.0/7.0.0.rc2/docs/api/com/vaadin/ui/Embedded.html

Uploading in MVC Dynamically creating folder with persmissions

VS'12 Ineternet Application Template asp.net C# MVC4, EF Code First
Upload Post Method
if (ModelState.IsValid)
{
foreach (var file in attachments)
{
string strMappath = "~/UploadedImages/" +var1+ "/" + var2+ "/" + var3+ "/" + var4+ "/" + var5 + "/";
if (!Directory.Exists(strMappath))
{
DirectoryInfo di = Directory.CreateDirectory(strMappath);
}
// Some browsers send file names with full path. We only care about the file name.
//var fileName = Path.GetFileName(file.FileName);
var fileName = Path.GetFileNameWithoutExtension(file.FileName) + Path.GetExtension(file.FileName);
var destinationPath = Path.Combine(
Server.MapPath(strMappath), fileName);
file.SaveAs(destinationPath);
}
My Questions are
Why is it not creating my Folders
When i ( cheat and make them myself ) i have no permissions...
How can you best upload Dynamically ( I would like to keep uploaded files separately )
Is there a better way to manage them?
This is for both on the Dev machine though IIS and on my Server-also IIS
Use Server.MapPath(strMappath) to create folders and check if exist.

vlcj:: Unable to load library 'libvlc' in 64bit OS

I am using 64 bit OS Windows 7 and i have 32 bit VLC versioned 1.1.8.
I have added these libraries
jna.jar
platform.jar
vlcj-1.1.5.1.jar
I am not able to stream using jVlc
public class HelloVLC {
/**
* #param args
* #throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
System.out.println( WindowsRuntimeUtil.getVlcInstallDir());
NativeLibrary.addSearchPath("libvlc", "C:\\Program Files (x86)\\VideoLAN\\VLC");
String media = "dshow://";
String[] options = {" :dshow-vdev=Integrated Webcam :dshow-adev= :dshow-caching=200", ":sout = #transcode{vcodec=theo,vb=800,scale=0.25,acodec=vorb,ab=128,channels=2,samplerate=44100}:display :no-sout-rtp-sap :no-sout-standard-sap :ttl=1 :sout-keep"};
System.out.println("Streaming '" + media + "' to '" + options + "'");
MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory();
final HeadlessMediaPlayer mediaPlayer = mediaPlayerFactory.newMediaPlayer();
mediaPlayer.playMedia(media, options);
}
}
I am getting the error Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'libvlc': The specified module could not be found.
Kindly help. Is there any way to get this code work in 64 bit OS????
have you tried running it with a 32-bit JVM?
if you are using windows 7 then search for a file libvlc.dll and libvlccore.dll files in to your vlc installation and add their path to code that you've written in
NativeLibrary.addSearchPath() also add...
this worked me in my case windows 7.
NativeLibrary.addSearchPath(
RuntimeUtil.getLibVlcLibraryName(), ""c:/Program Files/VideoLAN/VLC/");
Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
LibXUtil.initialise();
VLCj comes with automagic discovery methods, os-independent, that adds the relevent path to JNA:s search path:
NativeDiscovery nd = new NativeDiscovery();
if (!nd.discover()) {
System.out.println("VLC not found");
System.exit(-1);
}
String vlcLibName = RuntimeUtil.getLibVlcName();
String vlcLibCoreName = RuntimeUtil.getLibVlcCoreName();
Native.loadLibrary(vlcLibName, LibVlc.class);
...etc
for a good tutorial on how to load the VLC natives, see
http://capricasoftware.co.uk/#/projects/vlcj/tutorial/first-steps
(See also the previous steps in that tutorial)!

Resources