I'm looking for a solution to output a TestNG/Selenium screenshot in Jenkins. Ideally, when a Jenkins job runs I want to either have the images embedded into the Console Output or have a link display so the user can view the screenshot in a separate window.
Here's a function I'm using right now:
#AfterMethod
public void takeScreenShotOnFailure(ITestResult testResult) throws IOException {
if (testResult.getStatus() == ITestResult.FAILURE) {
System.out.println("Status: " + testResult.getStatus());
System.out.println("<img src=\"data:image/png;base64," +
((TakesScreenshot)driver).getScreenshotAs(OutputType.BASE64) + "\" ></img>");
}
}
The problem is that Jenkins displays the output as plain text. I tried copying the output into an html page and it looks fine. So it appears that the way Jenkins presents the information causes Firefox/Chrome to display the html code as plaintext. Any idea how to get around this? Or is there a better way to get TestNG's takescreenshot functionality to work with Jenkins?
You archive the screenshot using the "archive the artifacts" option in the "post build actions" of the jenkins project configuration page.To archive first u need to set the custom workspace for the project.The custom workspace should point to the root directory or the folder which is containing the folder of screenshots.Then after archiving all the screenshots will appear as links in the project page.Here "reports" will be folders containing the screenshots or any file.reports is under The "QTP" folder which is mentioned in the custom workspace.pls use slash instead of backslash in the archive the artifacts option.
Project page:
using custom workspace in jenkins
archiving the artifacts using post build actions
Jenkins console output can not show the images. But It shows the links as links - you can click on it from the console output to the corresponding site.
So, your takeScreenShotOnFailure can be modified to move the image to a common ftp folder from the slave machine & provide the link in the console output.
You should be able to see the image immediately.
It supports http/ftp links.
Perhaps you can use the html publisher plugin.
https://wiki.jenkins-ci.org/display/JENKINS/HTML+Publisher+Plugin
Generate a basic html file with text and images, and it will show up as a clickable link on your job page.
The image will be stored together with all other build data in Jenkins.
Related
I have written a Java WebApp with Vaadin 14.8.0 and SpringBoot.
When I put the application in production mode and create a war file with the command "mvn clean package -Pproduction" and deploy it on my Wildfly, everything works normally. My CSS files are read and also activated.
However, the path I use in the css file for the background image is not found.
"background-image: url("/META-INF/resources/img/zac-bromell-QwrTnOlWAmI-unsplash.jpg");"
If I enter the path directly as url:
"http://localhost:8080/planyoureplaylist-1.0-SNAPSHOT/META-INF/resources/img/zac-bromell-QwrTnOlWAmI-unsplash.jpg"
I also get a 404 Not Found.
My css files are located in the root directory under ./frontend/styles.
My image files can be found in src/main/resources/META-INF/resources/img/.
I also looked at my WAR file with WINRAR. Since I notice that I find the image files in the directory WEB-INF\classes\META-INF\resources\img, but in the whole folder structure not my css files.
To my surprise the background image was displayed normally when I started the application not yet via an external wildfly.
In reference to the following link https://github.com/vaadin/flow/issues/11015 I understand that it is a bug of vaadin. However, since I am on Vaadin 14.8.0 and the bug should be fixed with 14.6.2 I do not understand the problem.
Gladly point out if something else is needed to solve the problem.
About help I would be very happy.
Thanks in advance
The files in META-INF/resources are published in the server root so your META-INF/resources/img/zac-bromell-QwrTnOlWAmI-unsplash.jpg file is available at img/zac-bromell-QwrTnOlWAmI-unsplash.jpg inside your context root. Your background image CSS should thus be "background-image: url("img/zac-bromell-QwrTnOlWAmI-unsplash.jpg");"
When I run a java web project it always opens in my browser the "index.html" page, so I want to choose another page when the project starts.
How can I do it?
Thanks in advance.
Configure the URL to be used when you run your project as follows:
Select your project in the Projects panel, right click and select Properties... from the context menu.
Select Run from the list of categories.
You should see that Context Path already is set to something. It is set to /WebApplication1 in the sample screen shot below. Leave that field alone.
Specify the Relative URL you want to be used when NetBeans runs your application. By default it will be empty. The value you provide will be appended to the context path to construct the URL. In the screen shot below the relative URL is set to /Servlet1, so this will be be appended to the context path of /WebApplication1 to build the URL http://localhost:8080/WebApplication1/Servlet1 to be used when the application is run.
When your web application is run, the URL to be used is logged to the run window. Note the text Browsing: http://localhost:8080/WebApplication1/Servlet1 near the bottom of the screen shot.
I currently have a major problem with loading of CSS and images in JavaFX.
The goal is to make JavaFX load the images that are defined in the CSS file. I get this to work easily in the IDE and in the standalone execution. But once I try the the application as a applet and run it inside a browser context everything fails.
The CSS file is still load properly, but the image files remain blank. Sadly I can't find a way to make JavaFX log why the image loading is failing. All the images are located in subdirectories from the location of the CSS file and are accessed for example like this:
.button-gray {
-fx-border-image-source: url("button/buttongray.png");
}
The CSS file is located in the same package as the class that handles loading it and is load like this:
final URL css = Util.class.getResource("sheet.css");
if (css != null) {
parent.getStylesheets().add(css.toExternalForm());
}
I tried already placing the resources in the root directory and load it with Util.class.getClassLoader.getResource(...) and Thread.currentThread().getContextClassLoader.getResource(...). Both worked fine in case the application was executed as stand alone. Neither worked in case the application is launched from a webstart applet context.
But as I said. In all cases there is no indication that the CSS is not load. The styles defined in the stylesheet are applied properly with exception of the images.
I am running out of idea what the reason for this is. I package and publish the application using the gradle javafx plugin by shemnon.
Building environment:
Oracle Java 1.7b45 x64
Gradle 1.9
Anyone know how to fix this problem or has any idea how to debug it.
Sadly the logging facilities of JavaFX (even the CSS Logger) and the applet trace console give no indication what the problem is.
New Information!
The JNLP file is located here:
JNLP-File
How ever, this file is not the problem. The problems seems to be the generation of the binary css file that is part of the deployment process of JavaFX for webstart. In this binary file, for some yet unknown reason there is a reference to the CSS file inside by building environment. This causes the CSS loader to load the image files from the location on my building server. Something that does not work in my local computer. Builds I did on my local computer on the other hand work because the files are still at the location its looking for.
So now the problem seems to be limited to the binary css generation that stores a entirely wrong file reference.
1) Can you post the .jnlp file that you're using to deploy the app? An incorrect .jnlp can cause resource loading issues like this.
2) Give us the exact invocation of Thread.currentThread().getContextCLassLoader.getResource("") that you're using.
3) Report the contents of the .jar file, with the exact folder/path structure of the file(s) in the jar that you need to load. For example, 'My code is looking for example.png, it should be in the pics.jar file inside the folder com/mycompany/myimages', something like that.
WebStart takes some doing to get working, but I'd suspect the answer lies in there somewhere. If all else fails, I've found JaNeLa to be helpful in debugging web start deployment problems. http://pscode.org/janela/
Have you tried loading the css file with:
final String css = getClass.getResource("sheet.css").toExternalForm();
parent.getStylesheets.add(css); // taken that parent is the name for the Scene.
For the css:
-fx-border-image-source: url("../button/buttongray.png");
Using URL and Util.class is not something that is common to use for loading stylesheets afaik.
Maybe try NetBeans IDE 7.4. Personally i don't know Gradle.
i am using eclipse for android programing and now i need to view SQLite database in the emulator.
I followed these step:
Download .jar file
Place the plugin .jar file in your Eclipse plugins folder (e.g. /usr/lib/eclipse/plugins)
Restart Eclipse
Start up an Android Emulator w/ Debugging in Eclipse
Switch to the DDMS Perspective in Eclipse
Go to the 'File Explorer' tab to locate your device's database file
Navigate to: e.g. 'data -> data -> com.myproject -> databases -> myproject
Now when i try to Open the database file in Questoid i can't select it!
(see screen shot)
same advice?
From your screen shot there, the database does not have a "." (read: period) in the file name & extension area.
Improper: mydatabaseDB
Proper: mydatabase.db
Once the database shows the proper extension (and is a proper SQLite database), then Questoid will (I use the plugin all the time in Eclipse (Juno version)) then show the "active" button (not disabled like in your screen shot). When looking for latest database entries (what was just added into the database), I then click once again on the toolbar icon as you show there, in the upper right of the screen. I then go to the Browse Data tab for that view, then choose the table from the database I want to view the fields from.
I hope this helps.
Happy coding...
I had the same problem with "sqlitemanager": only .db-Database files are accepted.
This is the solution:
Download this Questoid SqLiteBrowser: http://www.java2s.com/Code/JarDownload/com.questoid/com.questoid.sqlitebrowser_1.2.0.jar.zip
Unzip and put it into eclipse/dropins (not Plugins)
Try following these steps:
1) Close Eclipe
2) Remove the .jar from /usr/lib/eclipse/plugins.
3) Place the .jar in /eclipse/dropins and let Eclipse try to install it for you.
4) Start Eclipse.
you can always use sqlitebrowser externally . You will have to pull your databse everytime from ddms though .
The file has to end with .db extension, so the answer is to name your database as this sqlite browser expects it to be.
Another way of fixing it is to find a year old version that does not have this constraint.
Please use the extension ".db" in lowercase, please don't try with these extensions .SLQLITE, .BD, .DB, .SQL, or similar or without extensions.
Regards,
I'm trying to make my own website using Weebly. I want to include a Java Applet I made and therefore I must use an HTML snippet on the website. In the snippet I have to include the path of my uploaded Applet in order for it to run. How can I get this path, because I do not know where the files end up after uploading them. I saw in one post that each user gets a very specific path with each upload but how did they find this out? Is there a way?
not sure if you still need an answer to this....the path for uploaded files into your weebly site (via the Design Tab, then "edit HTML/CSS" menu is "/files/theme/yourfilename.js"
Weebly by default gives it's subdomain sites the ability to control content so when you upload anything to weebly via Code Editor (Weebly main -> Design -> Edit Html/CSS -> Add New Files)
the default address is
yoursubdomain.weebly.com/files/theme/filename.extension
For example if my file name is social-grey and is png extension and my subdomain is geniusknight ( http://geniusknight.weebly.com ) then the link would be:
geniusknight.weebly.com/files/theme/social-grey.png
Similarly for Javascript extension with name test would be
http://geniusknight.weebly.com/files/theme/test.js
and make sure in the source use the complete url and not the short ones like test.js because that doesn't work in subdomain sites for weebly.
Go to Design > Edit HTML/CSS > Assets folder.
Go to the image or file you'd like to reference and grab the URL.
e.g. http://www.weebly.com/editor/uploads/3/4/0/9/34091/custom_themes/647127941726820885/files/homelogos/codehs.jpg
To use a relative path instead of an absolute path, remove everything before /uploads...
e.g. /uploads/3/4/0/9/34091/custom_themes/647127941726820885/files/homelogos/codehs.jpg
Hope that helps!
Go to Weebly then design and edit html.
Left click a pre existing .png image, then in that same window right click over the image that pops up and go to open image in new tab.
In the new tab you will see the address in the address bar. It will look something like this...
weebly.com/uploads/6/9/2/1/12851110/custom_themes/138585217722419571/files/yilogo.rar?1407684265479
You can drop the ?1407684265479 bit to have a direct url for your file!!!!
weebly.com/uploads/6/9/2/1/12851110/custom_themes/138585217722419571/files/yilogo.rar
Then replace that file name in this case yilogo.rar with the file you have just uploaded or wish to use from your existing collection. E.g.
weebly.com/uploads/6/9/2/1/12851110/custom_themes/138585217722419571/files/flags.exe