3

I have an automation testing project using LeanFT automation tool (in Java). Those tests covers UI flows of a web application.

Jenkins job execute those tests nightly on remote slave RDP VM.

I realized that tests sometimes fail, but couldn't spot the exact reason. After investigation, i found out that if the last user logged in to the VM had resolution different than 1920 X 1080 (for example login to the with laptop with different native resolution) tests are failing.

I am using LeanFT VRI method (Visual Relational Identifiers) in my tests to identify objects which have no ID, meaning identifying objects based on other objects in the DOM (closest on x/y Axis). so this is obviously related to screen resolution.

My question is: How can i insure my tests start with the needed screen resolution, regardless to the last login resolution ? I assume i need a way to override the existing resolution using Jenkins parameter or adding some line of code to my testing project to support a case which resolution is different than 1920 x 1080.

Udi
  • 31
  • 1

1 Answers1

0

Assuming we're talking Windows OS here, you can do that by calling some WinAPIs functions.

As mentioned in this answer, you can use:

  1. EnumDisplayDevices to figure out what displays you have available
  2. EnumDisplaySettings to get a list of available resolutions for your displays. 3.ChangeDisplaySettings to set the resolution you need.

To call those functions in Java you can use the Java Native Access (JNA). As they mention:

The definitive JNA reference (including an overview and usage details) is in the JavaDoc. Please read the overview. [...] you may find it easier to find answers to already-solved problems on StackOverflow.

Adelin
  • 7,809
  • 5
  • 37
  • 65