0

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.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • To set a variable, the recommended syntax is `Set "variable=value"`. Can you please explain why you're removing every location from the built-in system variable, `%PATH%`. – Compo Jun 13 '19 at 13:40
  • Not sure about the alignment issue but for login related issue we need to see your selenium code and HTML and JS code of that web page. It can help to narrow down the issue. – Deepak-MSFT Jun 13 '19 at 14:03
  • The system has JAVA 1.6 installed. I can't upgrade this as 1.6 is the basic requirement for some other applications being used on the same system. Since, Selenium required JAVA 1.8, I'm just referencing the 1.8 lib when this batch file is executed, thereby providing the required platform for my selenium tests to be launched safely. This works fine as I've mentioned in the post that when the batch file is executed directly, the selenium scripts work. – Dean Woods Jun 14 '19 at 10:25

1 Answers1

0

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
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352