Screenshot is not loaded in my Jenkins Result Page - selenium

My Testcase execution result will be displayed in the form of .html.
When I double click and open the .html file, the testcases results
along with the Pass or Fail screenshot will be displayed.
I am executing the selenium testcases in Mozilla Firefox browser
When I open the .html file from my local machine, the images for
every are loaded without any errors.
When I try to open the same .html file from any other system, images are not loaded.
Can somebody help me out in this issue?

I believe you are not able to view HTML properties of your HTML reports. This is working fine as per default Jenkins behavior.
Run below in Script Console (available in Manage Jenkins) to view HTML and CSS properties:
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")

Related

autoit +selanium on jenkins does not work

enter image description hereI have a selenium test implement for web application and implemented autoit to do a folder upload to my application. This folder upload initiates a chrome popup warning which has no title but 2 buttons "Upload" and "Cancel" (default selected). The folder upload is in the control of my application and has title for the popup window. So I could see controlfocus worked on upload folder popup even when my test was deployed on jenkins. But it does not click on the Chrome popup warning
#include <WinAPIFiles.au3>
ControlFocus("Select Folder to Upload","","Edit1")
ControlSetText("Select Folder to Upload","","Edit1","<Myfolder Path>")
sleep(4000)
ControlClick("Select Folder to Upload","","Button1")
sleep(4000)
;this is for the popup warning from chrome
ControlFocus("[CLASS:Edit; INSTANCE:1]","","Edit1")
Send("{LEFT}") <===== this and below does not ever work on jenkins but works on local
execution
Send("{ENTER}")
;sleep(10000)
exit(0)
my selenium code has
String filepath = ".\\uploadfile.bat";
Process p1 = Runtime.getRuntime().exec( filepath );
uploadfile.bat is ....
START /wait c:\AutoIT\uploadfld.exe
As first step run yours AutoIt script, and just after that click the HTML element using selenium.
Do not try to run AutoIt script after clicking the HTML element in selenium, as this stops your selenium because browser waits for file selection.
And as I said in one other cases (question which I answer some time ago), there should be other possibilities to do that without AutoIt, even without invoking the pop up window.

Screenshots are not generating for failure cases using robot framework if i am doing execution through Jenkins in Linux slave

In Robot framework by default screenshots are generating for failure cases.I tried using Get page screenshot keyword, but still i can't see screenshots. Using the same script i can see screenshots if i am doing the execution in local machine.
I am executing with headless chrome in Linux slave with Jenkins. Same scripts are working in local but failing in Jenkins. I want to see screenshots for failures, but screenshots are not generating.
Input Text ${login_password} ${password}
capture page screenshot password.png
click on next ${password_next} ${login_password}
capture page screenshot next.png
It is giving broken image like below.
I tried with below script to store the screenshots. It is working in Local. But screenshots are generating but not coming in html report if i m doing execution in Jenkins server which is hosted in Linux.
Capture Image
[Arguments] ${imagename}
${path}= Catenate SEPARATOR= ${EXECDIR} / Screenshots / ${imagename} . png
capture page screenshot ${path}
Issue Resolved. I am using Robot plugin in Jenkins for results. In Post build configuration till the time i am allowing only log and html report. but now i updated that as to allow .png format files also. So, default it is giving screenshots for failuree.

Selenium Tests for Internet Explorer doesn't executs properly through Jenkins

We have our Health Check automated wherein all of our applications are logged onto, all via Selenium and only on Internet Explorer.
The code runs well when it was executed directly from a batch file. However, when Jenkins calls this batch (.bat) file, it doesn't execute it completely.
BTW the platform is Windows Server 2008 R2 Standard
This is the .bat file code
#echo off
set path="";
set path="E:\XXXX\jre1.8.0_141\bin";
pushd E:\Jenkins_Softwares\SeleniumCode\HealthCheck_jar
SET JAVA_OPTS=-Xmx4g -Xms512m -XX:MaxPermSize=256m -XX:ReservedCodeCacheSize=128m -XX:MaxHeapSize=512m
java -jar HealthCheck_JenkinsNG.jar
I've added these additional IE options in the JAVA code before launching the IE driver.
InternetExplorerOptions options = new InternetExplorerOptions();
options.introduceFlakinessByIgnoringSecurityDomains();
options.enableNativeEvents();
options.destructivelyEnsureCleanSession();
When Jenkins executes the batch file, the IE browser opens into the Login page. There's something odd when this page is displayed - the entire page alignment is disrupted and all elements get aligned to the left. (I'd like to stress that when the batch file is instead executed directly, there is no such page alignment disruption. The elements retain their original centre position. For some reason, Jenkins sets all of this to the left). The alignment is not exactly a deal breaker for me.
However, when username and password is entered via the Selenium code, it types into the perfect text boxes; but when the submit button is hit, the content in these textboxes turn blank and I'm unable to login. (When this same piece of code is executed via running the batch file directly, I'm able to login and The homepage of my application is displayed)
I doubt if there's something wrong with the selenium java code. Since, it executes properly, when run from the .bat file or even command line or even as a Java Application from an IDE.
For some reason, when this is executed from Jenkins it does not work.
Is there any options or settings that needs to be set when Jenkins works with Selenium on IE 11? Because I've tried tweaking the selenium code so much, they all yield the same result - The elements on the Login page get cleared after the submit button is clicked.
Also, just to mention, all of this is run on one Master node of Jenkins only. There are no slave nodes.
You need to take care of a couple of things as follows:
For the build process Jenkins would need the path of jdk. Simply jre may not suffice.
JDK 8u141 is ancient now and you need to upgrade to latest JDK 8u202
introduceFlakinessByIgnoringSecurityDomains() (in Java) and IntroduceInstabilityByIgnoringProtectedModeSettings() (in DotNet) is not an ideal solution to address the issues croping out of Protected Mode settings.
Here you can find a detailed discussion in Internet Explorer Protective mode setting and Zoom levels
To work with Selenium, InternetExplorerDriver and InternetExplorer you need to fulfill the Required Configuration

Static html pages run from file system instead of built-in web-server

I'm running Intellij 13 Ultimate. I'm trying to open a web page I'm working on, and it's opened from the file system:
file:///Users/<username>/dev/index.html
Instead of something like:
http://localhost:<port>/index.html
Thing is, other projects run as expected and I can't figure out what's misconfigured in this specific project.
How do you open the page?
If you open your HTML file inside IntelliJ and go to Run > Run xxx.html (or Debug), a localhost page should be opened. If it isn't, check your Run Configuration (Run > Edit Configurations) and check the URL field.
View > Open in Browser should also work as expected.

Using Firefox HTML source viewer in VB.NET?

I want to view the HTML source of a web page, I've using ICSharpCode.TextEditor, Scintilla,... and they're all good. But, I have missed Firefox HTML source viewer.
I wonder if I can use Mozilla ActiveX Control to open the source viewer or is there a command line argument that make Firefox open it? Thanks!
You can do that from the command line like:
$> firefox view-source:http://stackoverflow.com
Or you can put something like this in the URL bar: "view-source:http://stackoverflow.com"
If you happen to want to open it in a new window:
$> firefox -new-window view-source:http://stackoverflow.com
There is a reference at mozillazine.org.