CMD window Close automatically after Jenkins build is over - selenium

I trying to run Selenium grid and node using Jenkins but the CMD windows always closes after executing the steps
i am running the below code in Jenkins Window Batch Command
cd "C:\TapsiumACSS\Grid3.9"
start Hub.bat
I need the CMD window to be opened

You can create a shortcut of the bat file and under properties in the target section you have to add &PAUSE
This will pause the command prompt until an user input is done.
Just a opinion, Not a good idea to use Jenkins and ask the user to do something as that defeats the whole automation aspect... Instead copy the selenium results into a html or text file which can be viewed later :)
P.S. you will have to refer to this bat file location in Jenkins i.e. the shortcut location
Hope it helps :)

Related

Pipe console output of IntelliJ to a script

It is possible to pipe the console output of an intellij application to a bash command so I can pretty-print it on the console directly?
I know I can save the log output to a file, but I still want to keep it on the stout window only, but just parse it through a script.
Piping output is a feature of the terminal shell.
IntelliJ IDEA is not using a terminal to run your app, therefore it's not possible with the default Run/Debug configurations.
You could use an external tool that will open a command line shell and run your app there, but the shell has to be open in a separate window and it will not be possible to get the formatted output directly in the IDE.
There is a related feature request in YouTrack, but it's unlikely to be implemented soon.

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

Upload file through vba and WinSCP.com

I don't know what is happeining since it's just flashing by the screen. But I have this code in vba.
Shell "H:\Dokument\Avvikelser\WinSCP.com /script=H:\Dokument\Avvikelser\script.txt"
In script.txt i have:
open ftpes://USERNAME:PASSWORD#ftp.SERVER.nu
put H:\Dokument\Avvikelser\lista.txt /Avvikelser/lista.txt
close
As I have understood it I need ftpes to make it passive?
I can't even start WinSCP from cmd prompt
I need to use a cmd style solution as I can't install software on the computer.
The file is not uploaded when the script ends.
WinSCP.COM is only an console interface program for WinSCP.EXE, you need to have both in the same directory.
See https://winscp.net/eng/docs/executables

Start program via ssh in Jenkins and using it in Jenkins build

Hello people.
I'm using Jenkins as CI server and I need to run some performance test using Jmeter. I've setup the plugin and configured my workspace and everything works ok, but I have to do some steps manually and I want a bit more of "automation".
Currently i have some small programs in a remote server. These programs make some specific validations, for instance (just to explain): validates e-mail addresses, phone numbers, etc.
So, before I run the build in jenkins, I have to manually start the program (file.sh) I want:
I have to use putty (or any othe ssh client) to conect to the server and then run, for instance, the command
./email_validation.sh
And the Jmeter test runs in a correct way, and when the test is done I have to manually "shut down" the program I started. But what I want is trying to start the program I need in Jenkins configuration (not manually outside Jenkins, but in "execute shell" or "execute remote shell using ssh" build step).
I have tried to start it, but it get stuck, because when Jenkins build finds the command
./email_validation.sh
the build stops, it waits for the command to finish and then it will continue the other build steps, but obviously, I need this step not to finish until the test is executed.
Is there a way to achieve this? Thanks
Run your command as a background process by adding the & symbol at the end of the command and use the nohup command in case the parent process gets a hangup signal, e.g.
nohup /path/to/email_validation.sh &
If the script produces any output, it will go by default to the file nohup.out in the current directory when the script was launched.
You can kill the process at the end of the build by running:
pkill email_validation.sh

How can I run a Windows shell script prior to launching an application?

Is there a way to configure an application shortcut so that a Windows shell script is run prior to kicking off the application? In my case, I want to back-up some files before the application runs.
Thanks!
You could change the application shortcut to actually run the shell script and just add a START command to the end of the script so it runs the program once complete.
IE: change the notepad shortcut from %SYSTEMROOT%\Windows\Notepad.exe to c:\launchNotepad.bat and have launchnotepad.bat be something like
COPY importantfile.txt importantfile.txt.bak
START %SYSTEMROOT%\Windows\Notepad.exe importantfile.txt